예제 #1
0
 internal IEnumerable GetCustomAttributes(Type ownerType, string memberName)
 {
     MutableAttributeTable.AttributeList expandedAttributes = this.GetExpandedAttributes(ownerType, (object)memberName, (MutableAttributeTable.GetAttributesCallback)((typeToGet, callbackParam) =>
     {
         string key = (string)callbackParam;
         MutableAttributeTable.TypeMetadata typeMetadata;
         if (this._metadata.TryGetValue(typeToGet, out typeMetadata))
         {
             if (typeMetadata.MemberAttributes == null && typeMetadata.TypeAttributes != null && !typeMetadata.TypeAttributes.IsExpanded)
             {
                 lock (this._syncLock)
                 {
                     this.ExpandAttributes(ownerType, typeMetadata.TypeAttributes);
                     typeMetadata.TypeAttributes.IsExpanded = true;
                 }
             }
             MutableAttributeTable.AttributeList attributeList;
             if (typeMetadata.MemberAttributes != null && typeMetadata.MemberAttributes.TryGetValue(key, out attributeList))
             {
                 return(attributeList);
             }
         }
         return((MutableAttributeTable.AttributeList)null);
     }));
     if (expandedAttributes != null)
     {
         return((IEnumerable)expandedAttributes.AsReadOnly());
     }
     return((IEnumerable)MutableAttributeTable._empty);
 }
예제 #2
0
 private MutableAttributeTable.AttributeList GetAssemblyList(Assembly assembly)
 {
     MutableAttributeTable.AttributeList attributeList;
     if (!this._assemblyAttributes.TryGetValue(assembly, out attributeList))
     {
         attributeList = new MutableAttributeTable.AttributeList();
         this._assemblyAttributes.Add(assembly, attributeList);
     }
     return(attributeList);
 }
예제 #3
0
 private MutableAttributeTable.AttributeList GetMemberList(Type ownerType, string memberName)
 {
     MutableAttributeTable.TypeMetadata typeMetadata = this.GetTypeMetadata(ownerType);
     if (typeMetadata.MemberAttributes == null)
     {
         typeMetadata.MemberAttributes = new Dictionary <string, MutableAttributeTable.AttributeList>();
     }
     MutableAttributeTable.AttributeList attributeList;
     if (!typeMetadata.MemberAttributes.TryGetValue(memberName, out attributeList))
     {
         attributeList = new MutableAttributeTable.AttributeList();
         typeMetadata.MemberAttributes.Add(memberName, attributeList);
     }
     return(attributeList);
 }
예제 #4
0
 private void ExpandAttributes(Type type, MutableAttributeTable.AttributeList attributes)
 {
     if (attributes.IsExpanded)
     {
         return;
     }
     for (int index = 0; index < attributes.Count; ++index)
     {
         for (AttributeCallback attributeCallback = attributes[index] as AttributeCallback; attributeCallback != null; attributeCallback = index >= attributes.Count ? (AttributeCallback)null : attributes[index] as AttributeCallback)
         {
             attributes.RemoveAt(index);
             AttributeCallbackBuilder builder = new AttributeCallbackBuilder(this, type);
             attributeCallback(builder);
         }
     }
 }
예제 #5
0
 private void AddAssemblyMetadata(Assembly assembly, MutableAttributeTable.AttributeList attributes)
 {
     MutableAttributeTable.AttributeList attributeList;
     if (this._assemblyAttributes.TryGetValue(assembly, out attributeList))
     {
         if (!attributes.IsExpanded)
         {
             attributeList.IsExpanded = false;
         }
         attributeList.AddRange((IEnumerable <object>)attributes);
     }
     else
     {
         this._assemblyAttributes.Add(assembly, attributes);
     }
 }
예제 #6
0
 internal IEnumerable GetCustomAttributes(Type type)
 {
     MutableAttributeTable.AttributeList expandedAttributes = this.GetExpandedAttributes(type, (object)null, (MutableAttributeTable.GetAttributesCallback)((typeToGet, callbackParam) =>
     {
         MutableAttributeTable.TypeMetadata typeMetadata;
         if (this._metadata.TryGetValue(typeToGet, out typeMetadata))
         {
             return(typeMetadata.TypeAttributes);
         }
         return((MutableAttributeTable.AttributeList)null);
     }));
     if (expandedAttributes != null)
     {
         return((IEnumerable)expandedAttributes.AsReadOnly());
     }
     return((IEnumerable)MutableAttributeTable._empty);
 }
예제 #7
0
 private MutableAttributeTable.AttributeList GetExpandedAttributes(Type type, object callbackParam, MutableAttributeTable.GetAttributesCallback callback)
 {
     MutableAttributeTable.AttributeList attributes = callback(type, callbackParam);
     if (attributes != null && !attributes.IsExpanded)
     {
         lock (attributes)
         {
             if (!attributes.IsExpanded)
             {
                 lock (this._syncLock)
                 {
                     this.ExpandAttributes(type, attributes);
                     attributes.IsExpanded = true;
                 }
             }
         }
     }
     return(attributes);
 }
예제 #8
0
 private static void AddAttributes(MutableAttributeTable.AttributeList list, IEnumerable <object> attributes)
 {
     list.AddRange(attributes);
 }