예제 #1
0
        void Parse()
        {
            var textTypes = Enum.GetValues(typeof(Contents.TextID));
            Func <object, JsonArrayCollection, bool, JsonArrayCollection> parse;

            foreach (Contents.TextID textType in textTypes)
            {
                var format = Contents.Text.Database.Get <Contents.Text.Base.Format>(textType);
                if (this.parseStrategies.TryGetValue(format.GetType(), out parse))
                {
                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Processing {0}", textType.ToString()));
                    var output = parse(format, JsonFiler.GetExisting(textType.ToString()), saveJson);
                    if (saveJson)
                    {
                        JsonFiler.Store(textType.ToString(), output, prettyPrint);
                    }
                }
            }

            var storyTypes = Enum.GetValues(typeof(Contents.StoryID));

            foreach (Contents.StoryID storyType in storyTypes)
            {
                var format = Contents.Story.Database.Get <Contents.Story.Base.Format>(storyType);
                if (this.parseStrategies.TryGetValue(format.GetType(), out parse))
                {
                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Processing {0}", storyType.ToString()));
                    var output = parse(format, JsonFiler.GetExisting(storyType.ToString()), saveJson);
                    JsonFiler.Store(storyType.ToString(), output, prettyPrint);
                }
            }
        }
예제 #2
0
파일: Database.cs 프로젝트: alama/ESBreaker
        void Parse()
        {
            var textTypes = Enum.GetValues(typeof(Contents.TextID));
            Func <object, JsonArrayCollection, bool, JsonArrayCollection> parse;

            foreach (Contents.TextID textType in textTypes)
            {
                Contents.Text.Base.Format format = null;
                try
                {
                    format = Contents.Text.Database.Get <Contents.Text.Base.Format>(textType);
                }
                catch (System.Collections.Generic.KeyNotFoundException ex)
                {
                    Console.Error.WriteLine(ex.ToString());
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Unknown issue with: " + textType.GetType());
                    Console.Error.WriteLine(ex.ToString());
                    throw;
                }
                if (format != null && this.parseStrategies.TryGetValue(format.GetType(), out parse))
                {
                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Processing {0}", textType.ToString()));
                    var output = parse(format, JsonFiler.GetExisting(textType.ToString()), saveJson);
                    if (saveJson)
                    {
                        JsonFiler.Store(textType.ToString(), output, prettyPrint);
                    }
                }
            }

            var storyTypes = Enum.GetValues(typeof(Contents.StoryID));

            foreach (Contents.StoryID storyType in storyTypes)
            {
                Contents.Story.Base.Format format = null;
                try
                {
                    format = Contents.Story.Database.Get <Contents.Story.Base.Format>(storyType);
                }
                catch (System.Collections.Generic.KeyNotFoundException ex)
                {
                    Console.Error.WriteLine(ex.ToString());
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Unknown issue with: " + storyType.GetType());
                    Console.Error.WriteLine(ex.ToString());
                    throw;
                }

                if (format != null && this.parseStrategies.TryGetValue(format.GetType(), out parse))
                {
                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Processing {0}", storyType.ToString()));
                    var output = parse(format, JsonFiler.GetExisting(storyType.ToString()), saveJson);
                    JsonFiler.Store(storyType.ToString(), output, prettyPrint);
                }
            }
        }