Ejemplo n.º 1
0
 private void LocalBuildEvents(AppMetas meta, string path)
 {
     foreach (var file in Directory.GetFiles(path, "*.cs"))
     {
         File.Delete(file);
     }
     CreateFiles(meta, path);
 }
Ejemplo n.º 2
0
        private void CreateFiles(AppMetas appmeta, string dir)
        {
            var s_namespace = appmeta.Name;

            Directory.CreateDirectory(dir);
            foreach (var meta in appmeta.MetaInfos)
            {
                CreateMainClassFile(dir, s_namespace, meta);
                if (meta.DefaultSeralize)
                {
                    CreateSeralizeClassFile(dir, s_namespace, meta);
                }
            }
            foreach (var meta in appmeta.Enums)
            {
                FileStream file = null;
                try
                {
                    file = File.Create(Path.Combine(dir, meta.Name + ".cs"));
                    file.WriteLine("using System;");
                    file.WriteLine("namespace EventModels." + s_namespace);
                    file.WriteLine("{");
                    file.WriteLine("    public enum " + meta.Name);
                    file.WriteLine("    {");
                    for (var i = 0; i < meta.Values.Count; i++)
                    {
                        if (i != meta.Values.Count - 1)
                        {
                            file.Write("        " + meta.Values[i].Name + " = " + meta.Values[i].Value);
                            file.WriteLine(",");
                        }
                        else
                        {
                            file.WriteLine("        " + meta.Values[i].Name + " = " + meta.Values[i].Value);
                        }
                    }
                    file.WriteLine("    }");
                    file.WriteLine("}");
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.ToString());
                }
                finally
                {
                    file?.Close();
                }
            }
            var versionFile = Path.Combine(dir, appmeta.Version + ".v");
            var v_file      = File.OpenWrite(versionFile);
            var json        = appmeta.ToJson();

            v_file.Write(json);
            v_file.Close();
        }