Internal descriptor for an injection.
コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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));
        }