Example #1
0
        public void AddPropertySetter(string key, Expression <Action <TEntity, object> > expression)
        {
            var convertedExpression = ExpressionUtils.ConvertToObjectTypeExpression(expression);

            PropertySettersExpressions.Add(key, convertedExpression);
            PropertySetters.Add(key, convertedExpression.Compile());
        }
Example #2
0
        public string RenderAssignments()
        {
            var result = "";

            if (ConstructorSetters.Any())
            {
                result = ConstructorSetters
                         .Select(constructorSetter => $"{constructorSetter.Key}: {constructorSetter.Value}")
                         .Aggregate((e, f) => $"{e}, {f}");
            }

            if (PropertySetters.Any())
            {
                var optionals = ConstructorSetters
                                .Select(constructorSetter => $"{constructorSetter.Key} = {constructorSetter.Value}");
                if (result != null)
                {
                    result = optionals.Aggregate(result, (e, f) => $"{e},{f}");
                }
                else
                {
                    result = optionals.Aggregate((e, f) => $"{e},{f}");
                }
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// Adds property for injection
        /// </summary>
        /// <param name="propertyName">Service property name for injection</param>
        /// <param name="value">value that will be injected</param>
        public void AddPropertyValue(string propertyName, object value)
        {
            // property can be added only to one Dictionary, so we must remove from other dictionary, if it contains the property
            if (PropertySetters.ContainsKey(propertyName))
            {
                PropertySetters.Remove(propertyName);
            }

            PropertyValues[propertyName] = value;       // here we just update the value
        }
Example #4
0
        public void SetPropertyStrategy(PropertySetters strategy)
        {
            switch (strategy)
            {
            case PropertySetters.Public:
                propertyStrategy = Extensions.PropertiesWithPublicSetter;
                break;

            case PropertySetters.Accessible:
                propertyStrategy = Extensions.PropertiesWithAccessibleSetter;
                break;
            }
        }
Example #5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Action"/> class.
		/// </summary>
		/// Element created at 08/11/2014,4:03 PM by Charles
		public Action()
		{
			Setters= new PropertySetters();
		}
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Action"/> class.
 /// </summary>
 /// Element created at 08/11/2014,4:03 PM by Charles
 public Action()
 {
     Setters = new PropertySetters();
 }