/// <summary> /// Resolves an injection to a Component. /// </summary> /// <param name="context"></param> /// <param name="componentDescriptor"></param> /// <param name="injectDescriptor"></param> /// <returns></returns> public object ResolveInject(Context context, ComponentDescriptor componentDescriptor, InjectDescriptor injectDescriptor) { ComponentDescriptor injectComponent = null; if (injectDescriptor.Attributes.Name != null) { context.descriptorNameCache.TryGetValue(injectDescriptor.Attributes.Name, out injectComponent); } if (injectDescriptor.Attributes.Type != null) { if (injectComponent == null) { context.descriptorTypeCache.TryGetValue(injectDescriptor.Attributes.Type.AssemblyQualifiedName, out injectComponent); } else { if (injectComponent.Type != injectDescriptor.Attributes.Type) { injectComponent = null; } } } else { context.descriptorTypeCache.TryGetValue(injectDescriptor.Type.AssemblyQualifiedName, out injectComponent); } return injectComponent == null ? null : context.GetInstance(injectComponent); }
/// <summary> /// Resolves Context injections. /// </summary> /// <param name="context"></param> /// <param name="componentDescriptor"></param> /// <param name="injectDescriptor"></param> /// <returns></returns> public object ResolveInject(Context context, ComponentDescriptor componentDescriptor, InjectDescriptor injectDescriptor) { if (injectDescriptor.Type.Equals(context.GetType().AssemblyQualifiedName)) { return context; } return null; }
/// <summary> /// Resolves Context injections. /// </summary> /// <param name="context"></param> /// <param name="componentDescriptor"></param> /// <param name="injectDescriptor"></param> /// <returns></returns> public object ResolveInject(Context context, ComponentDescriptor componentDescriptor, InjectDescriptor injectDescriptor) { if (injectDescriptor.Type.Equals(context.GetType().AssemblyQualifiedName)) { return(context); } return(null); }
/// <summary> /// Resolves an injection to a Component. /// </summary> /// <param name="context"></param> /// <param name="componentDescriptor"></param> /// <param name="injectDescriptor"></param> /// <returns></returns> public object ResolveInject(Context context, ComponentDescriptor componentDescriptor, InjectDescriptor injectDescriptor) { ComponentDescriptor injectComponent = null; if (injectDescriptor.Attributes.Name != null) { context.descriptorNameCache.TryGetValue(injectDescriptor.Attributes.Name, out injectComponent); } if (injectDescriptor.Attributes.Type != null) { if (injectComponent == null) { context.descriptorTypeCache.TryGetValue(injectDescriptor.Attributes.Type.AssemblyQualifiedName, out injectComponent); } else { if (injectComponent.Type != injectDescriptor.Attributes.Type) { injectComponent = null; } } } else { context.descriptorTypeCache.TryGetValue(injectDescriptor.Type.AssemblyQualifiedName, out injectComponent); } return(injectComponent == null ? null : context.GetInstance(injectComponent)); }