private static void ReplaceServiceEndpointAsyncContracts(object[] constructorArgs) { for (int i = 0; i < constructorArgs.Length; ++i) { var endpoint = constructorArgs[i] as ServiceEndpoint; if (endpoint != null) { var asyncEndpoint = new ServiceEndpoint(ContractDescription.GetContract( AsyncType.GetAsyncType(endpoint.Contract.ContractType))) { Name = endpoint.Name, Address = endpoint.Address, Binding = endpoint.Binding, ListenUri = endpoint.ListenUri, ListenUriMode = endpoint.ListenUriMode }; asyncEndpoint.Behaviors.Clear(); foreach (var behavior in endpoint.Behaviors) { asyncEndpoint.Behaviors.Add(behavior); } constructorArgs[i] = asyncEndpoint; } } }
public AsyncWcfCallContext(AsyncCallback callback, object state, AsyncType asyncType, object defaultReturn) { this.callback = callback; this.state = state; this.asyncType = asyncType; this.defaultReturn = defaultReturn; }
public AsyncWcfCallContext(AsyncCallback callback, object state, AsyncType asyncType, object defaultReturn) { this.callback = callback; this.state = state; this.asyncType = asyncType; this.defaultReturn = defaultReturn; }
private IInterceptor[] GetInterceptors(IKernel kernel, ComponentModel model, Type serviceContract, IWcfChannelHolder channelHolder, CreationContext context) { var interceptors = ObtainInterceptors(kernel, model, context); // TODO: this should be static and happen in IContributeComponentModelConstruction preferably var clientModel = (IWcfClientModel)model.ExtendedProperties[WcfConstants.ClientModelKey]; Array.Resize(ref interceptors, interceptors.Length + (clientModel.WantsAsyncCapability ? 2 : 1)); int index = interceptors.Length; interceptors[--index] = new WcfRemotingInterceptor(clients, channelHolder); if (clientModel.WantsAsyncCapability) { if (channelHolder.RealProxy == null) { throw new InvalidOperationException(string.Format( "Component {0} requested async support, but the channel does not support this capability.", model.Name)); } var getAsyncType = WcfUtils.SafeInitialize(ref asyncType, () => AsyncType.GetAsyncType(serviceContract)); interceptors[--index] = new WcfRemotingAsyncInterceptor(getAsyncType, clients, channelHolder); } return(interceptors); }
public ucProcess(AsyncType type) { InitializeComponent(); if (type == AsyncType.Loading) { this.progressBar.Style = ProgressBarStyle.Marquee; } }
public AsyncWcfCallContext(AsyncCallback callback, object state, AsyncType asyncType, IWcfChannelHolder channelHolder, object defaultReturn) { this.callback = callback; this.state = state; this.asyncType = asyncType; ChannelHolder = channelHolder; this.defaultReturn = defaultReturn; }
public AsyncWcfCallContext(AsyncCallback callback, object state, AsyncType asyncType, IWcfChannelHolder channelHolder, object defaultReturn) { this.callback = callback; this.state = state; this.asyncType = asyncType; ChannelHolder = channelHolder; this.defaultReturn = defaultReturn; }
private static void SetAsyncTypeAsTargetType(object target) { var channelFactoryType = FindTypeContainingChannelTypeField(target.GetType()); if (channelFactoryType == null) { // This should literally never happen... return; } var channelTypeField = GetChannelTypeField(channelFactoryType); var channelType = (Type)channelTypeField.GetValue(target); channelTypeField.SetValue(target, AsyncType.GetAsyncType(channelType)); }
public void Start(Action <Action <int, string> > workAction, AsyncType asyncType) { lock (workList) { if (workList.Contains(this._control)) { return; } else { workList.Add(this._control); } } this._asyncType = asyncType; AddLoadingLayer(); _workAction = workAction; _work.RunWorkerAsync(); }
private IInterceptor[] GetInterceptors(IKernel kernel, ComponentModel model, Type serviceContract, IWcfChannelHolder channelHolder, CreationContext context) { var interceptors = ObtainInterceptors(kernel, model, context); // TODO: this should be static and happen in IContributeComponentModelConstruction preferably var clientModel = (IWcfClientModel)model.ExtendedProperties[WcfConstants.ClientModelKey]; Array.Resize(ref interceptors, interceptors.Length + (clientModel.WantsAsyncCapability ? 2 : 1)); int index = interceptors.Length; interceptors[--index] = new WcfRemotingInterceptor(clients, channelHolder); if (clientModel.WantsAsyncCapability) { var getAsyncType = WcfUtils.SafeInitialize(ref asyncType, () => AsyncType.GetAsyncType(serviceContract)); interceptors[--index] = new WcfRemotingAsyncInterceptor(getAsyncType, clients, channelHolder); } return(interceptors); }
protected AsyncMethod(MethodInfo syncMethod, AsyncType type) { if (syncMethod == null) { throw new ArgumentNullException("syncMethod"); } if (type == null) { throw new ArgumentNullException("type"); } if (type.SyncType != syncMethod.DeclaringType) { throw new ArgumentException("The given method is not defined on given type", "syncMethod"); } VerifyContract(syncMethod); SyncMethod = syncMethod; AsyncType = type; handle = ObtainNewHandle(syncMethod); }
private static AsyncTask.ReturnValue UploadAndBeginTask(string filePath, string callbackUrl, AsyncType type) { string url = string.Empty; switch (type) { case AsyncType.InviteUser: break; case AsyncType.SyncUser: url = ServiceUrl.SyncUser + "?access_token=" + AccessToken.Value; break; case AsyncType.ReplaceUser: url = ServiceUrl.ReplaceUser + "?access_token=" + AccessToken.Value; break; case AsyncType.ReplaceDept: url = ServiceUrl.ReplaceDept + "?access_token=" + AccessToken.Value; break; default: break; } if (string.IsNullOrEmpty(url)) { } //上传csv文件 var uploadRet = MediaFileManager.UploadTempFile(filePath, MediaFile.FileType.File); //请求覆盖操作 var data = new { media_id = uploadRet.MediaID, callback = new { url = callbackUrl, token = WechatConfig.Token, //Wechat.Options.Token, encodingaeskey = WechatConfig.EncodingAESKey //Wechat.Options.EncodingAESKey } }; //string result = Create().WebClient.UploadString(url, AjaxEngine.Gloabl.Serializer.Serialize(data)); //return AjaxEngine.Gloabl.Serializer.Deserialize<AsyncTask.ReturnValue>(result); return(HttpHelper.Post <AsyncTask.ReturnValue>(url, data)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MiAsyncRecord(AsyncType asyncType, uint token, string clazz, List <MiResultValue> results) : base(token, clazz, results) { Type = asyncType; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public MiAsyncRecord (AsyncType asyncType, uint token, string clazz, List<MiResultValue> results) : base (token, clazz, results) { Type = asyncType; }
public static void SetAsyncContentType(UIElement element, AsyncType value) { element.SetValue(AsyncContentTypeProperty, value); }
public WcfRemotingAsyncInterceptor(AsyncType asyncType, WcfClientExtension clients, IWcfChannelHolder channelHolder) : base(clients, channelHolder) { this.asyncType = asyncType; }
/// <summary> /// Publish this event async. Choose the behaviour via the async-type and be informed for the result via the onFinished-callback. /// These are the call-options: /// Publish_Worker_Result_Worker - Do the publish call on the worker-thread and call the callback immediately with the result inside this thread /// Publish_Worker_Result_Main - Do the publish call on the worker-thread and add the callback with the result inside to the mainthread-queue /// Publish_Main_Result_Main - Queue the publish call in the MAIN-thread queue and call the callback immediately within the MAIN-thread /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="evt"></param> /// <param name="onFinished"></param> /// <param name="asyncType"></param> protected void PublishAsync <TEvent>(TEvent evt, Action <TEvent> onFinished = null, AsyncType asyncType = AsyncType.Publish_Main_Result_Main) { _eventService.PublishAsync(evt, onFinished, asyncType); }
/// <summary> /// Get资源调度 用于获取数据较大的方法 /// xugy 2015年11月7日17:43:09 /// </summary> /// <param name="url"></param> /// <param name="content"></param> /// <returns></returns> //public static string HttpGetSchedule(string url, FormUrlEncodedContent content) //{ // using (var client = content == null ? new HttpClient() : new HttpClient(new HttpClientHandler())) // { // var bytes = client.GetAsync(url).Result.Content.ReadAsByteArrayAsync().Result; // string ss = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result; // return System.Text.Encoding.UTF8.GetString(DeflateCompressionAttribute.DecompressionByte(bytes)); // } //} /// <summary> /// 客户端方法资源调度 /// xugy 2015年7月10日 /// </summary> /// <param name="url">请求资源url</param> /// <param name="content">http上下文</param> /// <param name="type">资源调度方式</param> /// <returns>结果</returns> public static string ProcessMethodSchedule(string url, FormUrlEncodedContent content, AsyncType type) { string str = null; using (var client = content == null ? new HttpClient() : new HttpClient(new HttpClientHandler())) { switch (type) { case AsyncType.GetAsync: str = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result; break; case AsyncType.PostAsync: str = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result; break; case AsyncType.PutAsync: str = client.PutAsync(url, content).Result.Content.ReadAsStringAsync().Result; break; case AsyncType.DeleteAsync: str = client.DeleteAsync(url).Result.Content.ReadAsStringAsync().Result; break; } } return(str); }
private void GetHallState(AsyncType asyncType) { if (SelectedEvent != null) { SeatIndex[] seats; switch (asyncType) { case AsyncType.NoAsync: IHallStateService syncProxy = new ChannelFactory<IHallStateService>("HallStateEP").CreateChannel(); seats = syncProxy.GetHallState(SelectedEvent.EventID); ShowAvailableSeats(seats); break; } } else { ShowAvailableSeats(null); } }
public BeginMethod(MethodInfo syncMethod, AsyncType type) : base(syncMethod, type) { parameters = ObtainParameters(syncMethod); }
public AsyncPublishContext PublishAsync <TEvent>(TEvent evt, Action <TEvent> onFinished = null, AsyncType type = AsyncType.Publish_Main_Result_Main) { // create the context-object which can be used to check for finished if e.g. from within a coroutine var result = new AsyncPublishContext(); if (type == AsyncType.Publish_Main_Result_Main) { _asyncManager.AddToMainThread(() => { // inside coroutine Publish(evt); result.finished = true; result.result = evt; if (onFinished != null) { onFinished(evt); } }); } else // atm, at this point there are only the worker-options, so I don't need to query specially for those //if (type == AsyncType.Publish_Worker_Result_Worker || type == AsyncType.Publish_Worker_Result_Main) { _asyncManager.AddToWorkerThread(() => { // inside worker-thread Publish(evt); result.finished = true; result.result = evt; if (type == AsyncType.Publish_Worker_Result_Main) { // since we want the result send to the main-thread, we need to wrap it in an Action // and add it to the main-thread-queue _asyncManager.AddToMainThread(() => { onFinished(evt); }); } else if (type == AsyncType.Publish_Worker_Result_Worker) { // immediately send the result to the callback which will be called from within(!) the worker-thread onFinished(evt); } }, null); } // return the context-object return(result); }