예제 #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));
     }
 }
예제 #2
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);
 }
예제 #3
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));
     }
 }