public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { IAsyncResult result = null; try { if (IsInfrastructureEndpoint(instance)) { result = m_OldInvoker.InvokeBegin(instance, inputs, callback, state); } else { //Implicitly activate instance: //1. Upon every stateless actor request //2. Upon first application request after state collection if ((m_MethodInfo.Name.Contains("Deactivate") == false) && ((instance as ActorBase).Activated == false)) { (instance as ActorBase).ActivateAsync().Wait(); } //For consistency with Service Fabric, remove OperationContext for actors. using (OperationContextScope scope = new OperationContextScope(null as OperationContext)) { result = m_OldInvoker.InvokeBegin(instance, inputs, callback, state); } } } catch (Exception exception) { Debug.Assert(true, "Invoker Begin exception: " + exception.Message); throw exception; } return(result); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { string cacheKey = this.CreateCacheKey(inputs); CachedOperationResult cachedItem = CacheServiceHelper.Current.Get <CachedOperationResult>(cacheKey); CachingUserState cachingUserState = new CachingUserState { CacheItem = cachedItem, CacheKey = cacheKey, Callback = callback, State = state }; IAsyncResult originalAsyncResult; if (cachedItem != null) { InvokerDelegate invoker = cachedItem.GetValue; object[] notUsed; originalAsyncResult = invoker.BeginInvoke(inputs, out notUsed, this.InvokerCallback, cachingUserState); } else { originalAsyncResult = _invoker.InvokeBegin(instance, inputs, this.InvokerCallback, cachingUserState); } return(new CachingAsyncResult(originalAsyncResult, cachingUserState)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { var service = GetServiceBase(instance); GrabSynchronizationContext(service); InitializeService(instance, inputs); return(originalInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { if (_operationMethod != null) { EnsureAccess(instance); } return(_originalInvoker.InvokeBegin(instance, inputs, callback, state)); }
public OperationCachingInvokerAsyncResult(object instance, string action, object[] inputs, IOperationInvoker innerOperationInvoker, AsyncCallback callback, object state) : base(callback, state) { this.instance = instance; this.action = action; this.inputs = inputs; this.innerOperationInvoker = innerOperationInvoker; this.isNewResult = true; innerOperationInvoker.InvokeBegin(instance, inputs, new AsyncCallback(HandleCallback), null); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { var context = OperationContext.Current.UseAndPropagate(); return(_invoker.InvokeBegin(instance, inputs, ar => { using (context) { callback(ar); } }, state)); }
public Task <object> InvokeOperationAsync(object instance, object[] inputs, object state) { Message inputMessage = null; Message outputMessage = null; try { if (inputs != null && inputs.Length == 1) { inputMessage = inputs[0] as Message; } if (inputMessage != null) { // We need to copy the message in order to read it. // This means the original message will have the 'Read' state, which means it can no longer be read. var bufferedMessage = inputMessage.CreateBufferedCopy(Int32.MaxValue); inputs[0] = bufferedMessage.CreateMessage(); var messageToWorkOn = bufferedMessage.CreateMessage(); Stream messageStream = messageToWorkOn.GetBody <Stream>(); if (messageStream != null) { outputMessage = GetOutputMessageForInputMessageStream(messageStream); } } } catch (Exception ex) { // Swallow all the exceptions outputMessage = null; } if (outputMessage == null) { var capturedOperationContext = OperationContext.Current; return(Task <object> .Factory.StartNew(() => { OperationContext.Current = capturedOperationContext; var begin = _innerInvoker.InvokeBegin(instance, inputs, null, state); object[] o; return _innerInvoker.InvokeEnd(instance, out o, begin); })); } return(Task.FromResult((object)outputMessage)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { IAsyncResult result = null; OnPreInvoke(instance); try { if (IsInfrastructureEndpoint(instance)) { //TEST ONLY... if (CompletesActorInstance(instance)) { CallContext.LogicalSetData("Context", new AsyncContextScope()); } result = m_OldInvoker.InvokeBegin(instance, inputs, callback, state); } else { //Implicitly activate instance: //1. Upon every stateless actor request //2. Upon first application request after state collection if ((m_MethodInfo.Name.Contains("Deactivate") == false) && ((instance as ActorBase).Activated == false)) { (instance as ActorBase).ActivateAsync().Wait(); } result = m_OldInvoker.InvokeBegin(instance, inputs, callback, state); } } catch (Exception exception) { Debug.Assert(true, "Invoker Begin exception: " + exception.Message); throw exception; } return(result); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { IAsyncResult result = null; try { result = m_OldInvoker.InvokeBegin(instance, inputs, callback, state); } catch (Exception exception) { Debug.Assert(true, "Invoker exception: " + exception.Message); throw exception; } return(result); }
/// <summary> /// Asynchronous implementation of the Invoke (Begin) /// </summary> public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { IAsyncResult result = null; // Create the Wcf audit event var auditWcfEvent = CreateWcfAuditEvent(instance, inputs); // Create the audit scope var eventType = _eventType.Replace("{contract}", auditWcfEvent.ContractName) .Replace("{operation}", auditWcfEvent.OperationName); var auditEventWcf = new AuditEventWcfAction() { WcfEvent = auditWcfEvent }; // Create the audit scope var auditScope = AuditScope.Create(new AuditScopeOptions() { EventType = eventType, CreationPolicy = _creationPolicy, AuditEvent = auditEventWcf, DataProvider = GetAuditDataProvider(instance), CallingMethod = _operationDescription.SyncMethod ?? _operationDescription.TaskMethod }); // Store a reference to this audit scope var callbackState = new AuditScopeState() { AuditScope = auditScope, OriginalUserCallback = callback, OriginalUserState = state }; AuditBehavior.CurrentAuditScope = auditScope; try { result = _baseInvoker.InvokeBegin(instance, inputs, this.InvokerCallback, callbackState); } catch (Exception ex) { AuditBehavior.CurrentAuditScope = null; auditWcfEvent.Fault = GetWcfFaultData(ex); auditWcfEvent.Success = false; (auditScope.Event as AuditEventWcfAction).WcfEvent = auditWcfEvent; auditScope.Dispose(); throw; } AuditBehavior.CurrentAuditScope = null; return(new AuditScopeAsyncResult(result, callbackState)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { Stopwatch sw = Stopwatch.StartNew(); return(invoker.InvokeBegin(instance, inputs, callback, new Tuple <object[], Stopwatch>(inputs, sw))); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { IAsyncResult result = _innerOperationInvoker.InvokeBegin(instance, inputs, callback, state); return(result); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { PreInvoke(instance, inputs); return(m_InnerInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { LogBeforeInvoke(instance, _opDescr, inputs); return(defaultInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { // Not supported - an exception will be thrown return(_innerInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { _myLog.Log(string.Format("Method {0} of class {1} called", _operationName, _controllerName)); return(_baseInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { sw = Stopwatch.StartNew(); return(invoker.InvokeBegin(instance, inputs, callback, inputs)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { // Use the default invoker. Don't time async methods return(_previousInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(Object instance, Object[] inputs, AsyncCallback callback, Object state) { LogicalOperationScope.StartLogicalOperation(GetOperation(instance)); return(_originalInvoker.InvokeBegin(instance, inputs, callback, state)); }
/// <summary> /// Method which fires at the time of Request invoke action begins /// </summary> /// <param name="instance">operation context instance</param> /// <param name="inputs">input parameter array</param> /// <param name="callback">call back method</param> /// <param name="state">request state</param> /// <returns>returns result status</returns> public IAsyncResult InvokeBegin(Object instance, Object[] inputs, AsyncCallback callback, Object state) { return(InnerOperationInvoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { return(_invoker.InvokeBegin(instance, inputs, callback, state)); }
public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state) { //execute validate before invoking the previous invoker in the chain Validate(); return(_invoker.InvokeBegin(instance, inputs, callback, state)); }