Beispiel #1
0
        internal XObjectRW(XTypeInfo typeInfo, XBindingFlags flags)
        {
            this.flags = flags;

            fieldsCache = typeInfo.rwFieldsCache;
            fields      = typeInfo.rwFields;
            type        = typeInfo.Type;
        }
Beispiel #2
0
        public static XObjectRW Create <T>(XBindingFlags flags = XBindingFlags.UseDefault)
        {
            if (flags == XBindingFlags.UseDefault)
            {
                flags = GetDefaultBindingFlags(typeof(T));
            }

            return(new XObjectRW(XTypeInfo.Create <T>(flags | XTypeInfo.RW)));
        }
Beispiel #3
0
        public static XObjectRW Create <T>(XBindingFlags flags = XBindingFlags.None)
        {
            if (flags == XBindingFlags.None)
            {
                flags = DefaultBindingFlags;
            }

            return(new XObjectRW(XTypeInfo.Create <T>(flags | XTypeInfo.RW)));
        }
Beispiel #4
0
        /// <summary>
        /// 创建 XObjectRW 对象读写器。
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="flags">绑定标识</param>
        /// <returns>返回 XObjectRW 对象读写器</returns>
        public static XObjectRW Create(Type type, XBindingFlags flags = XBindingFlags.None)
        {
            if (flags == XBindingFlags.None)
            {
                flags = DefaultBindingFlags;
            }

            return(new XObjectRW(XTypeInfo.Create(type, flags), flags));
        }
Beispiel #5
0
        internal XObjectRW(XTypeInfo typeInfo, XBindingFlags flags)
        {
            this.flags = flags;

            fields          = typeInfo.rwFields;
            rFields         = typeInfo.rFields;
            Type            = typeInfo.Type;
            typeIsValueType = Type.IsValueType;
        }
Beispiel #6
0
        XTypeInfo LockGetOrCreate(XBindingFlags flags)
        {
            lock (this)
            {
                return(Get(flags) ?? Create());
            }

            XTypeInfo Create()
            {
                var length = xTypeInfos.Length;

                Array.Resize(ref xTypeInfos, length + 1);

                return(xTypeInfos[length] = new XTypeInfo(type, flags));
            }
        }
Beispiel #7
0
        /// <summary>
        /// 创建 XTypeInfo 类型信息。
        /// </summary>
        /// <param name="type">需要创建 XTypeInfo 类型信息的类型。</param>
        /// <param name="flags">绑定参数</param>
        /// <returns>返回一个 XTypeInfo 类型信息。</returns>
        public static XTypeInfo Create(Type type, XBindingFlags flags = XBindingFlags.Default)
        {
            var cacheKey = new CacheKey(type, flags);

            if (InstanceCaches.TryGetValue(cacheKey, out var value))
            {
                return(value);
            }

            lock (InstanceCachesLock)
            {
                if (InstanceCaches.TryGetValue(cacheKey, out value))
                {
                    return(value);
                }

                value = new XTypeInfo(type, flags);

                InstanceCaches.Add(cacheKey, value);

                return(value);
            }
        }
Beispiel #8
0
 internal XObjectRW(XTypeInfo xTypeInfo)
 {
     this.xTypeInfo = xTypeInfo;
 }