Example #1
0
 internal XamlMember ResolveDirectiveProperty(string xamlNS, string name)
 {
     if (xamlNS != null)
     {
         return(SchemaContext.GetXamlDirective(xamlNS, name));
     }
     return(null);
 }
Example #2
0
        public XamlMember GetNoDotAttributeProperty(XamlType tagType, XamlPropertyName propName,
                                                    string tagNamespace, string propUsageNamespace, bool tagIsRoot)
        {
            XamlMember property = null;

            // workaround: tagNamespace will always be null coming from MeScanner.
            // Second line of if just handles tagNamespace always being null from MEScanner
            // Correct fix is to fix MEScanner and remove second line
            if ((propUsageNamespace == tagNamespace) ||
                (tagNamespace == null && propUsageNamespace != null && tagType.GetXamlNamespaces().Contains(propUsageNamespace)))
            {
                XamlType rootTagType = tagIsRoot ? tagType : null;
                property = GetXamlProperty(tagType, propName.Name, rootTagType);

                // Sometimes Attached properties look like normal properties.
                // [Attribute case] The above lookup fails and fall into here.
                // <Grid> <Grid Row="0"/> </Grid>
                if (property == null)
                {
                    property = GetXamlAttachableProperty(tagType, propName.Name);
                }
            }
            // Not Simple, not Attachable, look for Directives.
            if (property == null && propUsageNamespace != null)
            {
                // A processing attribute like;  x:Key  x:Name
                XamlDirective directive = SchemaContext.GetXamlDirective(propUsageNamespace, propName.Name);
                if (directive != null)
                {
                    if (AllowedMemberLocations.None == (directive.AllowedLocation & AllowedMemberLocations.Attribute))
                    {
                        // Need a way to surface up this usage error now that
                        // we don't have UnknownProperty.Exception
                        directive = new XamlDirective(propUsageNamespace, propName.Name);
                    }
                    property = directive;
                }
            }
            if (property == null)
            {
                if (tagNamespace == propUsageNamespace)
                {
                    // Unknown simple property
                    property = new XamlMember(propName.Name, tagType, false);
                }
                else
                {
                    // Unknown directive
                    property = new XamlDirective(propUsageNamespace, propName.Name);
                }
            }
            return(property);
        }