Esempio n. 1
0
        public void TestSystem()
        {
            SerializableAttribute sa = new SerializableAttribute();
            Assert(sa.GetType().IsSubclassOf(typeof(System.Attribute)));
            NonSerializedAttribute nsa = new NonSerializedAttribute();
            Assert(nsa.GetType().IsSubclassOf(typeof(System.Attribute)));

            //just make sure the definition is in the right place
            System.Runtime.Serialization.ISerializable iSerial = null;
            AreEqual(iSerial, null);

            AreEqual(StringSplitOptions.None.ToString("D"), "0");
            AreEqual(StringSplitOptions.RemoveEmptyEntries.ToString("D"), "1");

            AreEqual(ConsoleColor.Black.ToString("D"), "0");
            AreEqual(ConsoleColor.DarkBlue.ToString("D"), "1");
            AreEqual(ConsoleColor.DarkGreen.ToString("D"), "2");
            AreEqual(ConsoleColor.DarkCyan.ToString("D"), "3");
            AreEqual(ConsoleColor.DarkRed.ToString("D"), "4");
            AreEqual(ConsoleColor.DarkMagenta.ToString("D"), "5");
            AreEqual(ConsoleColor.DarkYellow.ToString("D"), "6");
            AreEqual(ConsoleColor.Gray.ToString("D"), "7");
            AreEqual(ConsoleColor.DarkGray.ToString("D"), "8");
            AreEqual(ConsoleColor.Blue.ToString("D"), "9");
            AreEqual(ConsoleColor.Green.ToString("D"), "10");
            AreEqual(ConsoleColor.Cyan.ToString("D"), "11");
            AreEqual(ConsoleColor.Red.ToString("D"), "12");
            AreEqual(ConsoleColor.Magenta.ToString("D"), "13");
            AreEqual(ConsoleColor.Yellow.ToString("D"), "14");
            AreEqual(ConsoleColor.White.ToString("D"), "15");
        }
Esempio n. 2
0
        static object[] GetPseudoCustomAttributes(Type type)
        {
            int count      = 0;
            var Attributes = type.Attributes;

            /* IsSerializable returns true for delegates/enums as well */
            if ((Attributes & TypeAttributes.Serializable) != 0)
            {
                count++;
            }
            if ((Attributes & TypeAttributes.Import) != 0)
            {
                count++;
            }

            if (count == 0)
            {
                return(null);
            }
            object[] attrs = new object [count];
            count = 0;

            if ((Attributes & TypeAttributes.Serializable) != 0)
            {
                attrs [count++] = new SerializableAttribute();
            }
            if ((Attributes & TypeAttributes.Import) != 0)
            {
                attrs [count++] = new ComImportAttribute();
            }

            return(attrs);
        }
Esempio n. 3
0
		public void AttributesTest ()
		{
			SerializableAttribute serializable_attr = new SerializableAttribute ();
			FlagsAttribute flags_attr = new FlagsAttribute ();

			CustomAttributeCollection attr_coll = new CustomAttributeCollection (serializable_attr, flags_attr);
			Attribute [] attributes = attr_coll.GetAttributes ();
			Assert.AreEqual (true, attributes != null, "#A0");
			Assert.AreEqual (2, attributes.Length, "#A1");

			// The property is supposed to be giving us the same instance in all the invocations
			Assert.AreSame (attributes, attr_coll.GetAttributes (), "#A2");
		}
Esempio n. 4
0
		internal object[] GetPseudoCustomAttributes ()
		{
			int count = 0;

			/* IsSerializable returns true for delegates/enums as well */
			if ((Attributes & TypeAttributes.Serializable) != 0)
				count ++;
			if ((Attributes & TypeAttributes.Import) != 0)
				count ++;

			if (count == 0)
				return null;
			object[] attrs = new object [count];
			count = 0;

			if ((Attributes & TypeAttributes.Serializable) != 0)
				attrs [count ++] = new SerializableAttribute ();
			if ((Attributes & TypeAttributes.Import) != 0)
				attrs [count ++] = new ComImportAttribute ();

			return attrs;
		}