예제 #1
0
        static void Main(string[] args)
        {
            object[] attributes = typeof(DCRSample).GetCustomAttributes(typeof(KnownAssembly), true);
            if (attributes.GetLength(0) != 0)
            {
                // Loading the assembly with types
                Assembly assembly = Assembly.Load(new AssemblyName(((KnownAssembly)attributes[0]).AssemblyName));

                // Creating the DataContractResolver
                DataContractResolverSample dcrSample = new DataContractResolverSample(assembly);

                Console.WriteLine("Serializing types from assembly: " + ((KnownAssembly)attributes[0]).AssemblyName);

                // Processing types
                foreach (Type type in assembly.GetTypes())
                {
                    dcrSample.serialize(type);
                    dcrSample.deserialize(type);
                }
                Console.WriteLine("----------------------------------------");
            }
            else
            {
                Console.WriteLine("Assembly not found");
            }
            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate.");
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            object[] attributes = typeof(DCRSample).GetCustomAttributes(typeof(KnownAssembly), true);
            if (attributes.GetLength(0) != 0)
            {
                // Loading the assembly with types
                Assembly assembly = Assembly.Load(new AssemblyName(((KnownAssembly)attributes[0]).AssemblyName));

                // Creating the DataContractResolver
                DataContractResolverSample dcrSample = new DataContractResolverSample(assembly);

                Console.WriteLine("Serializing types from assembly: " + ((KnownAssembly)attributes[0]).AssemblyName);

                // Processing types
                foreach (Type type in assembly.GetTypes())
                {
                    dcrSample.serialize(type);
                    dcrSample.deserialize(type);
                }
                Console.WriteLine("----------------------------------------");
            }
            else
            {
                Console.WriteLine("Assembly not found");
            }
            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate.");
            Console.ReadLine();
        }