Example #1
0
 public Type[] GetAttributeTypes(Type attributeType, int count)
 {
     if (CustomAttributeProvider != null)
     {
         object[] attributes = CustomAttributeProvider.GetCustomAttributes(attributeType, false);
         if (attributes.Length == 0)
         {
             return(null);
         }
         Debug.Assert(attributeType == typeof(XamlDeferLoadAttribute));
         Debug.Assert(count == 2);
         XamlDeferLoadAttribute tca = (XamlDeferLoadAttribute)attributes[0];
         Type converterType         = XamlNamespace.GetTypeFromFullTypeName(tca.LoaderTypeName);
         Type contentType           = XamlNamespace.GetTypeFromFullTypeName(tca.ContentTypeName);
         return(new Type[] { converterType, contentType });
     }
     try
     {
         CustomAttributeData cad = GetAttribute(attributeType);
         if (cad == null)
         {
             return(null);
         }
         return(ExtractTypes(cad, count));
     }
     catch (CustomAttributeFormatException)
     {
         CustomAttributeProvider = Member;
         return(GetAttributeTypes(attributeType, count));
     }
 }
Example #2
0
 public Type[] GetAttributeTypes(Type attributeType, int count)
 {
     if (this.CustomAttributeProvider != null)
     {
         object[] customAttributes = this.CustomAttributeProvider.GetCustomAttributes(attributeType, false);
         if (customAttributes.Length == 0)
         {
             return(null);
         }
         XamlDeferLoadAttribute attribute = (XamlDeferLoadAttribute)customAttributes[0];
         Type typeFromFullTypeName        = XamlNamespace.GetTypeFromFullTypeName(attribute.LoaderTypeName);
         Type type2 = XamlNamespace.GetTypeFromFullTypeName(attribute.ContentTypeName);
         return(new Type[] { typeFromFullTypeName, type2 });
     }
     try
     {
         CustomAttributeData cad = this.GetAttribute(attributeType);
         if (cad == null)
         {
             return(null);
         }
         return(this.ExtractTypes(cad, count));
     }
     catch (CustomAttributeFormatException)
     {
         this.CustomAttributeProvider = this.Member;
         return(this.GetAttributeTypes(attributeType, count));
     }
 }
Example #3
0
 private Type ExtractType(CustomAttributeTypedArgument arg)
 {
     if (arg.ArgumentType == typeof(Type))
     {
         return((Type)arg.Value);
     }
     else if (arg.ArgumentType == typeof(string))
     {
         string typeName = (string)arg.Value;
         return(XamlNamespace.GetTypeFromFullTypeName(typeName));
     }
     return(null);
 }
Example #4
0
 public Type GetAttributeType(Type attributeType)
 {
     if (CustomAttributeProvider != null)
     {
         object[] attributes = CustomAttributeProvider.GetCustomAttributes(attributeType, false);
         if (attributes.Length == 0)
         {
             return(null);
         }
         if (attributeType == typeof(TypeConverterAttribute))
         {
             string typeName = ((TypeConverterAttribute)attributes[0]).ConverterTypeName;
             return(XamlNamespace.GetTypeFromFullTypeName(typeName));
         }
         if (attributeType == typeof(MarkupExtensionReturnTypeAttribute))
         {
             return(((MarkupExtensionReturnTypeAttribute)attributes[0]).ReturnType);
         }
         if (attributeType == typeof(ValueSerializerAttribute))
         {
             return(((ValueSerializerAttribute)attributes[0]).ValueSerializerType);
         }
         Debug.Fail("Unexpected attribute type requested: " + attributeType.Name);
         return(null);
     }
     try
     {
         CustomAttributeData cad = GetAttribute(attributeType);
         if (cad == null)
         {
             return(null);
         }
         return(ExtractType(cad));
     }
     catch (CustomAttributeFormatException)
     {
         CustomAttributeProvider = Member;
         return(GetAttributeType(attributeType));
     }
 }
Example #5
0
 public Type GetAttributeType(Type attributeType)
 {
     if (this.CustomAttributeProvider != null)
     {
         object[] customAttributes = this.CustomAttributeProvider.GetCustomAttributes(attributeType, false);
         if (customAttributes.Length != 0)
         {
             if (attributeType == typeof(TypeConverterAttribute))
             {
                 return(XamlNamespace.GetTypeFromFullTypeName(((TypeConverterAttribute)customAttributes[0]).ConverterTypeName));
             }
             if (attributeType == typeof(MarkupExtensionReturnTypeAttribute))
             {
                 return(((MarkupExtensionReturnTypeAttribute)customAttributes[0]).ReturnType);
             }
             if (attributeType == typeof(ValueSerializerAttribute))
             {
                 return(((ValueSerializerAttribute)customAttributes[0]).ValueSerializerType);
             }
         }
         return(null);
     }
     try
     {
         CustomAttributeData attribute = this.GetAttribute(attributeType);
         if (attribute == null)
         {
             return(null);
         }
         return(this.ExtractType(attribute));
     }
     catch (CustomAttributeFormatException)
     {
         this.CustomAttributeProvider = this.Member;
         return(this.GetAttributeType(attributeType));
     }
 }