示例#1
0
        public IComponentInfo CreateInfo(XAccessor x)
        {
            string id = x.GetStringValue(ID_ATTR);
            bool? lcManage = x.GetValue<bool>(LIFECYCLE_MANAGEMENT_ATTR);
            Type serviceType = null;
            string xServiceType = x.GetStringValue(SERVICE_TYPE);
            if (!string.IsNullOrEmpty(xServiceType))
            {
                serviceType = Reflector.LoadType(xServiceType);
            }
            Type componentType = null;
            string xComponentType = x.GetStringValue(COMPONENT_TYPE);
            if (!string.IsNullOrEmpty(xComponentType))
            {
                componentType = Reflector.LoadType(xComponentType);
            }

            List<IPolicy> policies = new List<IPolicy>();
            XAccessor xPolicies = x.NavigateToSingleOrNull(POLICY);
            if (xPolicies != null)
            {
                foreach (var xPolicy in xPolicies.Children)
                {
                    if (xPolicy.IsComment)
                        continue;
                    IPolicy policy = CreatePolicy(xPolicy);
                    policies.Add(policy);
                }
            }

            IComponentInfo info = new ComponentInfo(id, serviceType, componentType, policies, lcManage ?? false);
            return info;
        }
示例#2
0
        public IComponentInfo CreateInfo(XAccessor x)
        {
            string id           = x.GetStringValue(ID_ATTR);
            bool?  lcManage     = x.GetValue <bool>(LIFECYCLE_MANAGEMENT_ATTR);
            Type   serviceType  = null;
            string xServiceType = x.GetStringValue(SERVICE_TYPE);

            if (!string.IsNullOrEmpty(xServiceType))
            {
                serviceType = Reflector.LoadType(xServiceType);
            }
            Type   componentType  = null;
            string xComponentType = x.GetStringValue(COMPONENT_TYPE);

            if (!string.IsNullOrEmpty(xComponentType))
            {
                componentType = Reflector.LoadType(xComponentType);
            }

            List <IPolicy> policies  = new List <IPolicy>();
            XAccessor      xPolicies = x.NavigateToSingleOrNull(POLICY);

            if (xPolicies != null)
            {
                foreach (var xPolicy in xPolicies.Children)
                {
                    if (xPolicy.IsComment)
                    {
                        continue;
                    }
                    IPolicy policy = CreatePolicy(xPolicy);
                    policies.Add(policy);
                }
            }

            IComponentInfo info = new ComponentInfo(id, serviceType, componentType, policies, lcManage ?? false);

            return(info);
        }
示例#3
0
文件: Kernal.cs 项目: rexzh/RexToy
        public void Register(string id, IList <IPolicy> policies = null, bool lifecycleManagement = false)
        {
            ComponentInfo info = new ComponentInfo(id, null, null, policies, lifecycleManagement);

            _store.AddComponentInfo(info);
        }
示例#4
0
文件: Kernal.cs 项目: rexzh/RexToy
        public void Register <TService, TComponent>(string id, IList <IPolicy> policies = null, bool lifecycleManagement = false)
        {
            ComponentInfo info = new ComponentInfo(id, typeof(TService), typeof(TComponent), policies, lifecycleManagement);

            _store.AddComponentInfo(info);
        }