Inheritance: System.Xaml.XamlMember
Exemplo n.º 1
0
 public static bool operator ==(XamlMember xamlMember1, XamlMember xamlMember2)
 {
     if (ReferenceEquals(xamlMember1, xamlMember2))
     {
         return(true);
     }
     if (xamlMember1 is null || xamlMember2 is null)
     {
         return(false);
     }
     if (xamlMember1._memberType != xamlMember2._memberType || xamlMember1.Name != xamlMember2.Name)
     {
         return(false);
     }
     if (xamlMember1.IsDirective)
     {
         Debug.Assert(xamlMember2.IsDirective);
         // DeclaringType is null for directives, so we need to compare namespaces.
         // Known and unknown directives are equal if the names and namespaces match
         return(XamlDirective.NamespacesAreEqual((XamlDirective)xamlMember1, (XamlDirective)xamlMember2));
     }
     else
     {
         // Known and unknown members are not equal, even if they otherwise match
         return(xamlMember1.DeclaringType == xamlMember2.DeclaringType &&
                xamlMember1.IsUnknown == xamlMember2.IsUnknown);
     }
 }
Exemplo n.º 2
0
        private static XamlDirective GetXmlDirective(string name)
        {
            XamlDirective result = new XamlDirective(s_xmlNamespaces, name, String,
                                                     BuiltInValueConverter.String, AllowedMemberLocations.Attribute);

            return(result);
        }
Exemplo n.º 3
0
        private static XamlDirective GetXamlDirective(string name, XamlType xamlType,
                                                      XamlValueConverter <TypeConverter> typeConverter, AllowedMemberLocations allowedLocation)
        {
            XamlDirective result = new XamlDirective(s_xamlNamespaces, name, xamlType,
                                                     typeConverter, allowedLocation);

            return(result);
        }
Exemplo n.º 4
0
 private static ReadOnlyCollection <XamlDirective> GetAllDirectives()
 {
     XamlDirective[] result = new XamlDirective[]
     { Arguments, AsyncRecords, Class, Code, ClassModifier, ConnectionId, FactoryMethod, FieldModifier,
       Key, Initialization, Items, Members, ClassAttributes, Name, PositionalParameters, Shared, Subclass,
       SynchronousMode, TypeArguments, Uid, UnknownContent, Base, Lang, Space };
     return(new ReadOnlyCollection <XamlDirective>(result));
 }
Exemplo n.º 5
0
        public virtual XamlDirective GetXamlDirective(string xamlNamespace, string name)
        {
            XamlDirective t;
            var           p = new Pair(xamlNamespace, name);

            if (!xaml_directives.TryGetValue(p, out t))
            {
                t = new XamlDirective(xamlNamespace, name);
                xaml_directives.Add(p, t);
            }
            return(t);
        }
        internal static bool NamespacesAreEqual(XamlDirective directive1, XamlDirective directive2)
        {
            IList <string> list  = directive1._xamlNamespaces;
            IList <string> list2 = directive2._xamlNamespaces;

            if (list.Count != list2.Count)
            {
                return(false);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != list2[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        // We use the private field _xamlNamespaces to avoid expensive lookups or mutable
        // return values from overriden implementations of GetXamlNamespaces. But this will produce
        // hard-to-understand behavior if the namespaces returned from GetXamlNamespaces are different
        // from the ones passed in the ctor. Ideally we would provide overridable equality here.
        internal static bool NamespacesAreEqual(XamlDirective directive1, XamlDirective directive2)
        {
            IList <string> ns1 = directive1._xamlNamespaces;
            IList <string> ns2 = directive2._xamlNamespaces;

            if (ns1.Count != ns2.Count)
            {
                return(false);
            }
            for (int i = 0; i < ns1.Count; i++)
            {
                if (ns1[i] != ns2[i])
                {
                    return(false);
                }
            }
            return(true);
        }
 public static bool operator ==(XamlMember xamlMember1, XamlMember xamlMember2)
 {
     if (object.ReferenceEquals(xamlMember1, xamlMember2))
     {
         return(true);
     }
     if (object.ReferenceEquals(xamlMember1, null) || object.ReferenceEquals(xamlMember2, null))
     {
         return(false);
     }
     if ((xamlMember1._memberType != xamlMember2._memberType) || (xamlMember1.Name != xamlMember2.Name))
     {
         return(false);
     }
     if (xamlMember1.IsDirective)
     {
         return(XamlDirective.NamespacesAreEqual((XamlDirective)xamlMember1, (XamlDirective)xamlMember2));
     }
     return((xamlMember1.DeclaringType == xamlMember2.DeclaringType) && (xamlMember1.IsUnknown == xamlMember2.IsUnknown));
 }
Exemplo n.º 9
0
        // lookups

        protected virtual XamlMember LookupAliasedProperty(XamlDirective directive)
        {
            if (directive == XamlLanguage.Key)
            {
                var a = this.GetCustomAttribute <DictionaryKeyPropertyAttribute> ();
                return(a != null?GetMember(a.Name) : null);
            }
            if (directive == XamlLanguage.Name)
            {
                var a = this.GetCustomAttribute <RuntimeNamePropertyAttribute> ();
                return(a != null?GetMember(a.Name) : null);
            }
            if (directive == XamlLanguage.Uid)
            {
                var a = this.GetCustomAttribute <UidPropertyAttribute> ();
                return(a != null?GetMember(a.Name) : null);
            }
            if (directive == XamlLanguage.Lang)
            {
                var a = this.GetCustomAttribute <XmlLangPropertyAttribute> ();
                return(a != null?GetMember(a.Name) : null);
            }
            return(null);
        }
Exemplo n.º 10
0
        // returns remaining attributes to be processed
        Dictionary <string, string> ProcessAttributes(List <Pair> members)
        {
            var l = members;

            // base
            string xmlbase = r.GetAttribute("base", XamlLanguage.Xml1998Namespace) ?? r.BaseURI;

            if (types.Count == 0 && xmlbase != null)             // top
            {
                l.Add(new Pair(XamlLanguage.Base, xmlbase));
            }

            var atts = new Dictionary <string, string> ();

            if (r.MoveToFirstAttribute())
            {
                do
                {
                    switch (r.NamespaceURI)
                    {
                    case XamlLanguage.Xml1998Namespace:
                        switch (r.LocalName)
                        {
                        case "base":
                            continue;                             // already processed.

                        case "lang":
                            l.Add(new Pair(XamlLanguage.Lang, r.Value));
                            continue;

                        case "space":
                            l.Add(new Pair(XamlLanguage.Space, r.Value));
                            continue;
                        }
                        break;

                    case XamlLanguage.Xmlns2000Namespace:
                        continue;

                    case XamlLanguage.Xaml2006Namespace:
                        XamlDirective d = FindStandardDirective(r.LocalName, AllowedMemberLocations.Attribute);
                        if (d != null)
                        {
                            l.Add(new Pair(d, r.Value));
                            continue;
                        }
                        throw new NotSupportedException(String.Format("Attribute '{0}' is not supported", r.Name));

                    default:
                        if (r.NamespaceURI == String.Empty)
                        {
                            atts.Add(r.Name, r.Value);
                            continue;
                        }
                        // Should we just ignore unknown attribute in XAML namespace or any other namespaces ?
                        // Probably yes for compatibility with future version.
                        break;
                    }
                } while (r.MoveToNextAttribute());
                r.MoveToElement();
            }
            return(atts);
        }
Exemplo n.º 11
0
        static XamlLanguage()
        {
            InitializingTypes = true;

            // types

            Array     = XT <ArrayExtension> ();
            Boolean   = XT <bool> ();
            Byte      = XT <byte> ();
            Char      = XT <char> ();
            Decimal   = XT <decimal> ();
            Double    = XT <double> ();
            Int16     = XT <short> ();
            Int32     = XT <int> ();
            Int64     = XT <long> ();
            Member    = XT <MemberDefinition> ();
            Null      = XT <NullExtension> ();
            Object    = XT <object> ();
            Property  = XT <PropertyDefinition> ();
            Reference = XT <Reference> ();
            Single    = XT <float> ();
            Static    = XT <StaticExtension> ();
            String    = XT <string> ();
            TimeSpan  = XT <TimeSpan> ();
            Type      = XT <TypeExtension> ();
            Uri       = XT <Uri> ();
            XData     = XT <XData> ();

            InitializingTypes = false;

            AllTypes = new ReadOnlyCollection <XamlType> (new XamlType [] { Array, Boolean, Byte, Char, Decimal, Double, Int16, Int32, Int64, Member, Null, Object, Property, Reference, Single, Static, String, TimeSpan, Type, Uri, XData });

            // directives

            var nss    = new string [] { XamlLanguage.Xaml2006Namespace };
            var nssXml = new string [] { XamlLanguage.Xml1998Namespace };

            Arguments            = new XamlDirective(nss, "Arguments", XT <List <object> > (), null, AllowedMemberLocations.Any);
            AsyncRecords         = new XamlDirective(nss, "AsyncRecords", XT <string> (), null, AllowedMemberLocations.Attribute);
            Base                 = new XamlDirective(nssXml, "base", XT <string> (), null, AllowedMemberLocations.Attribute);
            Class                = new XamlDirective(nss, "Class", XT <string> (), null, AllowedMemberLocations.Attribute);
            ClassAttributes      = new XamlDirective(nss, "ClassAttributes", XT <List <Attribute> > (), null, AllowedMemberLocations.MemberElement);
            ClassModifier        = new XamlDirective(nss, "ClassModifier", XT <string> (), null, AllowedMemberLocations.Attribute);
            Code                 = new XamlDirective(nss, "Code", XT <string> (), null, AllowedMemberLocations.Attribute);
            ConnectionId         = new XamlDirective(nss, "ConnectionId", XT <string> (), null, AllowedMemberLocations.Any);
            FactoryMethod        = new XamlDirective(nss, "FactoryMethod", XT <string> (), null, AllowedMemberLocations.Any);
            FieldModifier        = new XamlDirective(nss, "FieldModifier", XT <string> (), null, AllowedMemberLocations.Attribute);
            Initialization       = new XamlDirective(nss, "_Initialization", XT <object> (), null, AllowedMemberLocations.Any);
            Items                = new XamlDirective(nss, "_Items", XT <List <object> > (), null, AllowedMemberLocations.Any);
            Key                  = new XamlDirective(nss, "Key", XT <object> (), null, AllowedMemberLocations.Any);
            Lang                 = new XamlDirective(nssXml, "lang", XT <string> (), null, AllowedMemberLocations.Attribute);
            Members              = new XamlDirective(nss, "Members", XT <List <MemberDefinition> > (), null, AllowedMemberLocations.MemberElement);
            Name                 = new XamlDirective(nss, "Name", XT <string> (), null, AllowedMemberLocations.Attribute);
            PositionalParameters = new XamlDirective(nss, "_PositionalParameters", XT <List <object> > (), null, AllowedMemberLocations.Any);
            Space                = new XamlDirective(nssXml, "space", XT <string> (), null, AllowedMemberLocations.Attribute);
            Subclass             = new XamlDirective(nss, "Subclass", XT <string> (), null, AllowedMemberLocations.Attribute);
            SynchronousMode      = new XamlDirective(nss, "SynchronousMode", XT <string> (), null, AllowedMemberLocations.Attribute);
            Shared               = new XamlDirective(nss, "Shared", XT <string> (), null, AllowedMemberLocations.Attribute);
            TypeArguments        = new XamlDirective(nss, "TypeArguments", XT <string> (), null, AllowedMemberLocations.Attribute);
            Uid                  = new XamlDirective(nss, "Uid", XT <string> (), null, AllowedMemberLocations.Attribute);
            UnknownContent       = new XamlDirective(nss, "_UnknownContent", XT <object> (), null, AllowedMemberLocations.MemberElement)
            {
                InternalIsUnknown = true
            };

            AllDirectives = new ReadOnlyCollection <XamlDirective> (new XamlDirective [] { Arguments, AsyncRecords, Base, Class, ClassAttributes, ClassModifier, Code, ConnectionId, FactoryMethod, FieldModifier, Initialization, Items, Key, Lang, Members, Name, PositionalParameters, Space, Subclass, SynchronousMode, Shared, TypeArguments, Uid, UnknownContent });

            SpecialNames = new SpecialTypeNameList();
        }
Exemplo n.º 12
0
 public XamlMember GetAliasedProperty(XamlDirective directive)
 {
     return(LookupAliasedProperty(directive));
 }
Exemplo n.º 13
0
		public void DefaultValuesWithComplexParams ()
		{
			var d = new XamlDirective (new string [0], "Foo", new XamlType (typeof (object), sctx), null, AllowedMemberLocations.Any);
			Assert.AreEqual (AllowedMemberLocations.Any, d.AllowedLocation, "#1");
			Assert.IsNull (d.DeclaringType, "#2");
			Assert.IsNotNull (d.Invoker, "#3");
			Assert.IsNull (d.Invoker.UnderlyingGetter, "#3-2");
			Assert.IsNull (d.Invoker.UnderlyingSetter, "#3-3");
			Assert.IsFalse (d.IsUnknown, "#4"); // different from another test
			Assert.IsTrue (d.IsReadPublic, "#5");
			Assert.IsTrue (d.IsWritePublic, "#6");
			Assert.AreEqual ("Foo", d.Name, "#7");
			Assert.IsTrue (d.IsNameValid, "#8");
			Assert.AreEqual (null, d.PreferredXamlNamespace, "#9"); // different from another test (as we specified empty array above)
			Assert.IsNull (d.TargetType, "#10");
			Assert.IsNotNull (d.Type, "#11");
			Assert.AreEqual (typeof (object), d.Type.UnderlyingType, "#11-2");
			Assert.IsNull (d.TypeConverter, "#12");
			Assert.IsNull (d.ValueSerializer, "#13");
			Assert.IsNull (d.DeferringLoader, "#14");
			Assert.IsNull (d.UnderlyingMember, "#15");
			Assert.IsFalse (d.IsReadOnly, "#16");
			Assert.IsFalse (d.IsWriteOnly, "#17");
			Assert.IsFalse (d.IsAttachable, "#18");
			Assert.IsFalse (d.IsEvent, "#19");
			Assert.IsTrue (d.IsDirective, "#20");
			Assert.IsNotNull (d.DependsOn, "#21");
			Assert.AreEqual (0, d.DependsOn.Count, "#21-2");
			Assert.IsFalse (d.IsAmbient, "#22");
			Assert.AreEqual (DesignerSerializationVisibility.Visible, d.SerializationVisibility, "#23");
		}
Exemplo n.º 14
0
 protected override XamlMember LookupAliasedProperty(XamlDirective directive)
 { 
     if (directive == XamlLanguage.Name)
     {
         return CallGetMember(_runtimeNamePropertyName);
     } 
     else if (directive == XamlLanguage.Key && _dictionaryKeyPropertyName != null)
     { 
         return LookupMember(_dictionaryKeyPropertyName, true); 
     }
     else if (directive == XamlLanguage.Lang) 
     {
         return CallGetMember(_xmlLangPropertyName);
     }
     else if (directive == XamlLanguage.Uid) 
     {
         return CallGetMember(_uidPropertyName); 
     } 
     else
     { 
         return null;
     }
 }
 public XamlMember GetNoDotAttributeProperty(XamlType tagType, XamlPropertyName propName, string tagNamespace, string propUsageNamespace, bool tagIsRoot)
 {
     XamlMember xamlAttachableProperty = null;
     if ((propUsageNamespace == tagNamespace) || (((tagNamespace == null) && (propUsageNamespace != null)) && tagType.GetXamlNamespaces().Contains(propUsageNamespace)))
     {
         XamlType rootObjectType = tagIsRoot ? tagType : null;
         xamlAttachableProperty = this.GetXamlProperty(tagType, propName.Name, rootObjectType);
         if (xamlAttachableProperty == null)
         {
             xamlAttachableProperty = this.GetXamlAttachableProperty(tagType, propName.Name);
         }
     }
     if ((xamlAttachableProperty == null) && (propUsageNamespace != null))
     {
         XamlDirective xamlDirective = this.SchemaContext.GetXamlDirective(propUsageNamespace, propName.Name);
         if (xamlDirective != null)
         {
             if ((xamlDirective.AllowedLocation & AllowedMemberLocations.Attribute) == AllowedMemberLocations.None)
             {
                 xamlDirective = new XamlDirective(propUsageNamespace, propName.Name);
             }
             xamlAttachableProperty = xamlDirective;
         }
     }
     if (xamlAttachableProperty != null)
     {
         return xamlAttachableProperty;
     }
     if (tagNamespace == propUsageNamespace)
     {
         return new XamlMember(propName.Name, tagType, false);
     }
     return new XamlDirective(propUsageNamespace, propName.Name);
 }
Exemplo n.º 16
0
		public void DefaultValuesWithName ()
		{
			var d = new XamlDirective ("urn:foo", "Foo");
			Assert.AreEqual (AllowedMemberLocations.Any, d.AllowedLocation, "#1");
			Assert.IsNull (d.DeclaringType, "#2");
			Assert.IsNotNull (d.Invoker, "#3");
			Assert.IsNull (d.Invoker.UnderlyingGetter, "#3-2");
			Assert.IsNull (d.Invoker.UnderlyingSetter, "#3-3");
			Assert.IsTrue (d.IsUnknown, "#4");
			Assert.IsTrue (d.IsReadPublic, "#5");
			Assert.IsTrue (d.IsWritePublic, "#6");
			Assert.AreEqual ("Foo", d.Name, "#7");
			Assert.IsTrue (d.IsNameValid, "#8");
			Assert.AreEqual ("urn:foo", d.PreferredXamlNamespace, "#9");
			Assert.IsNull (d.TargetType, "#10");
			Assert.IsNotNull (d.Type, "#11");
			Assert.AreEqual (typeof (object), d.Type.UnderlyingType, "#11-2");
			Assert.IsNull (d.TypeConverter, "#12");
			Assert.IsNull (d.ValueSerializer, "#13");
			Assert.IsNull (d.DeferringLoader, "#14");
			Assert.IsNull (d.UnderlyingMember, "#15");
			Assert.IsFalse (d.IsReadOnly, "#16");
			Assert.IsFalse (d.IsWriteOnly, "#17");
			Assert.IsFalse (d.IsAttachable, "#18");
			Assert.IsFalse (d.IsEvent, "#19");
			Assert.IsTrue (d.IsDirective, "#20");
			Assert.IsNotNull (d.DependsOn, "#21");
			Assert.AreEqual (0, d.DependsOn.Count, "#21-2");
			Assert.IsFalse (d.IsAmbient, "#22");
			Assert.AreEqual (DesignerSerializationVisibility.Visible, d.SerializationVisibility, "#23");
		}
Exemplo n.º 17
0
		void TestXamlDirectiveCommon (XamlDirective d, string name, string ns, AllowedMemberLocations allowedLocation, Type type)
		{
			TestXamlDirectiveCommon (d, name, ns, allowedLocation, type, false);
		}
Exemplo n.º 18
0
			public DirectiveMemberInvoker (XamlDirective directive)
				: base (directive)
			{
			}
Exemplo n.º 19
0
        private static XamlDirective GetXamlDirective(string name, AllowedMemberLocations allowedLocation, MemberReflector reflector)
        {
            XamlDirective result = new XamlDirective(s_xamlNamespaces, name, allowedLocation, reflector);

            return(result);
        }
Exemplo n.º 20
0
		public void ConstructorNameNull ()
		{
			// wow, it is allowed.
			var d = new XamlDirective (String.Empty, null);
			Assert.IsNull (d.Name, "#1");
		}
Exemplo n.º 21
0
		public void ConstructorComplexParamsEmptyNamespaces ()
		{
			var d = new XamlDirective (new string [0], "Foo", new XamlType (typeof (object), sctx), null, AllowedMemberLocations.Any);
		}
        public override void WriteStartObject(XamlType type)
        {
            if (type.UnderlyingType == typeof(string))
            {
                isWritingElementStyleString = true;
            }
            // this is the top-level object
            if (this.currentDepth == 0)
            {
                if (!this.debugSymbolNamespaceAdded)
                {
                    string sadsNamespaceAlias = GenerateNamespaceAlias(NameSpaces.DebugSymbolPrefix);
                    this.WriteNamespace(new NamespaceDeclaration(NameSpaces.DebugSymbol, sadsNamespaceAlias));
                    this.debugSymbolNamespaceAdded = true;
                }

                // we need to write MC namespace if any namespaces need to be ignored
                if (this.namespacesToIgnore.Count > 0)
                {
                    string mcNamespaceAlias = GenerateNamespaceAlias(NameSpaces.McPrefix);
                    this.WriteNamespace(new NamespaceDeclaration(NameSpaces.Mc, mcNamespaceAlias));
                }


                if (this.localNamespacesWithAssemblyInfo != null)
                {
                    foreach (NamespaceDeclaration xamlNamespace in this.localNamespacesWithAssemblyInfo)
                    {
                        if ((this.emittedNamespacesInLocalAssembly == null) || (!this.emittedNamespacesInLocalAssembly.Contains(xamlNamespace.Namespace)))
                        {
                            base.WriteNamespace(xamlNamespace);
                        }
                    }
                }

                if ((type.UnderlyingType == typeof(Activity)) ||
                    (type.IsGeneric && type.UnderlyingType != null && type.UnderlyingType.GetGenericTypeDefinition() == typeof(Activity<>)) ||
                    (type.UnderlyingType == typeof(WorkflowService)))
                {   // Exist ActivityBuilder, DebugSymbolObject will be inserted at the depth == 1.
                    debugSymbolDepth = 1;
                }
                else
                {
                    debugSymbolDepth = 0;
                }
            }

            if (this.currentDepth == debugSymbolDepth)
            {
                if (type.UnderlyingType != null && type.UnderlyingType.IsSubclassOf(typeof(Activity)) && this.shouldWriteDebugSymbol)
                {
                    this.writeDebugSymbol = true;
                }
            }

            base.WriteStartObject(type);

            if (this.currentDepth == 0)
            {
                // we need to add Ignore attribute for all namespaces which we don't want to load assemblies for
                // this has to be done after WriteStartObject
                if (this.namespacesToIgnore.Count > 0)
                {
                    string nsString = null;
                    foreach (string ns in this.namespacesToIgnore)
                    {
                        if (nsString == null)
                        {
                            nsString = ns;
                        }
                        else
                        {
                            nsString += " " + ns;
                        }
                    }

                    XamlDirective ignorable = new XamlDirective(NameSpaces.Mc, "Ignorable");
                    base.WriteStartMember(ignorable);
                    base.WriteValue(nsString);
                    base.WriteEndMember();
                    this.namespacesToIgnore.Clear();
                }
            }

            ++this.currentDepth;

        }
Exemplo n.º 23
0
 public DirectiveMemberInvoker(XamlDirective directive)
     : base(directive)
 {
 }
Exemplo n.º 24
0
 public DirectiveAdapter(XamlDirective xamlMember)
     : base(xamlMember.GetXamlNamespaces(), xamlMember.Name, xamlMember.Type, xamlMember.TypeConverter, xamlMember.AllowedLocation)
 {
 }
Exemplo n.º 25
0
		public void ConstructorComplexParams ()
		{
			var d = new XamlDirective (new string [] {"urn:foo"}, "Foo", new XamlType (typeof (object), sctx), null, AllowedMemberLocations.Any);
		}
Exemplo n.º 26
0
		void TestXamlDirectiveCommon (XamlDirective d, string name, AllowedMemberLocations allowedLocation, Type type)
		{
			TestXamlDirectiveCommon (d, name, XamlLanguage.Xaml2006Namespace, allowedLocation, type);
		}
Exemplo n.º 27
0
        // returns remaining attributes to be processed
        List <AttributeInfo> ProcessAttributes(XmlReader r, List <MemberInfo> members, out string typeArgNames)
        {
            // base (top element)
            if (!xmlbase_done)
            {
                xmlbase_done = true;
                string xmlbase = r.GetAttribute("base", XamlLanguage.Xml1998Namespace) ?? r.BaseURI;
                if (xmlbase != null)
                {
                    members.Add(new MemberInfo(XamlLanguage.Base, xmlbase, line_info));
                }
            }
            typeArgNames = null;
            var atts         = new List <AttributeInfo>();
            var tagNamespace = r.NamespaceURI;

            if (r.MoveToFirstAttribute())
            {
                do
                {
                    switch (r.NamespaceURI)
                    {
                    case XamlLanguage.Xml1998Namespace:
                        switch (r.LocalName)
                        {
                        case "base":
                            continue;                                             // already processed.

                        case "lang":
                            members.Add(new MemberInfo(XamlLanguage.Lang, r.Value, line_info));
                            continue;

                        case "space":
                            members.Add(new MemberInfo(XamlLanguage.Space, r.Value, line_info));
                            continue;
                        }
                        break;

                    case XamlLanguage.Xmlns2000Namespace:
                        continue;

                    case XamlLanguage.Xaml2006Namespace:
                        XamlDirective d = FindStandardDirective(r.LocalName, AllowedMemberLocations.Attribute);
                        if (d != null)
                        {
                            // check TypeArguments to resolve Type, and remove them from the list. They don't appear as a node.
                            if (ReferenceEquals(d, XamlLanguage.TypeArguments))
                            {
                                typeArgNames = r.Value;
                                continue;
                            }
                            members.Add(new MemberInfo(d, r.Value, line_info));
                            continue;
                        }
                        throw new NotSupportedException(String.Format("Attribute '{0}' is not supported", r.Name));

                    default:
                        if (string.IsNullOrEmpty(r.NamespaceURI) || tagNamespace == r.NamespaceURI || r.LocalName.IndexOf('.') > 0)
                        {
                            atts.Add(new AttributeInfo(r.Name, r.Value, line_info));
                            continue;
                        }
                        // Custom directive
                        members.Add(new MemberInfo(SchemaContext.GetXamlDirective(r.NamespaceURI, r.LocalName), r.Value,
                                                   line_info));
                        break;
                    }
                } while (r.MoveToNextAttribute());
                r.MoveToElement();
            }
            return(atts);
        }
Exemplo n.º 28
0
		void TestXamlDirectiveCommon (XamlDirective d, string name, string ns, AllowedMemberLocations allowedLocation, Type type, bool isUnknown)
		{
			Assert.AreEqual (allowedLocation, d.AllowedLocation, "#1");
			Assert.IsNull (d.DeclaringType, "#2");
			Assert.IsNotNull (d.Invoker, "#3");
			Assert.IsNull (d.Invoker.UnderlyingGetter, "#3-2");
			Assert.IsNull (d.Invoker.UnderlyingSetter, "#3-3");
			Assert.AreEqual (isUnknown, d.IsUnknown, "#4");
			Assert.IsTrue (d.IsReadPublic, "#5");
			Assert.IsTrue (d.IsWritePublic, "#6");
			Assert.AreEqual (name, d.Name, "#7");
			Assert.IsTrue (d.IsNameValid, "#8");
			Assert.AreEqual (ns, d.PreferredXamlNamespace, "#9");
			Assert.IsNull (d.TargetType, "#10");
			Assert.IsNotNull (d.Type, "#11");
			Assert.AreEqual (type, d.Type.UnderlyingType, "#11-2");

			// .NET returns StringConverter, but it should not premise that key must be string (it is object)
			if (name == "Key")
				;//Assert.IsNull (d.TypeConverter, "#12")
			else if (type.IsGenericType || name == "_Initialization" || name == "_UnknownContent")
				Assert.IsNull (d.TypeConverter, "#12");
			else
				Assert.IsNotNull (d.TypeConverter, "#12");
			Assert.IsNull (d.ValueSerializer, "#13");
			Assert.IsNull (d.DeferringLoader, "#14");
			Assert.IsNull (d.UnderlyingMember, "#15");
			Assert.IsFalse (d.IsReadOnly, "#16");
			Assert.IsFalse (d.IsWriteOnly, "#17");
			Assert.IsFalse (d.IsAttachable, "#18");
			Assert.IsFalse (d.IsEvent, "#19");
			Assert.IsTrue (d.IsDirective, "#20");
			Assert.IsNotNull (d.DependsOn, "#21");
			Assert.AreEqual (0, d.DependsOn.Count, "#21-2");
			Assert.IsFalse (d.IsAmbient, "#22");
			Assert.AreEqual (DesignerSerializationVisibility.Visible, d.SerializationVisibility, "#23");
		}
 internal static bool NamespacesAreEqual(XamlDirective directive1, XamlDirective directive2)
 {
     IList<string> list = directive1._xamlNamespaces;
     IList<string> list2 = directive2._xamlNamespaces;
     if (list.Count != list2.Count)
     {
         return false;
     }
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i] != list2[i])
         {
             return false;
         }
     }
     return true;
 }