Ejemplo n.º 1
0
        private static XamlMember CreateXamlMember(XAttribute attribute, XamlNamespaces namespaces)
        {
            XamlName name = new XamlName(attribute.Name.LocalName, attribute.Name.NamespaceName.IsNullOrEmpty() ? namespaces.Get(String.Empty) : attribute.Name.NamespaceName);
            object value = (object)MarkupExtensionParser.Parse(attribute.Value, namespaces);

            return new XamlMember(name, namespaces, value);
        }
Ejemplo n.º 2
0
        public static XamlName FromPrefixedName(string prefixedName, XamlNamespaces namespaces)
        {
            string typeName            = prefixedName;
            string typeNamespacePrefix = String.Empty;

            int namespaceSeparatorIndex = prefixedName.IndexOf(":");

            if (namespaceSeparatorIndex != -1)
            {
                typeNamespacePrefix = prefixedName.Substring(0, namespaceSeparatorIndex);
                typeName            = prefixedName.Substring(namespaceSeparatorIndex + 1);
            }

            return(namespaces.Contains(typeNamespacePrefix) ? new XamlName(typeName, namespaces.Get(typeNamespacePrefix)) : XamlName.Empty);
        }
Ejemplo n.º 3
0
        private static XamlMember CreateXamlMember(XElement element, XamlNamespaces namespaces)
        {
            XamlName name = new XamlName(element.Name.LocalName, element.Name.NamespaceName.IsNullOrEmpty() ? namespaces.Get(String.Empty) : element.Name.NamespaceName);

            if (element.Attributes().Any())
            {
                throw new Granular.Exception("Member \"{0}\" cannot contain attributes", element.Name);
            }

            if (element.Elements().Any(child => IsMemberName(child.Name)))
            {
                throw new Granular.Exception("Member \"{0}\" cannot contain member elements", element.Name);
            }

            return new XamlMember(name, namespaces, CreateValues(element, namespaces));
        }
Ejemplo n.º 4
0
        private string GetTypeNamespace(string typeFullName)
        {
            int namespaceSeparatorIndex = typeFullName.IndexOf(":");

            return(namespaces.Get(namespaceSeparatorIndex != -1 ? typeFullName.Substring(0, namespaceSeparatorIndex) : String.Empty));
        }
Ejemplo n.º 5
0
        private static XamlMember CreateXamlMember(XElement element, XamlNamespaces namespaces)
        {
            XamlName name = new XamlName(element.Name.LocalName, element.Name.NamespaceName.IsNullOrEmpty() ? namespaces.Get(String.Empty) : element.Name.NamespaceName);

            if (element.Attributes().Any())
            {
                throw new Granular.Exception("Member \"{0}\" cannot contain attributes", element.Name);
            }

            if (element.Elements().Any(child => IsMemberName(child.Name)))
            {
                throw new Granular.Exception("Member \"{0}\" cannot contain member elements", element.Name);
            }

            return(new XamlMember(name, namespaces, CreateValues(element, namespaces)));
        }
Ejemplo n.º 6
0
        private static XamlMember CreateXamlMember(XAttribute attribute, XamlNamespaces namespaces)
        {
            XamlName name  = new XamlName(attribute.Name.LocalName, attribute.Name.NamespaceName.IsNullOrEmpty() ? namespaces.Get(String.Empty) : attribute.Name.NamespaceName);
            object   value = (object)MarkupExtensionParser.Parse(attribute.Value, namespaces);

            return(new XamlMember(name, namespaces, value));
        }
Ejemplo n.º 7
0
        public static XamlName FromPrefixedName(string prefixedName, XamlNamespaces namespaces)
        {
            string typeName = prefixedName;
            string typeNamespacePrefix = String.Empty;

            int namespaceSeparatorIndex = prefixedName.IndexOf(":");
            if (namespaceSeparatorIndex != -1)
            {
                typeNamespacePrefix = prefixedName.Substring(0, namespaceSeparatorIndex);
                typeName = prefixedName.Substring(namespaceSeparatorIndex + 1);
            }

            return namespaces.Contains(typeNamespacePrefix) ? new XamlName(typeName, namespaces.Get(typeNamespacePrefix)) : XamlName.Empty;
        }
Ejemplo n.º 8
0
 public static string GetDefault(this XamlNamespaces @this)
 {
     return(@this.Get(String.Empty));
 }