コード例 #1
0
        public void CreatePropertyAssignment(PropertyAssignment propertyAssignment)
        {
            if (this._disposed == true)
            {
                return;
            }

            if (this.PropertyAssignments.Contains(propertyAssignment) == false)
            {
                this.PropertyAssignments.Add(propertyAssignment);
            }
        }
コード例 #2
0
        public IRegistration WithPropertyValue(Type component, string propertyName, object value)
        {
            var node = (from match in this._kernel.Nodes
                        where match.Component == component
                        select match).FirstOrDefault();

            if (node == null)
            {
                return(this);
            }

            if (string.IsNullOrEmpty(propertyName) == false)
            {
                var propertyType = component.GetProperty(propertyName).PropertyType;
                var assignment   = new PropertyAssignment(component, propertyType, propertyName, value);
                node.CreatePropertyAssignment(assignment);
            }

            return(this);
        }
コード例 #3
0
        public IRegistration WithPropertyValue <TComponent>(Expression <Func <TComponent, object> > property, object value)
        {
            var node = (from match in this._kernel.Nodes
                        where match.Component == typeof(TComponent) ||
                        match.Contract == typeof(TComponent)
                        select match).FirstOrDefault();

            if (node == null)
            {
                return(this);
            }

            var propertyName = GetPropertyName <TComponent>(property);
            var propertyType = typeof(TComponent).GetProperty(propertyName).PropertyType;
            var assignment   = new PropertyAssignment(typeof(TComponent), propertyType, propertyName, value);

            node.CreatePropertyAssignment(assignment);

            return(this);
        }