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; }
public override void Initialize(XAccessor x) { _teardown = x.GetValue<bool>(TEARDOWN_ATTR) ?? false; var xParams = x.NavigateToList(PARAM); foreach (var xParam in xParams) { string name = xParam.GetStringValue(NAME_ATTR); string val = xParam.GetStringValue(VALUE_ATTR); if (string.IsNullOrEmpty(name)) ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), NAME_ATTR); _injectionHints.Add(name, val); } string strFactoryType = x.GetStringValue(CLASS); if (string.IsNullOrEmpty(strFactoryType)) ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), CLASS); _factoryType = Reflector.LoadType(strFactoryType); _methodName = x.GetStringValue(METHOD); if (string.IsNullOrEmpty(_methodName)) ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), METHOD); }