Ejemplo n.º 1
0
 internal static bool AllowedOrRequired(ImpersonationOption option)
 {
     if (option != ImpersonationOption.Allowed)
     {
         return(option == ImpersonationOption.Required);
     }
     return(true);
 }
Ejemplo n.º 2
0
 public static bool IsDefined(ImpersonationOption option)
 {
     if ((option != ImpersonationOption.NotAllowed) && (option != ImpersonationOption.Allowed))
     {
         return(option == ImpersonationOption.Required);
     }
     return(true);
 }
Ejemplo n.º 3
0
 public DispatchOperation(DispatchRuntime parent, string name, string action)
 {
     Parent             = parent ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent));
     this.name          = name ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
     this.action        = action;
     this.impersonation = OperationBehaviorAttribute.DefaultImpersonationOption;
     // Not necessary for basic functionality
     CallContextInitializers = parent.NewBehaviorCollection <ICallContextInitializer>();
     faultContractInfos      = parent.NewBehaviorCollection <FaultContractInfo>();
     ParameterInspectors     = parent.NewBehaviorCollection <IParameterInspector>();
     IsOneWay = true;
 }
        public DispatchOperation(DispatchRuntime parent, string name, string action)
        {
            if (parent == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            if (name == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");

            this.parent = parent;
            this.name = name;
            this.action = action;
            this.impersonation = OperationBehaviorAttribute.DefaultImpersonationOption;

            this.callContextInitializers = parent.NewBehaviorCollection<ICallContextInitializer>();
            this.faultContractInfos = parent.NewBehaviorCollection<FaultContractInfo>();
            this.parameterInspectors = parent.NewBehaviorCollection<IParameterInspector>();
            this.isOneWay = true;
        }
        public DispatchOperation(DispatchRuntime parent, string name, string action)
        {
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }
            if (name == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
            }

            this.parent        = parent;
            this.name          = name;
            this.action        = action;
            this.impersonation = OperationBehaviorAttribute.DefaultImpersonationOption;

            this.callContextInitializers = parent.NewBehaviorCollection <ICallContextInitializer>();
            this.faultContractInfos      = parent.NewBehaviorCollection <FaultContractInfo>();
            this.parameterInspectors     = parent.NewBehaviorCollection <IParameterInspector>();
            this.isOneWay = true;
        }
Ejemplo n.º 6
0
 public DispatchOperation(DispatchRuntime parent, string name, string action)
 {
     this.deserializeRequest    = true;
     this.serializeReply        = true;
     this.autoDisposeParameters = true;
     if (parent == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
     }
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     this.parent                  = parent;
     this.name                    = name;
     this.action                  = action;
     this.impersonation           = ImpersonationOption.NotAllowed;
     this.callContextInitializers = parent.NewBehaviorCollection <ICallContextInitializer>();
     this.faultContractInfos      = parent.NewBehaviorCollection <FaultContractInfo>();
     this.parameterInspectors     = parent.NewBehaviorCollection <IParameterInspector>();
     this.isOneWay                = true;
 }
 public DispatchOperation(DispatchRuntime parent, string name, string action)
 {
     this.deserializeRequest = true;
     this.serializeReply = true;
     this.autoDisposeParameters = true;
     if (parent == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
     }
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     this.parent = parent;
     this.name = name;
     this.action = action;
     this.impersonation = ImpersonationOption.NotAllowed;
     this.callContextInitializers = parent.NewBehaviorCollection<ICallContextInitializer>();
     this.faultContractInfos = parent.NewBehaviorCollection<FaultContractInfo>();
     this.parameterInspectors = parent.NewBehaviorCollection<IParameterInspector>();
     this.isOneWay = true;
 }
Ejemplo n.º 8
0
 internal static bool AllowedOrRequired(ImpersonationOption option)
 {
     return (option == ImpersonationOption.Allowed ||
             option == ImpersonationOption.Required);
 }
Ejemplo n.º 9
0
 public static bool IsDefined(ImpersonationOption option)
 {
     return (option == ImpersonationOption.NotAllowed ||
             option == ImpersonationOption.Allowed ||
             option == ImpersonationOption.Required);
 }
Ejemplo n.º 10
0
 public static bool IsDefined(ImpersonationOption option)
 {
     return(option == ImpersonationOption.NotAllowed ||
            option == ImpersonationOption.Allowed ||
            option == ImpersonationOption.Required);
 }
        internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }
            if (operation.Invoker == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.RuntimeRequiresInvoker0)));
            }

            this.disposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters));
            this.parent = parent;
            this.callContextInitializers = EmptyArray<ICallContextInitializer>.ToArray(operation.CallContextInitializers);
            this.inspectors = EmptyArray<IParameterInspector>.ToArray(operation.ParameterInspectors);
            this.faultFormatter = operation.FaultFormatter;
            this.impersonation = operation.Impersonation;
            this.deserializeRequest = operation.DeserializeRequest;
            this.serializeReply = operation.SerializeReply;
            this.formatter = operation.Formatter;
            this.invoker = operation.Invoker;

            try
            {
                this.isSynchronous = operation.Invoker.IsSynchronous;
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }
            this.isTerminating = operation.IsTerminating;
            this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            this.action = operation.Action;
            this.name = operation.Name;
            this.releaseInstanceAfterCall = operation.ReleaseInstanceAfterCall;
            this.releaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall;
            this.replyAction = operation.ReplyAction;
            this.isOneWay = operation.IsOneWay;
            this.transactionAutoComplete = operation.TransactionAutoComplete;
            this.transactionRequired = operation.TransactionRequired;
            this.receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode;
            this.bufferedReceiveEnabled = operation.BufferedReceiveEnabled;
            this.isInsideTransactedReceiveScope = operation.IsInsideTransactedReceiveScope;

            if (this.formatter == null && (deserializeRequest || serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.DispatchRuntimeRequiresFormatter0, this.name)));
            }

            if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null))
            {
                SyncMethodInvoker sync = this.invoker as SyncMethodInvoker;
                if (sync != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, sync.Method);
                }

                AsyncMethodInvoker async = this.invoker as AsyncMethodInvoker;
                if (async != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, async.BeginMethod);
                    this.ValidateInstanceType(operation.Parent.Type, async.EndMethod);
                }

                TaskMethodInvoker task = this.invoker as TaskMethodInvoker;
                if (task != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, task.TaskMethod);
                }
            }
        }
        //readonly bool isInsideTransactedReceiveScope;

        internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(operation));
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent));
            }
            if (operation.Invoker == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.RuntimeRequiresInvoker0));
            }

            disposeParameters       = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters));
            this.parent             = parent;
            callContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers);

            inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors);

            faultFormatter     = operation.FaultFormatter;
            impersonation      = operation.Impersonation;
            deserializeRequest = operation.DeserializeRequest;
            serializeReply     = operation.SerializeReply;
            formatter          = operation.Formatter;
            invoker            = operation.Invoker;

            try
            {
                isSynchronous = operation.Invoker.IsSynchronous;
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }
            isTerminating = operation.IsTerminating;
            isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            action = operation.Action;
            name   = operation.Name;
            releaseInstanceAfterCall  = operation.ReleaseInstanceAfterCall;
            releaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall;
            replyAction = operation.ReplyAction;
            isOneWay    = operation.IsOneWay;
            receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode;
            bufferedReceiveEnabled            = operation.BufferedReceiveEnabled;

            if (formatter == null && (deserializeRequest || serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DispatchRuntimeRequiresFormatter0, name)));
            }

            if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null))
            {
                SyncMethodInvoker sync = invoker as SyncMethodInvoker;
                if (sync != null)
                {
                    ValidateInstanceType(operation.Parent.Type, sync.Method);
                }

                //AsyncMethodInvoker async = this.invoker as AsyncMethodInvoker;
                //if (async != null)
                //{
                //    this.ValidateInstanceType(operation.Parent.Type, async.BeginMethod);
                //    this.ValidateInstanceType(operation.Parent.Type, async.EndMethod);
                //}

                TaskMethodInvoker task = invoker as TaskMethodInvoker;
                if (task != null)
                {
                    ValidateInstanceType(operation.Parent.Type, task.TaskMethod);
                }
            }
        }
Ejemplo n.º 13
0
 internal static bool AllowedOrRequired(ImpersonationOption option)
 {
     return(option == ImpersonationOption.Allowed ||
            option == ImpersonationOption.Required);
 }
Ejemplo n.º 14
0
        internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }
            if (operation.Invoker == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("RuntimeRequiresInvoker0")));
            }
            this.disposeParameters       = operation.AutoDisposeParameters && !operation.HasNoDisposableParameters;
            this.parent                  = parent;
            this.callContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers);

            this.inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors);

            this.faultFormatter     = operation.FaultFormatter;
            this.impersonation      = operation.Impersonation;
            this.deserializeRequest = operation.DeserializeRequest;
            this.serializeReply     = operation.SerializeReply;
            this.formatter          = operation.Formatter;
            this.invoker            = operation.Invoker;
            try
            {
                this.isSynchronous = operation.Invoker.IsSynchronous;
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception);
            }
            this.isTerminating                     = operation.IsTerminating;
            this.action                            = operation.Action;
            this.name                              = operation.Name;
            this.releaseInstanceAfterCall          = operation.ReleaseInstanceAfterCall;
            this.releaseInstanceBeforeCall         = operation.ReleaseInstanceBeforeCall;
            this.replyAction                       = operation.ReplyAction;
            this.isOneWay                          = operation.IsOneWay;
            this.transactionAutoComplete           = operation.TransactionAutoComplete;
            this.transactionRequired               = operation.TransactionRequired;
            this.receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode;
            this.bufferedReceiveEnabled            = operation.BufferedReceiveEnabled;
            this.isInsideTransactedReceiveScope    = operation.IsInsideTransactedReceiveScope;
            if ((this.formatter == null) && (this.deserializeRequest || this.serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("DispatchRuntimeRequiresFormatter0", new object[] { this.name })));
            }
            if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null))
            {
                SyncMethodInvoker invoker = this.invoker as SyncMethodInvoker;
                if (invoker != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, invoker.Method);
                }
                AsyncMethodInvoker invoker2 = this.invoker as AsyncMethodInvoker;
                if (invoker2 != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, invoker2.BeginMethod);
                    this.ValidateInstanceType(operation.Parent.Type, invoker2.EndMethod);
                }
            }
        }