예제 #1
0
        private IEnumerable <KeyValuePair <Type, ConfigAttribute> > GenerateCSCode(List <Type> allTypes)
        {
            SerializationGenerator gen = new SerializationGenerator();

            Dictionary <Type, ConfigAttribute> configs = new Dictionary <Type, ConfigAttribute>();

            for (int i = 0; i < allTypes.Count; i++)
            {
                ConfigAttribute attribute = null;
                Type            type      = allTypes[i];
                if ((type.Namespace == null || !type.Namespace.StartsWith("GeneratedCode")) &&
                    (attribute = TypeUtil.GetAttribute <ConfigAttribute>(type)) != null && !type.IsEnum &&
                    IsTargetNamespace(type.Namespace))
                {
                    type = attribute.GetConfigType(type);
                    configs.Add(type, attribute);
                    gen.RegisterRoot(type);
                }
            }

            gen.Register(typeof(ConfigHeader));

            new CodeGenVisitor().Export(gen, "GeneratedCode", targetFolder);
            string md5 = new VersionVisitor().GenerateMd5(gen);

            new SerializerListVisitor().Export(gen, "GeneratedCode", md5, targetFolder);

            return(configs);
        }