Exemplo n.º 1
0
        public void ToStringNamespaceNull()
        {
            // allowed.
            var n = new XamlTypeName(null, "FooBar");

            n.ToString();
        }
Exemplo n.º 2
0
 public void StaticToStringNullLookup()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         XamlTypeName.ToString(new XamlTypeName[] { new XamlTypeName("urn:foo", "bar") }, null);
     });
 }
Exemplo n.º 3
0
 public void StaticToStringNullTypeNameList()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         XamlTypeName.ToString(null, new MyNamespaceLookup());
     });
 }
Exemplo n.º 4
0
        public void ToStringNamespaceNull()
        {
            // allowed.
            var n = new XamlTypeName(null, "FooBar");

            Assert.Throws <InvalidOperationException> (() => n.ToString());
        }
Exemplo n.º 5
0
 public void ToStringDefault()
 {
     Assert.Throws(typeof(InvalidOperationException), () =>
     {
         var n = new XamlTypeName();
         n.ToString();
     });
 }
Exemplo n.º 6
0
 public void ToStringNameNull()
 {
     Assert.Throws(typeof(InvalidOperationException), () =>
     {
         var n = new XamlTypeName("urn:foo", null);
         n.ToString();
     });
 }
Exemplo n.º 7
0
 public void ToStringNamespaceNull()
 {
     Assert.Throws(typeof(InvalidOperationException), () =>
     {
         // allowed.
         var n = new XamlTypeName(null, "FooBar");
         n.ToString();
     });
 }
Exemplo n.º 8
0
        public void ConstructorTypeArgumentsNullEntry()
        {
            if (!Compat.IsPortableXaml)
            {
                Assert.Ignore(".NET causes NRE on ToString().It is not really intended and should raise an error when constructed");
            }
            var type = new XamlTypeName("urn:foo", "FooBar", new XamlTypeName[] { null });

            Assert.DoesNotThrow(() => type.ToString());
        }
Exemplo n.º 9
0
        public void ToStringNamespaceLookupInsufficient()
        {
            var n      = new XamlTypeName("urn:foo", "Foo", new XamlTypeName [] { new XamlTypeName("urn:bar", "Bar"), new XamlTypeName("urn:baz", "Baz") });
            var lookup = new MyNamespaceLookup();

            lookup.Add("a", "urn:foo");
            lookup.Add("c", "urn:baz");
            // it fails because there is missing mapping for urn:bar.
            Assert.AreEqual("a:Foo({urn:bar}Bar, c:Baz)", n.ToString(lookup), "#1");
        }
Exemplo n.º 10
0
        public void ToStringNamespaceLookupInsufficient()
        {
            var n      = new XamlTypeName("urn:foo", "Foo", new XamlTypeName [] { new XamlTypeName("urn:bar", "Bar"), new XamlTypeName("urn:baz", "Baz") });
            var lookup = new MyNamespaceLookup();

            lookup.Add("a", "urn:foo");
            lookup.Add("c", "urn:baz");
            // it fails because there is missing mapping for urn:bar.
            Assert.Throws <InvalidOperationException> (() => n.ToString(lookup), "#1");
        }
Exemplo n.º 11
0
        public void ToStringNamespaceLookup()
        {
            var n      = new XamlTypeName("urn:foo", "Foo", new XamlTypeName [] { new XamlTypeName("urn:bar", "Bar"), new XamlTypeName("urn:baz", "Baz") });
            var lookup = new MyNamespaceLookup();

            lookup.Add("a", "urn:foo");
            lookup.Add("b", "urn:bar");
            lookup.Add("c", "urn:baz");
            Assert.AreEqual("a:Foo(b:Bar, c:Baz)", n.ToString(lookup), "#1");
            Assert.AreEqual("b:Bar, c:Baz", XamlTypeName.ToString(n.TypeArguments, lookup), "#2");
        }
Exemplo n.º 12
0
 public void ToStringTypeArgumentsNullEntry()
 {
                 #if PCL
     Assert.Throws <ArgumentNullException> (() => {
                 #else
     Assert.Throws <NullReferenceException> (() => {
                 #endif
         var n = new XamlTypeName("urn:foo", "FooBar", new XamlTypeName [] { null, new XamlTypeName("urn:bar", "FooBarBaz") });
         Assert.AreEqual("{urn:foo}FooBar()", n.ToString(), "#1");
     });
 }
Exemplo n.º 13
0
		public void ToStringEmptyNamespace ()
		{
			var n = new XamlTypeName (string.Empty, "Foo");
			Assert.AreEqual ("{}Foo", n.ToString (), "#1");
		}
Exemplo n.º 14
0
		public void ToStringTypeArgumentsNullEntry ()
		{
			var n = new XamlTypeName ("urn:foo", "FooBar", new XamlTypeName [] {null, new XamlTypeName ("urn:bar", "FooBarBaz")});
			Assert.AreEqual ("{urn:foo}FooBar()", n.ToString (), "#1");
		}
Exemplo n.º 15
0
		public void ToStringNamespaceNull ()
		{
			// allowed.
			var n = new XamlTypeName (null, "FooBar");
			n.ToString ();
		}
Exemplo n.º 16
0
		public void ToStringDefault ()
		{
			var n = new XamlTypeName ();
			n.ToString ();
		}
Exemplo n.º 17
0
		public void ToStringNamespaceNull ()
		{
			// allowed.
			var n = new XamlTypeName (null, "FooBar");
			Assert.Throws<InvalidOperationException> (() => n.ToString ());
		}
Exemplo n.º 18
0
        public void ToStringTypeArguments2()
        {
            var n = new XamlTypeName("urn:foo", "Foo", new XamlTypeName [] { new XamlTypeName("urn:bar", "Bar"), new XamlTypeName("urn:baz", "Baz") });

            Assert.AreEqual("{urn:foo}Foo({urn:bar}Bar, {urn:baz}Baz)", n.ToString(), "#1");
        }
Exemplo n.º 19
0
        public void ToStringNameNull()
        {
            var n = new XamlTypeName("urn:foo", null);

            n.ToString();
        }
Exemplo n.º 20
0
        public void ToStringDefault()
        {
            var n = new XamlTypeName();

            n.ToString();
        }
Exemplo n.º 21
0
 public void StaticToStringNullTypeNameList()
 {
     Assert.Throws <ArgumentNullException> (() => XamlTypeName.ToString(null, new MyNamespaceLookup()));
 }
Exemplo n.º 22
0
 public void StaticToStringNullLookup()
 {
     Assert.Throws <ArgumentNullException> (() => XamlTypeName.ToString(new XamlTypeName [] { new XamlTypeName("urn:foo", "bar") }, null));
 }
Exemplo n.º 23
0
		public void ToStringNamespaceLookupInsufficient ()
		{
			var n = new XamlTypeName ("urn:foo", "Foo", new XamlTypeName [] {new XamlTypeName ("urn:bar", "Bar"), new XamlTypeName ("urn:baz", "Baz")});
			var lookup = new MyNamespaceLookup ();
			lookup.Add ("a", "urn:foo");
			lookup.Add ("c", "urn:baz");
			// it fails because there is missing mapping for urn:bar.
			Assert.AreEqual ("a:Foo({urn:bar}Bar, c:Baz)", n.ToString (lookup), "#1");
		}
Exemplo n.º 24
0
        public void ToStringXamlTypePredefined()
        {
            var n = new XamlTypeName(XamlLanguage.Int32);

            Assert.AreEqual("{http://schemas.microsoft.com/winfx/2006/xaml}Int32", n.ToString(), "#1");
        }
Exemplo n.º 25
0
        public void ToStringNameNull()
        {
            var n = new XamlTypeName("urn:foo", null);

            Assert.Throws <InvalidOperationException> (() => n.ToString());
        }
        private IEnumerable <XamlNode> LogicStream_CheckForStartGetCollectionFromMember()
        {
            XamlType   type1             = this._context.CurrentType;
            XamlMember currentMember     = this._context.CurrentMember;
            XamlType   type              = currentMember.Type;
            XamlType   iteratorVariable2 = (this._xamlScanner.NodeType == ScannerNodeType.TEXT) ? XamlLanguage.String : this._xamlScanner.Type;

            if (type.IsArray && (this._xamlScanner.Type != this.ArrayExtensionType))
            {
                IEnumerable <NamespaceDeclaration> newNamespaces = null;
                XamlTypeName           iteratorVariable4         = new XamlTypeName(type.ItemType);
                INamespacePrefixLookup prefixLookup = new NamespacePrefixLookup(out newNamespaces, new Func <string, string>(this._context.FindNamespaceByPrefix));
                string data = iteratorVariable4.ToString(prefixLookup);
                foreach (NamespaceDeclaration iteratorVariable7 in newNamespaces)
                {
                    yield return(new XamlNode(XamlNodeType.NamespaceDeclaration, iteratorVariable7));
                }
                yield return(this.Logic_StartObject(this.ArrayExtensionType, null));

                this._context.CurrentInImplicitArray = true;
                yield return(this.Logic_StartMember(this.ArrayTypeMember));

                yield return(new XamlNode(XamlNodeType.Value, data));

                yield return(this.Logic_EndMember());

                yield return(this.Logic_EndOfAttributes());

                yield return(this.Logic_StartMember(this.ItemsTypeMember));

                XamlType currentType = this._context.CurrentType;
                currentMember = this._context.CurrentMember;
                type          = currentMember.Type;
            }
            if (!currentMember.IsDirective && (type.IsCollection || type.IsDictionary))
            {
                bool iteratorVariable8 = false;
                if (currentMember.IsReadOnly || !this._context.CurrentMemberIsWriteVisible())
                {
                    iteratorVariable8 = true;
                }
                else if (((type.TypeConverter != null) && !currentMember.IsReadOnly) && (this._xamlScanner.NodeType == ScannerNodeType.TEXT))
                {
                    iteratorVariable8 = false;
                }
                else if (((iteratorVariable2 == null) || !iteratorVariable2.CanAssignTo(type)) && (iteratorVariable2 != null))
                {
                    if (!iteratorVariable2.IsMarkupExtension || this._xamlScanner.HasKeyAttribute)
                    {
                        iteratorVariable8 = true;
                    }
                    else if (iteratorVariable2 == XamlLanguage.Array)
                    {
                        iteratorVariable8 = true;
                    }
                }
                if (iteratorVariable8)
                {
                    yield return(this.Logic_StartGetObjectFromMember(type));

                    yield return(this.Logic_StartItemsProperty(type));
                }
            }
        }
Exemplo n.º 27
0
        public void ToStringEmptyNamespace()
        {
            var n = new XamlTypeName(string.Empty, "Foo");

            Assert.AreEqual("{}Foo", n.ToString(), "#1");
        }
Exemplo n.º 28
0
 public void StaticToStringNullLookup()
 {
     XamlTypeName.ToString(new XamlTypeName [] { new XamlTypeName("urn:foo", "bar") }, null);
 }
Exemplo n.º 29
0
        public void ToStringNullLookup()
        {
            var n = new XamlTypeName("urn:foo", "Foo", new XamlTypeName [] { new XamlTypeName("urn:bar", "Bar"), new XamlTypeName("urn:baz", "Baz") });

            Assert.AreEqual("{urn:foo}Foo({urn:bar}Bar, {urn:baz}Baz)", n.ToString(null), "#1");
        }
Exemplo n.º 30
0
 public void StaticToStringNullTypeNameList()
 {
     XamlTypeName.ToString(null, new MyNamespaceLookup());
 }
Exemplo n.º 31
0
		public void ToStringTypeArgumentsNullEntry ()
		{
			#if PCL
			Assert.Throws<ArgumentNullException> (() => {
			#else
			Assert.Throws<NullReferenceException> (() => {
			#endif
				var n = new XamlTypeName ("urn:foo", "FooBar", new XamlTypeName [] { null, new XamlTypeName ("urn:bar", "FooBarBaz") });
				Assert.AreEqual ("{urn:foo}FooBar()", n.ToString (), "#1");
			});
		}
Exemplo n.º 32
0
        private IEnumerable <XamlNode> LogicStream_CheckForStartGetCollectionFromMember()
        {
            XamlType   currentType     = _context.CurrentType;
            XamlMember currentProperty = _context.CurrentMember;

            XamlType propertyType = currentProperty.Type;

            XamlType valueElementType = (_xamlScanner.NodeType == ScannerNodeType.TEXT)
                            ? XamlLanguage.String
                            : _xamlScanner.Type;

            if (propertyType.IsArray && _xamlScanner.Type != ArrayExtensionType)
            {
                IEnumerable <NamespaceDeclaration> newNamespaces = null;
                XamlTypeName           typeName       = new XamlTypeName(propertyType.ItemType);
                INamespacePrefixLookup prefixResolver = new NamespacePrefixLookup(out newNamespaces, _context.FindNamespaceByPrefix);
                string typeNameString = typeName.ToString(prefixResolver);    // SideEffects!!! prefixResolver will populate newNamespaces

                foreach (NamespaceDeclaration nsDecl in newNamespaces)
                {
                    yield return(new XamlNode(XamlNodeType.NamespaceDeclaration, nsDecl));
                }
                yield return(Logic_StartObject(ArrayExtensionType, null));

                _context.CurrentInImplicitArray = true;
                yield return(Logic_StartMember(ArrayTypeMember));

                yield return(new XamlNode(XamlNodeType.Value, typeNameString));

                yield return(Logic_EndMember());

                yield return(Logic_EndOfAttributes());

                yield return(Logic_StartMember(ItemsTypeMember));

                currentType     = _context.CurrentType;
                currentProperty = _context.CurrentMember;
                propertyType    = currentProperty.Type;
            }

            // Now Consider inserting special preamble to "Get" the collection:
            //   . GO
            //   . . SM _items
            if (!currentProperty.IsDirective && (propertyType.IsCollection || propertyType.IsDictionary))
            {
                bool emitPreamble = false;

                // If the collection property is Readonly then "Get" the collection.
                if (currentProperty.IsReadOnly || !_context.CurrentMemberIsWriteVisible())
                {
                    emitPreamble = true;
                }
                // If the collection is R/W and there is a type converter and we have Text
                // use the type converter rather than the GO; SM _items;
                else if (propertyType.TypeConverter != null && !currentProperty.IsReadOnly &&
                         _xamlScanner.NodeType == ScannerNodeType.TEXT)
                {
                    emitPreamble = false;
                }
                // Or if the Value (this is the first value in the collection)
                // isn't assignable to the Collection then "Get" the collection.
                else if (valueElementType == null || !valueElementType.CanAssignTo(propertyType))
                {
                    if (valueElementType != null)
                    {
                        // Unless: the Value is a Markup extension, in which case it is
                        // assumed that the ProvideValue() type will be AssignableFrom
                        // or If the next object has an x:Key in which case it must be
                        // a dictionary entry.
                        // so Don't "Get" the collection.
                        if (!valueElementType.IsMarkupExtension || _xamlScanner.HasKeyAttribute)
                        {
                            emitPreamble = true;
                        }
                        // Except: the Array Extension can never return a dictionary
                        // so for Array Extension do "Get" the collection.
                        // Note Array Extension would be suitable for List Collections
                        // Note: a fully validating parser should look at MarkupExtensionReturnType
                        // for this choice, there might be other MarkupExtensions that fit this.
                        else if (valueElementType == XamlLanguage.Array)
                        {
                            emitPreamble = true;
                        }
                    }
                }
                if (emitPreamble)
                {
                    yield return(Logic_StartGetObjectFromMember(propertyType));

                    yield return(Logic_StartItemsProperty(propertyType));
                }
            }
        }
Exemplo n.º 33
0
 public void StaticToStringEmptyArray()
 {
     Assert.AreEqual("", XamlTypeName.ToString(new XamlTypeName [0], new MyNamespaceLookup()), "#1");
 }
Exemplo n.º 34
0
		public void ToStringNamespaceLookupInsufficient ()
		{
			var n = new XamlTypeName ("urn:foo", "Foo", new XamlTypeName [] {new XamlTypeName ("urn:bar", "Bar"), new XamlTypeName ("urn:baz", "Baz")});
			var lookup = new MyNamespaceLookup ();
			lookup.Add ("a", "urn:foo");
			lookup.Add ("c", "urn:baz");
			// it fails because there is missing mapping for urn:bar.
			Assert.Throws<InvalidOperationException> (() => n.ToString (lookup), "#1");
		}
Exemplo n.º 35
0
		public void ToStringNameNull ()
		{
			var n = new XamlTypeName ("urn:foo", null);
			n.ToString ();
		}
Exemplo n.º 36
0
		public void ToStringNamespaceLookup ()
		{
			var n = new XamlTypeName ("urn:foo", "Foo", new XamlTypeName [] {new XamlTypeName ("urn:bar", "Bar"), new XamlTypeName ("urn:baz", "Baz")});
			var lookup = new MyNamespaceLookup ();
			lookup.Add ("a", "urn:foo");
			lookup.Add ("b", "urn:bar");
			lookup.Add ("c", "urn:baz");
			Assert.AreEqual ("a:Foo(b:Bar, c:Baz)", n.ToString (lookup), "#1");
			Assert.AreEqual ("b:Bar, c:Baz", XamlTypeName.ToString (n.TypeArguments, lookup), "#2");
		}
Exemplo n.º 37
0
		public void ToStringTypeArgumentsNull ()
		{
			var n = new XamlTypeName ("urn:foo", "FooBar", (XamlTypeName []) null);
			Assert.AreEqual ("{urn:foo}FooBar", n.ToString (), "#1");
		}
Exemplo n.º 38
0
		public void ToStringNameNull ()
		{
			var n = new XamlTypeName ("urn:foo", null);
			Assert.Throws<InvalidOperationException> (() => n.ToString ());
		}
Exemplo n.º 39
0
		public void ToStringTypeArguments2 ()
		{
			var n = new XamlTypeName ("urn:foo", "Foo", new XamlTypeName [] {new XamlTypeName ("urn:bar", "Bar"), new XamlTypeName ("urn:baz", "Baz")});
			Assert.AreEqual ("{urn:foo}Foo({urn:bar}Bar, {urn:baz}Baz)", n.ToString (), "#1");
		}
Exemplo n.º 40
0
        public void ToStringTypeArgumentsNull()
        {
            var n = new XamlTypeName("urn:foo", "FooBar", (XamlTypeName [])null);

            Assert.AreEqual("{urn:foo}FooBar", n.ToString(), "#1");
        }
Exemplo n.º 41
0
		public void ToStringXamlTypePredefined ()
		{
			var n = new XamlTypeName (XamlLanguage.Int32);
			Assert.AreEqual ("{http://schemas.microsoft.com/winfx/2006/xaml}Int32", n.ToString (), "#1");
		}
Exemplo n.º 42
0
        public void ToStringTypeArgumentsNullEntry()
        {
            var n = new XamlTypeName("urn:foo", "FooBar", new XamlTypeName [] { null, new XamlTypeName("urn:bar", "FooBarBaz") });

            Assert.AreEqual("{urn:foo}FooBar()", n.ToString(), "#1");
        }
Exemplo n.º 43
0
		public void ToStringNullLookup ()
		{
			var n = new XamlTypeName ("urn:foo", "Foo", new XamlTypeName [] {new XamlTypeName ("urn:bar", "Bar"), new XamlTypeName ("urn:baz", "Baz")});
			Assert.AreEqual ("{urn:foo}Foo({urn:bar}Bar, {urn:baz}Baz)", n.ToString (null), "#1");
		}
Exemplo n.º 44
0
        public void ToStringDefault()
        {
            var n = new XamlTypeName();

            Assert.Throws <InvalidOperationException> (() => n.ToString());
        }
Exemplo n.º 45
0
		public void ConstructorTypeArgumentsNullEntry()
		{
			if (!Compat.IsPortableXaml)
				Assert.Ignore(".NET causes NRE on ToString().It is not really intended and should raise an error when constructed");
			var type = new XamlTypeName("urn:foo", "FooBar", new XamlTypeName[] { null });
			Assert.DoesNotThrow(() => type.ToString());
		}
Exemplo n.º 46
0
		public void ToStringDefault ()
		{
			var n = new XamlTypeName ();
			Assert.Throws<InvalidOperationException> (() => n.ToString ());
		}