Esempio n. 1
0
        private OperationKey GetOperationKey(string value)
        {
            IObjectContainer objectContainer = ObjectContainerFactory.GetObjectContainer();

            if (!objectContainer.IsRegistered(typeof(IOperationKeyFormatter)))
            {
                objectContainer.RegisterType <IOperationKeyFormatter, OperationKeyFormatter>(new object[0]);
            }
            return(objectContainer.Resolve <IOperationKeyFormatter>().Parse(value));
        }
Esempio n. 2
0
        public object GetInstance(InstanceContext instanceContext, Message message)
        {
            IObjectContainer objectContainer = ObjectContainerFactory.GetObjectContainer();

            if (objectContainer.IsRegistered(this.ContractType, this.Name))
            {
                return(objectContainer.Resolve(this.ContractType, this.Name));
            }
            return(Activator.CreateInstance(this.ServiceType));
        }
Esempio n. 3
0
        private ILogger GetLogger()
        {
            ILogger          logger          = null;
            IObjectContainer objectContainer = ObjectContainerFactory.GetObjectContainer();

            if (objectContainer.IsRegistered(typeof(ILogger), "STOPWATCH_LOGGER"))
            {
                return(objectContainer.Resolve <ILogger>("STOPWATCH_LOGGER"));
            }
            if (objectContainer.IsRegistered(typeof(ILogger)))
            {
                logger = objectContainer.Resolve <ILogger>();
            }
            return(logger);
        }
Esempio n. 4
0
 private void TryLog(Exception ex)
 {
     try
     {
         IObjectContainer objectContainer = ObjectContainerFactory.GetObjectContainer();
         if (!objectContainer.IsRegistered(typeof(ILogger)))
         {
             objectContainer.RegisterType <ILogger, WcfLogger>(new object[0]);
         }
         objectContainer.Resolve <ILogger>().Error(ex, null);
     }
     catch (Exception exception)
     {
         Debug.WriteLine("WCF log exception error:");
         Debug.WriteLine(exception.Message);
     }
 }
Esempio n. 5
0
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            string           name            = serviceHostBase.Description.Name;
            Type             serviceType     = serviceHostBase.Description.ServiceType;
            IObjectContainer objectContainer = ObjectContainerFactory.GetObjectContainer();

            foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
            {
                foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints)
                {
                    foreach (ServiceEndpoint endpoint in serviceHostBase.Description.Endpoints)
                    {
                        Type contractType = endpoint.Contract.ContractType;
                        if (((endpoint.Contract.Name == dispatcher2.ContractName) && (endpoint.Contract.Namespace == dispatcher2.ContractNamespace)) && (endpoint.Contract.ContractType != null))
                        {
                            if (serviceType.GetInterfaces().Any <Type>(t => (t == contractType)) && !objectContainer.IsRegistered(contractType))
                            {
                                objectContainer.RegisterType(contractType, serviceType, name, new object[0]);
                            }
                            dispatcher2.DispatchRuntime.InstanceProvider = new EGInstanceProvider(contractType, serviceType, name);
                            lock (this)
                            {
                                foreach (OperationDescription description in endpoint.Contract.Operations)
                                {
                                    if ((description.Behaviors != null) && ((from t in description.Behaviors
                                                                             where t.GetType() == typeof(EGOperationBehavior)
                                                                             select t).Count <IOperationBehavior>() <= 0))
                                    {
                                        IOperationBehavior item = new EGOperationBehavior();
                                        description.Behaviors.Add(item);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 public UserAccessManager GetUserAccessManager()
 {
     return(ObjectContainerFactory.GetObjectContainer().Resolve <UserAccessManager>());
 }
Esempio n. 7
0
 public DbObjectOperator GetDbObjectOperator(string connectionName)
 {
     return(ObjectContainerFactory.GetObjectContainer().Resolve <DbObjectOperator>(connectionName));
 }
Esempio n. 8
0
 public DbObjectOperator GetDbObjectOperator()
 {
     return(ObjectContainerFactory.GetObjectContainer().Resolve <DbObjectOperator>());
 }
Esempio n. 9
0
            public object Invoke(object instance, object[] inputs, out object[] outputs)
            {
                object result = null;
                List <OperationAttribute> operationAttributes = null;
                int    num;
                object obj3;

                try
                {
                    OperationAttribute current;
                    operationAttributes = this.GetOperationAttributes();
                    using (List <OperationAttribute> .Enumerator enumerator = operationAttributes.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            current = enumerator.Current;
                            current.BeforeInvoke(instance, inputs);
                        }
                    }
                    result = this.invoker.Invoke(instance, inputs, out outputs);
                    if (operationAttributes.Count > 0)
                    {
                        for (num = operationAttributes.Count - 1; num >= 0; num--)
                        {
                            current = operationAttributes[num];
                            current.AfterInvoke(instance, inputs, result);
                        }
                    }
                    obj3 = result;
                }
                catch (Exception exception)
                {
                    this.TryLog(exception);
                    try
                    {
                        if ((operationAttributes != null) && (operationAttributes.Count > 0))
                        {
                            for (num = operationAttributes.Count - 1; num >= 0; num--)
                            {
                                operationAttributes[num].OnInvokeError(instance, inputs, result);
                            }
                        }
                    }
                    catch
                    {
                    }
                    IObjectContainer    objectContainer = ObjectContainerFactory.GetObjectContainer();
                    IExceptionFormatter formatter       = null;
                    if (objectContainer.IsRegistered(typeof(IExceptionFormatter)))
                    {
                        formatter = objectContainer.Resolve <IExceptionFormatter>();
                    }
                    if (formatter == null)
                    {
                        formatter = new ExceptionFormatter();
                        objectContainer.RegisterInstance <IExceptionFormatter>(formatter);
                    }
                    throw formatter.Format(exception);
                }
                finally
                {
                    try
                    {
                        WcfContext.Current.FindAll <DbObjectOperator>().ForEach(delegate(DbObjectOperator op)
                        {
                            try
                            {
                                op.DbOperator.Close();
                            }
                            catch
                            {
                            }
                        });
                    }
                    catch
                    {
                    }
                }
                return(obj3);
            }