Esempio n. 1
0
        public override XamlType GetXamlType(Type type)
        {
            XamlType xamlType = null;

            if (this.customXamlTypes != null && this.customXamlTypes.TryGetValue(type, out xamlType))
            {
                return(xamlType);
            }
            bool isCustom = false;

            xamlType = GetCustomType(type);
            if (xamlType != null)
            {
                isCustom = true;
            }
            else
            {
                xamlType = base.GetXamlType(type);
                if (xamlType.GetXamlNamespaces().Any(ns => IsClrNamespaceInLocalAssembly(ns)))
                {
                    isCustom = true;
                    xamlType = new XamlTypeWithExplicitNamespace(xamlType, xamlType.GetXamlNamespaces().Select(ns => IsClrNamespaceInLocalAssembly(ns) ? TrimLocalAssembly(ns) : ns));
                }
            }
            if (isCustom)
            {
                if (this.customXamlTypes == null)
                {
                    this.customXamlTypes = new Dictionary <Type, XamlType>();
                }
                this.customXamlTypes[type] = xamlType;
            }
            return(xamlType);
        }
 public override XamlType GetXamlType(Type type)
 {            
     XamlType xamlType = null;
     if (this.customXamlTypes != null && this.customXamlTypes.TryGetValue(type, out xamlType))
     {
         return xamlType;
     }
     bool isCustom = false;
     xamlType = GetCustomType(type);
     if (xamlType != null)
     {
         isCustom = true;
     }
     else
     {
         xamlType = base.GetXamlType(type);
         if (xamlType.GetXamlNamespaces().Any(ns => IsClrNamespaceInLocalAssembly(ns)))
         {
             isCustom = true;
             xamlType = new XamlTypeWithExplicitNamespace(xamlType, xamlType.GetXamlNamespaces().Select(ns => IsClrNamespaceInLocalAssembly(ns) ? TrimLocalAssembly(ns) : ns));
         }
     }
     if (isCustom)
     {
         if (this.customXamlTypes == null)
         {
             this.customXamlTypes = new Dictionary<Type, XamlType>();
         }
         this.customXamlTypes[type] = xamlType;
     }
     return xamlType;
 }