Beispiel #1
0
        /// <summary> 加载公开的静态的字段,参数hasNonPublic为true,则非公开的静态字段也一起加载
        /// </summary>
        /// <param name="hasNonPublic">是否一起加载非公开的静态字段</param>
        void ILoadMember.StaticField(bool hasNonPublic)
        {
            if (Loaded(hasNonPublic ? 3 : 4))
            {
                return;
            }
            if (Field == null)
            {
                Field = new ObjectPropertyCollection(Property.IgnoreCase);
            }
            var bf = BindingFlags.Public | BindingFlags.Static;

            if (hasNonPublic)
            {
                bf |= BindingFlags.NonPublic;
            }
            foreach (var f in Type.GetFields(bf))
            {
                if (Field.ContainsKey(f.Name) == false)
                {
                    Field.Add(new ObjectProperty(f));
                }
            }
            Monitor.Exit(this);
        }
Beispiel #2
0
        internal Literacy(TypeInfo info, bool ignoreCase)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            TypeInfo       = info;
            Type           = info.Type;
            _CallNewObject = PreNewObject;
            Property       = new ObjectPropertyCollection(ignoreCase);
            foreach (var p in Type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (p.GetIndexParameters().Length == 0) //排除索引器
                {
                    if (!Property.ContainsKey(p.Name))
                    {
                        var a = new ObjectProperty(p);
                        Property.Add(a);
                    }
                }
            }
            ID        = Interlocked.Increment(ref Sequence);
            UID       = Guid.NewGuid();
            TypeCodes = info.TypeCodes;
        }
Beispiel #3
0
        /// <summary> 加载非公开的实例字段
        /// </summary>
        void ILoadMember.NonPublicField()
        {
            if (Loaded(2))
            {
                return;
            }
            if (Field == null)
            {
                Field = new ObjectPropertyCollection(Property.IgnoreCase);
            }
            const BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Instance;

            foreach (var f in Type.GetFields(bf))
            {
                Field.Add(new ObjectProperty(f));
            }
            Monitor.Exit(this);
        }