Exemplo n.º 1
0
        internal ProcessInfoData(ServiceHostBase Host)
        {
            if (Host == null)
            {
                lastError = "FATALERROR: Host cannot be null (ProcessInfo)";
                return;
            }
            try
            {
                serviceName  = Host.Description.Name;
                maxCalls     = 0;
                maxInstances = 0;
                calls        = 0;
                sessions     = 0;

                maxCalls     = Host.GetMaxCalls();
                MaxSessions  = Host.GetMaxSessions();
                MaxInstances = Host.GetMaxInstances();

                sessions               = Host.GetCurrentSessions();
                calls                  = Host.GetCurrentCalls();
                servicehostType        = Host.GetServiceType().ToString();
                serviceConcurrencyMode = Host.GetConcurrencyMode();
                instanceContextMode    = Host.GetInstanceContextMode();
                serviceBehaviors       = Host.GetServiceBehaviors();
            }
            catch (Exception ex)
            {
                lastError = ex.Message;
            }
        }
Exemplo n.º 2
0
 public WcfServiceBehavior(string strPerformanceCounters, ConcurrencyMode enuConcurrencyMode, InstanceContextMode enuInstanceContextMode)
     : base()
 {
     PerformanceCounters = strPerformanceCounters;
     ConcurrencyMode     = enuConcurrencyMode;
     InstanceContextMode = enuInstanceContextMode;
 }
        void ValidateAutoCompleteFalseRequirements(ServiceDescription service, ServiceEndpoint endpoint)
        {
            OperationDescription autoCompleteFalseOperation = GetAutoCompleteFalseOperation(endpoint);

            if (autoCompleteFalseOperation != null)
            {
                // Does the service have InstanceContextMode.PerSession or Shareable?
                ServiceBehaviorAttribute serviceBehavior = service.Behaviors.Find <ServiceBehaviorAttribute>();
                if (serviceBehavior != null)
                {
                    InstanceContextMode instanceMode = serviceBehavior.InstanceContextMode;
                    if (instanceMode != InstanceContextMode.PerSession)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                      SR.GetString(SR.SFxTransactionAutoCompleteFalseAndInstanceContextMode,
                                                                                                   endpoint.Contract.Name, autoCompleteFalseOperation.Name)));
                    }
                }

                // Does the binding support sessions?
                if (!autoCompleteFalseOperation.IsInsideTransactedReceiveScope)
                {
                    if (!RequiresSessions(endpoint))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                      SR.GetString(SR.SFxTransactionAutoCompleteFalseAndSupportsSession,
                                                                                                   endpoint.Contract.Name, autoCompleteFalseOperation.Name)));
                    }
                }
            }
        }
Exemplo n.º 4
0
 static public bool IsDefined(InstanceContextMode x)
 {
     return
         (x == InstanceContextMode.PerCall ||
          x == InstanceContextMode.PerSession ||
          x == InstanceContextMode.Single);
 }
Exemplo n.º 5
0
 public WCFService(
     ConcurrencyMode concurrencyMode,
     InstanceContextMode instanceContextMode)
 {
     this.concurrencyMode     = concurrencyMode;
     this.instanceContextMode = instanceContextMode;
 }
Exemplo n.º 6
0
        public override void ReadData(SerializedObject objSerializedObject)
        {
            base.ReadData(objSerializedObject);

            PerformanceCounters = objSerializedObject.Values.GetValue <string>("PerformanceCounters", DefaultPerformanceCounters);
            ConcurrencyMode     = objSerializedObject.Values.GetValue <ConcurrencyMode>("ConcurrencyMode", DefaultConcurrencyMode);
            InstanceContextMode = objSerializedObject.Values.GetValue <InstanceContextMode>("InstanceContextMode", DefaultInstanceContextMode);
        }
 public static bool IsDefined(InstanceContextMode x)
 {
     if ((x != InstanceContextMode.PerCall) && (x != InstanceContextMode.PerSession))
     {
         return(x == InstanceContextMode.Single);
     }
     return(true);
 }
Exemplo n.º 8
0
        public override void ReadData(BinaryReaderExtension objBinaryReader)
        {
            base.ReadData(objBinaryReader);

            PerformanceCounters = objBinaryReader.ReadString();
            ConcurrencyMode     = objBinaryReader.ReadEnum <ConcurrencyMode>();
            InstanceContextMode = objBinaryReader.ReadEnum <InstanceContextMode>();
        }
 public static bool IsDefined(InstanceContextMode x)
 {
     if ((x != InstanceContextMode.PerCall) && (x != InstanceContextMode.PerSession))
     {
         return (x == InstanceContextMode.Single);
     }
     return true;
 }
 static public bool IsDefined(InstanceContextMode x)
 {
     return
         x == InstanceContextMode.PerCall ||
         x == InstanceContextMode.PerSession ||
         x == InstanceContextMode.Single ||
         false;
 }
Exemplo n.º 11
0
        public static void AddInstanceContextMode(this ServiceHostBase host, InstanceContextMode mode)
        {
            ServiceHostData data = GetServiceHostData(host);

            if (data != null)
            {
                data.ServiceInstanceContextMode = mode;
            }
        }
 public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, TransferMode transferMode,
                                      InstanceContextMode instanceContextMode, ConcurrencyMode concurencyMode, params string[] bindingConfiguration)
 {
     InstanceContextMode   = instanceContextMode;
     ConcurrencyMode       = concurencyMode;
     CustomErrorHandler    = customErrorHandler;
     TransferMode          = transferMode;
     BehaviorConfiguration = behaviorConfiguration;
     BindingConfiguration  = bindingConfiguration;
 }
Exemplo n.º 13
0
 internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
 {
     switch (instanceMode)
     {
         case InstanceContextMode.PerSession:
             return new PerSessionInstanceContextProvider(runtime);
         default:
             throw new PlatformNotSupportedException();
     }
 }
 public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, TransferMode transferMode, 
     InstanceContextMode instanceContextMode, ConcurrencyMode concurencyMode, params string[] bindingConfiguration)
 {
     InstanceContextMode = instanceContextMode;
     ConcurrencyMode = concurencyMode;
     CustomErrorHandler = customErrorHandler;
     TransferMode = transferMode;
     BehaviorConfiguration = behaviorConfiguration;
     BindingConfiguration = bindingConfiguration;
 }
        internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
        {
            switch (instanceMode)
            {
            case InstanceContextMode.PerSession:
                return(new PerSessionInstanceContextProvider(runtime));

            default:
                throw new PlatformNotSupportedException();
            }
        }
Exemplo n.º 16
0
        private static void ConfigureInstanceContextMode(ServiceHost host, InstanceContextMode mode)
        {
            ServiceBehaviorAttribute serviceBehaviorAttribute = host.Description.Behaviors.Find <ServiceBehaviorAttribute>();

            if (serviceBehaviorAttribute == null)
            {
                serviceBehaviorAttribute = new ServiceBehaviorAttribute();
                host.Description.Behaviors.Add(serviceBehaviorAttribute);
            }

            serviceBehaviorAttribute.InstanceContextMode = mode;
        }
Exemplo n.º 17
0
        private void ValidateTransactionAutoCompleteOnSessionCloseHasSession(System.ServiceModel.Description.ServiceDescription service)
        {
            ServiceBehaviorAttribute attribute = service.Behaviors.Find <ServiceBehaviorAttribute>();

            if (attribute != null)
            {
                InstanceContextMode instanceContextMode = attribute.InstanceContextMode;
                if (attribute.TransactionAutoCompleteOnSessionClose && (instanceContextMode != InstanceContextMode.PerSession))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionAutoCompleteOnSessionCloseNoSession", new object[] { service.Name })));
                }
            }
        }
        void ValidateTransactionAutoCompleteOnSessionCloseHasSession(ServiceDescription service)
        {
            ServiceBehaviorAttribute serviceBehavior = service.Behaviors.Find <ServiceBehaviorAttribute>();

            if (serviceBehavior != null)
            {
                InstanceContextMode instanceMode = serviceBehavior.InstanceContextMode;
                if (serviceBehavior.TransactionAutoCompleteOnSessionClose &&
                    instanceMode != InstanceContextMode.PerSession)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.GetString(SR.SFxTransactionAutoCompleteOnSessionCloseNoSession, service.Name)));
                }
            }
        }
 internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
 {
     switch (instanceMode)
     {
         case InstanceContextMode.PerCall:
             return new PerCallInstanceContextProvider(runtime);
         case InstanceContextMode.PerSession:
             return new PerSessionInstanceContextProvider(runtime);
         case InstanceContextMode.Single:
             return new SingletonInstanceContextProvider(runtime);
         default:
             DiagnosticUtility.FailFast("InstanceContextProviderBase.GetProviderForMode: default");
             return null;
     }
 }
        internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, System.ServiceModel.Dispatcher.DispatchRuntime runtime)
        {
            switch (instanceMode)
            {
            case InstanceContextMode.PerSession:
                return(new PerSessionInstanceContextProvider(runtime));

            case InstanceContextMode.PerCall:
                return(new PerCallInstanceContextProvider(runtime));

            case InstanceContextMode.Single:
                return(new SingletonInstanceContextProvider(runtime));
            }
            DiagnosticUtility.FailFast("InstanceContextProviderBase.GetProviderForMode: default");
            return(null);
        }
Exemplo n.º 21
0
        private ServiceHost CreateService(UserSettings settings, InstanceContextMode contextMode)
        {
            switch (contextMode)
            {
            case InstanceContextMode.PerSession:
                return(CreateServiceHost <IMyService, PerSessionMyService>(settings));

            case InstanceContextMode.PerCall:
                return(CreateServiceHost <IMyService, PerCallMyService>(settings));

            case InstanceContextMode.Single:
                return(CreateServiceHost <IMyService, SingleMyService>(settings));

            default:
                throw new ArgumentOutOfRangeException(nameof(contextMode), contextMode, null);
            }
        }
Exemplo n.º 22
0
        static InstanceContext()
        {
            var type = typeof(T);

            InstanceContextMode = InstanceContextMode.PerCall;

            var serviceBehavior = type.GetTypeInfo().GetCustomAttribute <ServiceBehaviorAttribute>(false);

            if (serviceBehavior != null)
            {
                InstanceContextMode = serviceBehavior.InstanceContextMode;
            }

            GetOperations(type);

            if (OperationDispatchers.Count == 0)
            {
                throw new Exception("No OperationContract found");
            }
        }
Exemplo n.º 23
0
 public static IHost InstanceContextMode(this IHost me, InstanceContextMode mode)
 {
     (me as _Host).ServiceHost.Description.Behaviors.Find <ServiceBehaviorAttribute>().InstanceContextMode = mode;
     return(me);
 }
Exemplo n.º 24
0
        private static void ConfigureInstanceContextMode(ServiceHost host, InstanceContextMode mode)
        {
            ServiceBehaviorAttribute serviceBehaviorAttribute = host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
            if (serviceBehaviorAttribute == null)
            {
                serviceBehaviorAttribute = new ServiceBehaviorAttribute();
                host.Description.Behaviors.Add(serviceBehaviorAttribute);
            }

            serviceBehaviorAttribute.InstanceContextMode = mode;
        }
Exemplo n.º 25
0
 public ServiceServer(Uri uri, Binding binding, TServiceImpl singletonInstance = null, InstanceContextMode contextMode = InstanceContextMode.PerSession)
 {
     ServiceUri     = uri;
     Binding        = binding;
     Started        = false;
     _threadLock    = new object();
     _singletonImpl = singletonInstance;
     ContextMode    = _singletonImpl != null ? InstanceContextMode.Single : contextMode;
 }
Exemplo n.º 26
0
 public ServiceServer(Uri uri, InstanceContextMode contextMode = InstanceContextMode.PerSession)
     : this(uri, BindingFactory.CreateStandardBinding(), contextMode : contextMode)
 {
 }
 public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, InstanceContextMode instanceContextMode, params string[] bindingConfiguration)
     : this(behaviorConfiguration, customErrorHandler, TransferMode.Buffered, instanceContextMode, ConcurrencyMode.Single, bindingConfiguration)
 {
 }
 public ServiceConfigurationAttribute(string behaviorConfiguration, bool customErrorHandler, InstanceContextMode instanceContextMode, params string[] bindingConfiguration) :
     this(behaviorConfiguration, customErrorHandler, TransferMode.Buffered, instanceContextMode, ConcurrencyMode.Single, bindingConfiguration)
 {
 }
Exemplo n.º 29
0
 public ServiceBehaviorAttribute()
 {
     this.InstanceContextMode = InstanceContextMode.PerSession;
 }