コード例 #1
0
        /// <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));
        }
コード例 #2
0
 internal AuditScopeAsyncResult(IAsyncResult originalResult, AuditScopeState auditScopeState)
 {
     _originalResult  = originalResult;
     _auditScopeState = auditScopeState;
 }