예제 #1
0
        public ValueEntityProperty(Type implementationType, string propertyName, int position, ValueFactory <TValue> valueFactory)
        {
            _position     = position;
            _valueFactory = valueFactory;

            _writeProperty = new WriteProperty <TEntity, Value <TValue> >(implementationType, propertyName);
        }
예제 #2
0
 public Property(PropertyInfo propertyInfo)
 {
     mName     = propertyInfo.Name;
     mTypeData = propertyInfo.PropertyType.GetTypeData();
     mRead     = propertyInfo.GetValue;
     mWrite    = propertyInfo.SetValue;
 }
예제 #3
0
        public ValueListEntityProperty(Type implementationType, string propertyName, int position, ValueListFactory <TValue> valueFactory, ValueSliceFactory valueSliceFactory)
        {
            if (implementationType == null)
            {
                throw new ArgumentNullException(nameof(implementationType));
            }
            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }
            if (valueFactory == null)
            {
                throw new ArgumentNullException(nameof(valueFactory));
            }
            if (valueSliceFactory == null)
            {
                throw new ArgumentNullException(nameof(valueSliceFactory));
            }

            _position          = position;
            _valueFactory      = valueFactory;
            _valueSliceFactory = valueSliceFactory;

            _writeProperty = new WriteProperty <TEntity, ValueList <TValue> >(implementationType, propertyName);
        }
예제 #4
0
 public TranslateEntityValuePropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo, PropertyInfo inputPropertyInfo,
                                               IEntityTranslator <TEntity, TSchema> entityTranslator)
 {
     _entityTranslator = entityTranslator;
     _propertyName     = entityPropertyInfo.Name;
     _property         = new WriteProperty <TResult, Value <TEntity> >(implementationType, _propertyName);
     _inputProperty    = new ReadOnlyProperty <TInput, Value <TEntity> >(inputPropertyInfo);
 }
예제 #5
0
 /// <summary>
 /// 判定属性是否是读写属性。
 /// </summary>
 /// <param name="propertyName">表示属性名称。</param>
 /// <returns>返回属性是否是读写属性。</returns>
 public bool IsWriteProperty(string propertyName)
 {
     if (WriteProperty.Contains(propertyName))
     {
         return(true);
     }
     return(false);
 }
예제 #6
0
 /// <summary>
 /// 将属性加入读写属性集合中。
 /// </summary>
 /// <param name="propertyNames">属性名称集合字符串,以';'号隔开。</param>
 protected void AddWritePropertyRange(string propertyNames)
 {
     string[] propertyNameArray = propertyNames.Split(';');
     foreach (string s in propertyNameArray)
     {
         WriteProperty.Add(s);
     }
 }
예제 #7
0
 public SetValuePropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo, PropertyInfo inputPropertyInfo,
                                   SetValueProvider <TInput, TSchema, TPropertyEntity> valueProvider)
 {
     _valueProvider = valueProvider;
     _propertyName  = entityPropertyInfo.Name;
     _property      = new WriteProperty <TEntity, Value <TPropertyEntity> >(implementationType, _propertyName);
     _inputProperty = new ReadOnlyProperty <TInput, Value <TPropertyEntity> >(inputPropertyInfo);
 }
예제 #8
0
        public DynamicEntityFactory(EntityInfo entityInfo, IEnumerable <IEntityInitializer <TEntity> > initializers)
        {
            _entityInfo = entityInfo;

            _initializers = initializers.ToArray();

            _entityInfoProperty = new WriteProperty <TEntity, EntityInfo>(typeof(TImplementation), nameof(Entity.EntityInfo));
        }
예제 #9
0
 /// <summary>
 /// Writes the properties of an instance to a delegate if not decorated with the DoNoTOutput attribute
 /// </summary>
 /// <param name="item">The item to output</param>
 /// <param name="writer">The method to invoke for writing a property value</param>
 public static void WriteConfiguration(object item, WriteProperty writer)
 {
     foreach (var property in item.GetType().GetProperties())
     {
         if (Attribute.GetCustomAttribute(property, typeof(DoNotOutputAttribute)) == null)
         {
             if (property.GetMethod != null)
             {
                 writer(property.Name, property.GetMethod.Invoke(item, null), property.PropertyType);
             }
         }
     }
 }
예제 #10
0
 object Evaluate(WriteProperty p)
 {
     _reflection.SetPropertyValue(Evaluate(p.Object), p.Property.Name, Evaluate(p.Value));
     return(null);
 }
예제 #11
0
 public EntityLayoutProperty(Type implementationType, PropertyInfo property, bool required, Func <Entity <TEntity>, TProperty> propertyConverter)
 {
     _required          = required;
     _propertyConverter = propertyConverter;
     _property          = new WriteProperty <TLayout, TProperty>(implementationType, property.Name);
 }
예제 #12
0
 public ExcludeValueListPropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo)
 {
     _propertyName = entityPropertyInfo.Name;
     _property     = new WriteProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, _propertyName);
     _readProperty = new ReadProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, _propertyName);
 }
예제 #13
0
        public PropertyEntityInitializer(Type implementationType, string propertyName, TValue value)
        {
            _value = value;

            _writeProperty = new WriteProperty <TEntity, Value <TValue> >(implementationType, propertyName);
        }
예제 #14
0
 public LayoutLayoutProperty(Type implementationType, PropertyInfo property, ILayoutParserFactory <T, TSchema> layout, bool required)
 {
     _layout   = layout;
     _required = required;
     _property = new WriteProperty <TLayout, Layout <T> >(implementationType, property.Name);
 }
예제 #15
0
 public CopyValueListPropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo, PropertyInfo inputPropertyInfo)
 {
     _property      = new WriteProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, entityPropertyInfo.Name);
     _inputProperty = new ReadOnlyProperty <TInput, ValueList <TPropertyEntity> >(inputPropertyInfo);
 }
예제 #16
0
        public ValueEntityPropertyConverter(Type implementationType, string propertyName, ValueFactory <TValue> valueFactory)
        {
            _valueFactory = valueFactory;

            _writeProperty = new WriteProperty <TEntity, Value <TValue> >(implementationType, propertyName);
        }
예제 #17
0
 public CopyValueListPropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo, PropertyInfo inputPropertyInfo)
 {
     _propertyName  = entityPropertyInfo.Name;
     _property      = new WriteProperty <TResult, ValueList <TValue> >(implementationType, _propertyName);
     _inputProperty = new ReadOnlyProperty <TInput, ValueList <TValue> >(inputPropertyInfo);
 }
예제 #18
0
 public DynamicEntityFactory(Type implementationType, EntityInfo entityInfo)
 {
     _entityInfo         = entityInfo;
     _new                = CompileNewMethod(implementationType);
     _entityTypeProperty = new WriteProperty <TEntity, EntityInfo>(implementationType, nameof(Entity.EntityInfo));
 }
예제 #19
0
 public SetPropertyTranslator(Type implementationType, PropertyInfo propertyInfo, ITranslatePropertyProvider <TProperty, TInput, TSchema> propertyProvider)
 {
     _propertyProvider = propertyProvider;
     _property         = new WriteProperty <TEntity, TProperty>(implementationType, propertyInfo.Name);
 }