Esempio n. 1
0
 public PropertyAccessor(
     PropertyInfo propertyInfo,
     GetMemberDelegate publicGetter,
     SetMemberDelegate publicSetter)
 {
     PropertyInfo = propertyInfo;
     PublicGetter = publicGetter;
     PublicSetter = publicSetter;
 }
Esempio n. 2
0
        public AssignmentEntry(string name, AssignmentMember @from, AssignmentMember to)
        {
            Name = name;
            From = @from;
            To   = to;

            GetValueFn     = From.CreateGetter();
            SetValueFn     = To.CreateSetter();
            ConvertValueFn = TypeConverter.CreateTypeConverter(From.Type, To.Type);
        }
Esempio n. 3
0
        public AssignmentEntry(string name, AssignmentMember @from, AssignmentMember to)
        {
            this.Name = name;
            this.From = @from;
            this.To   = to;

            this.GetValueFn     = this.From.CreateGetter();
            this.SetValueFn     = this.To.CreateSetter();
            this.ConvertValueFn = TypeConverter.CreateTypeConverter(this.From.Type, this.To.Type);
        }
 public FieldAccessor(
     FieldInfo fieldInfo,
     GetMemberDelegate publicGetter,
     SetMemberDelegate publicSetter,
     SetMemberRefDelegate publicSetterRef)
 {
     FieldInfo       = fieldInfo;
     PublicGetter    = publicGetter;
     PublicSetter    = publicSetter;
     PublicSetterRef = publicSetterRef;
 }
Esempio n. 5
0
        public IdFieldSetter()
        {
            var allProperties   = typeof(T).GetAllProperties();
            var fieldIdProperty = allProperties.SingleOrDefault(p => p.HasAttribute <IdFieldAttribute>());

            if (fieldIdProperty == null)
            {
                return;
            }

            _idFieldSetter = fieldIdProperty.CreateSetter();
        }
Esempio n. 6
0
        public EntityPropertyAccessor()
        {
            var allProperties  = typeof(T).GetAllProperties();
            var nodeIdProperty = allProperties.SingleOrDefault(p => p.HasAttributeNamed(nameof(NodeIdAttribute)));

            if (nodeIdProperty == null)
            {
                return;
            }

            nodeIdPropertySetter = nodeIdProperty.CreateSetter();
            nodeIdPropertyGetter = nodeIdProperty.CreateGetter();
        }
Esempio n. 7
0
        public static void Init()
        {
            // Use reflection to avoid tfm builds and binary dependency on .NET Framework v4.7.2+
            sameSiteFn = TypeProperties <HttpCookie> .GetAccessor("SameSite")?.PublicSetter;

            if (sameSiteFn != null)
            {
                var sameSiteMode = typeof(HttpCookie).Assembly.GetType("System.Web.SameSiteMode");
                if (sameSiteMode != null)
                {
                    sameSiteNone   = (Enum)Enum.Parse(sameSiteMode, "None");
                    sameSiteStrict = (Enum)Enum.Parse(sameSiteMode, "Strict");
                }
            }
        }
Esempio n. 8
0
        public PocoDataSource(IEnumerable <T> items, long nextIdSequence = 0)
        {
            this.items      = new List <T>(items);
            this.idSequence = nextIdSequence;

            var checkPropExists = typeof(T).GetProperty("Id");

            if (checkPropExists == null)
            {
                throw new ArgumentException($@"{typeof(T).Name} does not have an Id property", nameof(items));
            }

            idProp       = checkPropExists;
            idGetter     = idProp.CreateGetter <T>();
            idSetter     = idProp.CreateSetter <T>();
            defaultValue = idProp.PropertyType.GetDefaultValue();
        }
 public PropertySerializerEntry(SetMemberDelegate propertySetFn, ParseStringDelegate propertyParseStringFn)
 {
     PropertySetFn         = propertySetFn;
     PropertyParseStringFn = propertyParseStringFn;
 }