public DynamicMemberHandle(string memberName, Type memberType, DynamicMemberGetter dynamicMemberGet, DynamicMemberSetter dynamicMemberSet)
 {
     MemberName = memberName;
     MemberType = memberType;
     DynamicMemberGet = dynamicMemberGet;
     DynamicMemberSet = dynamicMemberSet;
 }
Beispiel #2
0
        /// <summary>
        /// 动态获取指定名称的成员的值。
        /// </summary>
        /// <param name="name">成员的名称,可以是一个属性或字段。</param>
        /// <returns>成员的值。</returns>
        public virtual object Get(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            var memberInfo        = Type.GetMember(name, AllBindingFalgs).FirstOrDefault();
            DynamicMemberGetter d = null;

            if (memberInfo != null)
            {
                if (memberInfo.MemberType == MemberTypes.Property)
                {
                    d = (memberInfo as PropertyInfo).CreatePropertyGetter();
                }
                else if (memberInfo.MemberType == MemberTypes.Field)
                {
                    d = (memberInfo as FieldInfo).CreateFieldGetter();
                }
            }

            if (d == null)
            {
                throw new MissingMemberException(Type.FullName, name);
            }
            return(d(Instance));
        }
Beispiel #3
0
 public DynamicMemberHandle(string memberName, Type memberType, DynamicMemberGetter dynamicMemberGet, DynamicMemberSetter dynamicMemberSet)
 {
     this.MemberName       = memberName;
     this.MemberType       = memberType;
     this.DynamicMemberGet = dynamicMemberGet;
     this.DynamicMemberSet = dynamicMemberSet;
 }
 public SerializableFieldInfo(FieldInfo field, int depth)
 {
     this.Field = field;
     if(depth == 0) this.Name = field.Name;
     else this.Name = depth.ToString() + "#" + field.Name;
     this.GetValue = field.CreateFieldGetter();
     this.SetValue = field.CreateFieldSetter();
     
     //this.Name
     //this.NameHashCode = this.Name.GetHashCode();
 }
        public SerializableFieldInfo(FieldInfo field, int depth)
        {
            this.Field = field;
            if (depth == 0)
            {
                this.Name = field.Name;
            }
            else
            {
                this.Name = depth.ToString() + "#" + field.Name;
            }
            this.GetValue = field.CreateFieldGetter();
            this.SetValue = field.CreateFieldSetter();

            //this.Name
            //this.NameHashCode = this.Name.GetHashCode();
        }
Beispiel #6
0
        static ObjectFormatters()
        {
            var field = DefineTypes.HybridDictionary.GetField("caseInsensitive", Aoite.Reflection.Flags.InstancePrivateDeclaredOnly);

            GetCaseInsensitive = field.CreateFieldGetter();
        }
Beispiel #7
0
 static ObjectFormatters()
 {
     var field = Types.HybridDictionary.GetField("caseInsensitive", Aoite.Reflection.Flags.InstancePrivateDeclaredOnly);
     GetCaseInsensitive = field.CreateFieldGetter();
 }