コード例 #1
0
 /// <summary>
 /// 将多个对象组合在一起(仅限第一层属性)
 /// </summary>
 /// <param name="objects">用于组装的对象列表,实体类/匿名类/字典/JSON</param>
 /// <returns>不会有null。</returns>
 public static Symbol.Collections.Generic.NameValueCollection <object> Combine(System.Collections.IEnumerable objects)
 {
     Symbol.Collections.Generic.NameValueCollection <object> values = As(null);
     if (objects != null)
     {
         foreach (var item in objects)
         {
             values.SetValues(item);
         }
     }
     return(values);
 }
コード例 #2
0
 static Symbol.Collections.Generic.NameValueCollection <string> GetValues(ICustomAttributeProvider provider)
 {
     Symbol.Collections.Generic.NameValueCollection <string> list;
     if (!_list.TryGetValue(provider, out list))
     {
         ThreadHelper.Block(_list, () => {
             if (!_list.TryGetValue(provider, out list))
             {
                 list = new Symbol.Collections.Generic.NameValueCollection <string>(StringComparer.OrdinalIgnoreCase);
                 GetValues(provider, list, true);
                 _list.TryAdd(provider, list);
             }
         });
     }
     return(list);
 }
コード例 #3
0
 static void GetValues(ICustomAttributeProvider provider, Symbol.Collections.Generic.NameValueCollection <string> list, bool inherit)
 {
     if (inherit)
     {
         {
             Type type = provider as Type;
             if (type != null)
             {
                 foreach (Type p in type.GetInterfaces())
                 {
                     GetValues(p, list, false);
                 }
             }
         }
         {
             MemberInfo member = provider as MemberInfo;
             if (member != null && member.DeclaringType != null)
             {
                 foreach (Type p in member.DeclaringType.GetInterfaces())
                 {
                     MemberInfo[] members = p.GetMember(member.Name);
                     if (members == null || members.Length == 0)
                     {
                         continue;
                     }
                     foreach (MemberInfo m in members)
                     {
                         GetValues(m, list, false);
                     }
                 }
             }
         }
     }
     {
         var attributes = provider.GetCustomAttributes(typeof(ConstAttribute), true);
         if (attributes != null)
         {
             foreach (ConstAttribute p in attributes)
             {
                 list[p.Key] = p.Value;
             }
         }
     }
 }