Ejemplo n.º 1
0
        /// <summary>
        ///     Generates the code for the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="baseDirectory">The base directory.</param>
        public void Generate(IXerusModel model, string baseDirectory, string name)
        {
            List <IXerusDataType> dataTypes = model.DataTypes.ToList();

            dataTypes.AddRange(IntrinsicTypes.GetTypes());


            //GenerateSourcePart serializer
            using (StreamWriter streamWriter = File.CreateText(baseDirectory + "\\" + name + ".h"))
            {
                var serializerHeader = new SerializerHeaderGenerator();
                streamWriter.Write(serializerHeader.Generate(model, dataTypes, name));
            }

            using (StreamWriter streamWriter = File.CreateText(baseDirectory + "\\" + name + ".cpp"))
            {
                var serializerSource = new SerializerSourceGenerator();
                streamWriter.Write(serializerSource.Generate(model, dataTypes, name));
            }
        }