コード例 #1
0
ファイル: CataFile.cs プロジェクト: BrianMacIntosh/SpaceTool
 public CataFile(string displayMember, JsonSchema schema)
     : this(displayMember)
 {
     this.schema = schema;
 }
コード例 #2
0
ファイル: CataFile.cs プロジェクト: BrianMacIntosh/SpaceTool
 public CataFile(string displayMember, string displaySuffix, JsonSchema schema)
     : this(displayMember, schema)
 {
     this.displaySuffix = displaySuffix;
 }
コード例 #3
0
ファイル: Storage.cs プロジェクト: BrianMacIntosh/SpaceTool
        public static void SaveJsonItem(StreamWriter write, object obj, JsonSchema schema, string pivotKey, int bracketBlockLevel = 1)
        {
            try
            {
                StringBuilder sb = new StringBuilder("[");
                foreach (Dictionary<string, object> item in (object[])obj)
                {
                    string type = (item.ContainsKey(pivotKey) ? (string)item[pivotKey] : "");
                    sb.Append(schema.Serialize(item, type));
                    sb.Append(",");
                }
                //Remove last comma
                sb.Remove(sb.Length - 1, 1);

                sb.Append("]");

                if (Options.DontFormatJson)
                    write.Write(sb.ToString());
                else
                    write.Write(SpaceJson(sb.ToString(), bracketBlockLevel));
            }
            catch (ArgumentException)
            {
                //TODO: error message
                return;
            }
        }
コード例 #4
0
ファイル: Storage.cs プロジェクト: Gladius1/CataModder
        public static void SaveJsonRecipes(string file, object obj, JsonSchema schema, string pivotKey, int bracketBlockLevel = 3)
        {
            StreamWriter write = new StreamWriter(new FileStream(Path.Combine(workspacePath, file), FileMode.Create));
            try
            {
                StringBuilder sb = new StringBuilder("{\"categories\":[");

                //Unknown stuff
                /*for (int c = 0; c < RecipeUnknown.Count; c++)
                {
                    Dictionary<string, object> item = RecipeUnknown[c].data;
                    string type = (item.ContainsKey(pivotKey) ? (string)item[pivotKey] : "");
                    sb.Append(schema.Serialize(item, type));
                    sb.Append(",");
                }*/
                sb.Append("\"" + string.Join("\",\"", CraftCategories) + "\"");

                sb.Append("],\"recipes\":[");

                //Recipes
                foreach (Dictionary<string, object> item in (object[])obj)
                {
                    string type = (item.ContainsKey(pivotKey) ? (string)item[pivotKey] : "");
                    sb.Append(schema.Serialize(item, type));
                    sb.Append(",");
                }
                //Remove last comma
                sb.Remove(sb.Length - 1, 1);

                sb.Append("]}");

                if (Options.DontFormatJson)
                    write.Write(sb.ToString());
                else
                    write.Write(SpaceJson(sb.ToString(), bracketBlockLevel));
            }
            catch (ArgumentException)
            {
                //TODO: error message
                return;
            }
            finally
            {
                write.Close();
            }
        }
コード例 #5
0
ファイル: Storage.cs プロジェクト: Gladius1/CataModder
        public static void SaveJsonItem(string file, object obj, JsonSchema schema, string pivotKey, int bracketBlockLevel = 1)
        {
            //TODO: remove in next version
            if (GetFileType(file) == FileType.SKILLS)
                return;

            StreamWriter write = new StreamWriter(new FileStream(Path.Combine(workspacePath, file), FileMode.Create));
            try
            {
                StringBuilder sb = new StringBuilder("[");
                foreach (Dictionary<string, object> item in (object[])obj)
                {
                    string type = (item.ContainsKey(pivotKey) ? (string)item[pivotKey] : "");
                    sb.Append(schema.Serialize(item, type));
                    sb.Append(",");
                }
                //Remove last comma
                sb.Remove(sb.Length - 1, 1);

                sb.Append("]");

                if (Options.DontFormatJson)
                    write.Write(sb.ToString());
                else
                    write.Write(SpaceJson(sb.ToString(), bracketBlockLevel));
            }
            catch (ArgumentException)
            {
                //TODO: error message
                return;
            }
            finally
            {
                write.Close();
            }
        }
コード例 #6
0
ファイル: Storage.cs プロジェクト: GalenEvil/CataModder
        public static void SaveJsonRecipes(string file, object obj, JsonSchema schema, string pivotKey, int bracketBlockLevel = 3)
        {
            StreamWriter write = new StreamWriter(new FileStream(file, FileMode.Create));
            try
            {
                StringBuilder sb = new StringBuilder("{\"categories\":[");

                //Categories
                foreach (string cat in CraftCategories)
                    sb.Append('"' + cat + "\",");
                //Remove last comma
                sb.Remove(sb.Length - 1, 1);

                sb.Append("],\"recipes\":[");

                //Recipes
                foreach (Dictionary<string, object> item in (object[])obj)
                {
                    string type = (item.ContainsKey(pivotKey) ? (string)item[pivotKey] : "");
                    sb.Append(schema.Serialize(item, type));
                    sb.Append(",");
                }
                //Remove last comma
                sb.Remove(sb.Length - 1, 1);

                sb.Append("]}");

                if (Options.DontFormatJson)
                    write.Write(sb.ToString());
                else
                    write.Write(SpaceJson(sb.ToString(), bracketBlockLevel));
            }
            catch (ArgumentException)
            {
                //TODO: error message
                return;
            }
            finally
            {
                write.Close();
            }
        }
コード例 #7
0
ファイル: Storage.cs プロジェクト: GalenEvil/CataModder
 static Storage()
 {
     //Load schemas
     itemSchema = new JsonSchema("CataclysmModder.schemas.items.txt");
     itemgroupSchema = new JsonSchema("CataclysmModder.schemas.item_group.txt");
     recipesSchema = new JsonSchema("CataclysmModder.schemas.recipes.txt");
 }