示例#1
0
        public void WriteTypeRegularTest()
        {
            Dictionary <string, IEnumerable <DateTime>[]> o = new Dictionary <string, IEnumerable <DateTime>[]>();
            Type t = o.GetType();

            TypeWriter writer = new TypeWriter();

            Console.WriteLine(writer.WriteType(t));
            Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

            Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Collections.Generic.IEnumerable`1[[System.DateTime, mscorlib]][], mscorlib]], mscorlib", writer.WriteType(t));
            Assert.AreEqual("System.Collections.Generic.Dictionary`2, mscorlib", writer.WriteType(t.GetGenericTypeDefinition()));
        }
示例#2
0
        public void WriteTypeMinimalTest()
        {
            Dictionary <string, IEnumerable <DateTime>[]> o = new Dictionary <string, IEnumerable <DateTime>[]>();
            Type t = o.GetType();

            TypeWriter writer = new TypeWriter();

            writer.WithAssembly = false;

            Console.WriteLine(writer.WriteType(t));
            Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

            Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String],[System.Collections.Generic.IEnumerable`1[[System.DateTime]][]]]", writer.WriteType(t));
            Assert.AreEqual("System.Collections.Generic.Dictionary`2", writer.WriteType(t.GetGenericTypeDefinition()));
        }
示例#3
0
        public void WriteAndReadTypeTest()
        {
            Dictionary <string, IEnumerable <DateTime>[]> o = new Dictionary <string, IEnumerable <DateTime>[]>();
            Type t = o.GetType();

            TypeWriter writer = new TypeWriter();

            Console.WriteLine(writer.WriteType(t));
            Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

            Type t1 = Type.GetType(writer.WriteType(t));
            Type t2 = Type.GetType(writer.WriteType(t.GetGenericTypeDefinition()));

            Assert.AreEqual(t, t1);
            Assert.AreEqual(t.GetGenericTypeDefinition(), t2);
        }
示例#4
0
        public void WriteTypeFullTest()
        {
            Dictionary <string, IEnumerable <DateTime>[]> o = new Dictionary <string, IEnumerable <DateTime>[]>();
            Type t = o.GetType();

            TypeWriter writer = new TypeWriter();

            writer.WithVersion        = true;
            writer.WithCulture        = true;
            writer.WithPublicKeyToken = true;

            Console.WriteLine(writer.WriteType(t));
            Console.WriteLine(writer.WriteType(t.GetGenericTypeDefinition()));

            Assert.AreEqual("System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.IEnumerable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", writer.WriteType(t));
            Assert.AreEqual("System.Collections.Generic.Dictionary`2, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", writer.WriteType(t.GetGenericTypeDefinition()));
        }