예제 #1
0
파일: XObjectRW.cs 프로젝트: cardinals/Yus
        /// <summary>
        /// 获取指定成员名称的成员值的读写器。
        /// </summary>
        /// <param name="key">成员名称</param>
        /// <returns>返回值的读写器</returns>
        public XFieldValueRW this[string key]
        {
            get
            {
                if (fieldsCache.TryGetValue(key, out var field))
                {
                    return(new XFieldValueRW(obj, field));
                }

                if ((flags & XBindingFlags.RWNoFoundException) != 0)
                {
                    throw new MissingMemberException(type.Name, key);
                }

                return(null);
            }
        }
예제 #2
0
 public static bool TryParse(string name, out T value)
 {
     if (NameCache.TryGetValue(name, out var containedValue))
     {
         value = (T)containedValue;
         return(true);
     }
     value = default(T);
     return(false);
 }
예제 #3
0
        public static DbProviderFactory GetFactory(string providerName)
        {
            if (providerName == null)
            {
                throw new ArgumentNullException(nameof(providerName));
            }

            if (ProviderTypesCache.TryGetValue(providerName, out var value))
            {
                return(value);
            }

            return(ProviderTypesCache.LockGetOrAdd(providerName, name => SearchFactory(name)));
        }