Example #1
0
        public ReflectiveBinding CreateReflectiveBinding(MethodInfo factory, BindingProviderAttribute attribute)
        {
            var dependencies = new List <BindingPair>();

            if (attribute.DependencyCount > 0)
            {
                var parameters = factory.GetParameters();

                for (int i = 0; i < attribute.DependencyCount; ++i)
                {
                    var type = parameters[i].ParameterType;

                    object name = InnerBindingNames.Empty;

                    if (attribute.DependencieNames.Length > i)
                    {
                        name = attribute.DependencieNames[i];
                    }

                    var duo = new BindingPair(name, type);
                    dependencies.Add(duo);
                }
            }

            var root = new BindingPair(attribute.Name, factory.ReturnType);

            return(new ReflectiveBinding(root, factory, dependencies));
        }
Example #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(BindingPair))
            {
                return(false);
            }
            BindingPair other = (BindingPair)obj;

            return(name == other.name && BindingType == other.BindingType);
        }
Example #3
0
            public ReflectionBindingProvider(MethodInfo factory, BindingProviderAttribute attribute) : this(new BindingPair(attribute.Name, factory.ReturnType))
            {
                Dependencies = new List <IBindingProvider>();

                if (attribute.DependencyCount > 0)
                {
                    var parameters = factory.GetParameters();

                    for (int i = 0; i < attribute.DependencyCount; ++i)
                    {
                        var type = parameters[i].ParameterType;

                        object name = InnerBindingNames.Empty;

                        if (attribute.DependencieNames.Length > i)
                        {
                            name = attribute.DependencieNames[i];
                        }

                        var duo = new BindingPair(name, type);
                        Dependencies.Add(new ReflectionBindingProvider(duo));
                    }
                }
            }
Example #4
0
 public ReflectiveBinding(BindingPair root, MethodInfo factory, IList <BindingPair> dependencies)
 {
     this.Root         = root;
     this.Factory      = factory;
     this.Dependencies = dependencies;
 }
Example #5
0
 private ReflectionBindingProvider(BindingPair duo)
 {
     m_duo        = duo;
     Dependencies = new List <IBindingProvider>();
 }
		public ReflectiveBinding (BindingPair root, MethodInfo factory, IList<BindingPair> dependencies)
		{
			this.Root = root;
			this.Factory = factory;
			this.Dependencies = dependencies;
		}