Esempio n. 1
0
        private static void LoadContentManifest()
        {
            ContentManifest newManifest = JsonIO.Load <ContentManifest>(PathUtils.GetLocalPath(content_path, "content.json"));

            bool reloading_manifest = false;

            if (manifest != null)
            {
                reloading_manifest = true;
                StageNewResources(newManifest);
            }

            manifest = newManifest;

            FillContentMapsFromCurrentManifest();

            if (reloading_manifest)
            {
                foreach (var new_res_id in newResourcesToAdd)
                {
                    ConsoleUtils.ShowInfo($"Found new resource to Add: {new_res_id}");
                    UpdateResourceOnPak(new_res_id);
                }

                newResourcesToAdd.Clear();
            }
        }
Esempio n. 2
0
        public static void Build(string project_root_path)
        {
            var content_path = PathUtils.GetLocalPath(project_root_path, Constants.CONTENT_FOLDER);

            if (!Directory.Exists(content_path))
            {
                throw new Exception("Invalid Project : Missing Content Folder");
            }

            ContentManifest manifest;

            var manifest_path = PathUtils.GetLocalPath(content_path, "content.json");

            if (!File.Exists(manifest_path))
            {
                throw new Exception("Invalid Project : Missing content.json");
            }

            manifest = JsonIO.Load <ContentManifest>(manifest_path);

            var root_path = Path.GetDirectoryName(manifest_path);

            var paks = BuildPaks(root_path, manifest);

            foreach (var pak in paks)
            {
                pak.SaveToDisk(root_path);
            }
        }
Esempio n. 3
0
        public void ExportInterfacesAndImportJson()
        {
            // assert
            var input = new InterfaceRepository();

            input.Add(new TestClassA());
            input.Add(new TestClassB());
            input.Add(new TestClassA());
            input.Add(new TestClassA());

            var binder = new TypedSerializationBinder(new List <Type> {
                typeof(TestClassA),
                typeof(TestClassB)
            });

            string json = JsonIO.ToJsonString(input, binder);

            // act
            var output = JsonIO.FromJsonString <InterfaceRepository>(json, binder);

            // Assert
            for (int i = 0; i < output.Count; i++)
            {
                Assert.AreEqual(output[i].Name, input[i].Name, $"Name property at {i} is not equal");
                Assert.AreEqual(output[i].Id, input[i].Id, $"Id property at {i} is not equal");
            }
        }
Esempio n. 4
0
        public ActionResult <JsonStatus> ProblemsPost([FromBody] JsonJob instance)
        {
            // Sanity check job
            var inputErr = JsonIO.Validate(instance.Instance);

            if (inputErr != null)
            {
                _logger.LogWarning($"POST calculation had error: {inputErr}");
                return(BadRequest(inputErr));
            }
            // Create calculation job
            int calcId = _jobManager.GetNextId();
            var calc   = new Calculation(calcId, instance, null);

            if (calc.Problem.Configuration == null) // Set a default config, if none is given
            {
                calc.Problem.Configuration = new ObjectModel.Configuration.Configuration(ObjectModel.MethodType.ExtremePointInsertion, false);
            }
            calc.Status.ProblemUrl  = $"{SUB_CALCULATION_PROBLEMS}/{calcId}";
            calc.Status.StatusUrl   = $"{SUB_CALCULATION_PROBLEMS}/{calcId}/status";
            calc.Status.SolutionUrl = $"{SUB_CALCULATION_PROBLEMS}/{calcId}/solution";
            // Log
            _logger.LogInformation($"POST calculation (got ID {calcId})");
            // Enqueue the problem
            _jobManager.Enqueue(calc);
            return(Ok(calc.Status));
        }
Esempio n. 5
0
        public async Task ThrowServiceException()
        {
            // arrange
            var exception = default(Exception);

            _endpoint = new HttpEndpoint
            {
                BaseAddress = "http://not-found.de/123",
                Request     = "",
                MethodName  = ""
            };

            // act
            try
            {
                _service = new GenericService(new HttpClient(), _endpoint);
                _service.CallResponded += (o, e) =>
                {
                    Log.Info($"Http responded with code: {e.StatusCode}");
                };
                var result = await _service.CallAsync <object>((s) => JsonIO.FromJsonString <object>(s));
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
                exception = ex;
            }

            // assert
            Assert.IsNotNull(exception);
        }
Esempio n. 6
0
        public static void LoadProxiesFromJson(string filePath)
        {
            List <Proxy> proxies = JsonIO.DeserializeObject <List <Proxy> >(filePath);

            ProxyManager.Proxies.Clear();
            ProxyManager.Proxies.AddRange(proxies);
        }
Esempio n. 7
0
        /// <summary>
        /// Converts the instance to a JSON string.
        /// </summary>
        /// <returns>The JSON string.</returns>
        public string WriteJson()
        {
            // Serialize
            string json = JsonIO.To(ToJsonInstance());

            // Return JSON string
            return(json);
        }
Esempio n. 8
0
        /// <summary>
        /// Reads an instance file from the given path.
        /// </summary>
        /// <param name="path">The path to the instance file</param>
        /// <returns>The read instance</returns>
        public static Instance ReadJson(string json)
        {
            // Deserialize JSON
            var jsonInstance = JsonIO.From <JsonInstance>(json);

            // Convert and return it
            return(FromJsonInstance(jsonInstance));
        }
Esempio n. 9
0
 public void SaveProfile(string profileName)
 {
     if (!Directory.Exists(FolderName))
     {
         Directory.CreateDirectory(FolderName);
     }
     ChangeFileName(profileName);
     JsonIO.Save(SavePath, profileData);
 }
Esempio n. 10
0
        /// <summary>
        /// プレイヤー情報をファイルに保存する。
        /// </summary>
        /// <param name="value">保存する情報</param>
        /// <param name="filePath">保存先ファイルパス</param>
        /// <remarks>非同期版</remarks>
        public static async Task SaveAsync(PlayerParameter value, string filePath)
        {
            // XML出力
            var xmlTask = XmlIO.WriteAsync(value, AddExtension(filePath, XmlIO.Extension));

            // JSON出力
            var jsonTask = JsonIO.WriteAsync(value, AddExtension(filePath, JsonIO.Extension));

            await Task.WhenAll(xmlTask, jsonTask);
        }
Esempio n. 11
0
    public static bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }
        FlagsForSerialization scr = JsonIO.JsonImport <FlagsForSerialization>(path, name);

        FlagField = scr.FlagField;
        return(true);
    }
Esempio n. 12
0
    //IJsonSaveLoadInitializable
    public bool JsonExport(string path, string name, bool overwrite)
    {
        string FilePath = path + "/" + name + ".json";

        if (File.Exists(FilePath) && !overwrite)
        {
            return(false);//(返り値なしだとエラーのため適当にしています.要修正)
        }
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        return(JsonIO.JsonExport(this, path, name));
    }
    public bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }
        ItemProperty ip = JsonIO.JsonImport <ItemProperty>(path, name);

        Name      = ip.Name;
        Attribute = ip.Attribute;

        return(true);
    }
Esempio n. 14
0
    public bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }

        SystemScript ss = JsonIO.JsonImport <SystemScript>(path, name);

        SpriteList    = ss?.SpriteList;
        MapChipPrefab = ss?.MapChipPrefab;
        return(true);
    }
Esempio n. 15
0
    public string InitialMapName = "MapDemo";//初期にロードするマップ名

    void Awake()
    {
        string DirectoryPath = SystemVariables.RootPath + "/Data";

        //JsonIO.JsonImport<SystemScript>(DirectoryPath, "System.json"); 現在読み込むべきシステム変数がないためコメントアウト
        SystemVariables.CopiedFrom(this);
        JsonIO.TiledJsonConvert();

        ///sprite読み込み///
        string jsonPath = SystemVariables.RootPath + "/TiledData";
        string jsonName = "MapDemo_Default";
        string tsxPath  = SystemVariables.RootPath + "/TiledData/tsx";

        LoadSpriteList(jsonPath, jsonName, tsxPath);
    }//Awake時にシステム関係(アイテム情報やマップチップ情報など)をロードして,SystemVariable.Initialize(this)で適用する.
Esempio n. 16
0
    public bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }
        MapControllScriptForSerialization mcss = JsonIO.JsonImport <MapControllScriptForSerialization>(path, name);

        MapName      = mcss.MapName;
        BuildingName = mcss.BuildingName;

        return(true);
    }
    public bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }
        ItemConversion ic = JsonIO.JsonImport <ItemConversion>(path, name);

        Name = ic.Name;
        ItemConversionRecipe = ic.ItemConversionRecipe;
        Attribute            = ic.Attribute;

        return(true);
    }
Esempio n. 18
0
        private void Window_Loaded(object sender, RoutedEventArgs e)//загрузка в модель из файла
        {
            jsn = new JsonIO(PATH);

            try
            {
                _todoData = jsn.LoadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Close();
            }

            ToDo_List.ItemsSource  = _todoData;
            _todoData.ListChanged += _todoData_ListChanged;
        }
Esempio n. 19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton <IJobManager, JobManager>();

            // Alter JSON behavior
            services.AddMvc().AddJsonOptions(options =>
            {
                JsonIO.SetJsonSerializerOptions(options.JsonSerializerOptions);
            });

            // Add swagger
            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "API", Version = "v1"
                }); });
        }
Esempio n. 20
0
    //IJsonSaveLoadable
    public static bool JsonExport(string path, string name, bool overwrite)
    {
        string filePath = path + "/" + name + ".json";

        if (File.Exists(filePath) && !overwrite)
        {
            return(false);
        }
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        FlagsForSerialization exporter = new FlagsForSerialization();

        exporter.FlagField = FlagField;

        return(JsonIO.JsonExport(exporter, path, name));
    }
Esempio n. 21
0
    public static List <Tuple <int, List <string> > > MapchipSourceImportFromTiled(string jsonPath, string jsonName, string tsxPath)
    {
        var tilesets    = JsonIO.JsonImport <TileMapData>(jsonPath, jsonName).Tilesets;
        var resultArray = new List <Tuple <int, List <string> > >();

        foreach (var ts in tilesets)
        {
            string[] s = ts.Source.Split('.');//拡張子(.tsx)を取り除くため分割

            if (s.Length != 2 || s[1] != "tsx")
            {
                throw new FormatException($"{jsonPath}/{jsonName}.json内のtileset.sourceの形式が不正です。tileset.source:{ts.Source}");
            }
            string tsxName = s[0];
            resultArray.Add(new Tuple <int, List <string> >(ts.FirstGId, TsxImageSourceImportFromTiled(tsxPath, tsxName)));
        }
        return(resultArray);
    }
Esempio n. 22
0
    public bool JsonImport(string path, string name)
    {
        string FilePath = path + "/" + name + ".json";

        if (!File.Exists(FilePath))
        {
            return(false);
        }
        MapBuildingScriptForSerialization scr = JsonIO.JsonImport <MapBuildingScriptForSerialization>(path, name);

        Origin                = scr.Origin;
        BuildingName          = scr.BuildingName;
        Status                = scr.Status;
        MapChipIDField_Width  = scr.MapChipIDField_Width;
        MapChipIDField_Height = scr.MapChipIDField_Height;
        MapChipIDField        = scr.MapChipIDField;
        CollisionField        = scr.CollisionField;
        return(true);
    }
Esempio n. 23
0
        private static void Execute(Options opts)
        {
            // Read input file (either from file or from stdin)
            var instance = JsonIO.From <JsonCalculation>(string.IsNullOrWhiteSpace(opts.Input) ? Console.In.ReadToEnd() : File.ReadAllText(opts.Input));

            // >> Run calculation
            Action <string> logger = string.IsNullOrWhiteSpace(opts.Output) ? null : Console.Write;
            var             result = Executor.Execute(Instance.FromJsonInstance(instance.Instance), instance.Configuration, logger);

            // Output result
            if (string.IsNullOrWhiteSpace(opts.Output))
            {
                Console.WriteLine(JsonIO.To(result.Solution.ToJsonSolution()));
            }
            else
            {
                File.WriteAllText(opts.Output, JsonIO.To(result.Solution.ToJsonSolution()));
            }
        }
Esempio n. 24
0
    public Dictionary <string, MapBuildingScript> Buildings; //キー: 建物名, 値: 対応するMapBuildingScriptとする.

    //IJsonSaveLoadable
    public bool JsonExport(string path, string name, bool overwrite)
    {
        string filePath = path + "/" + name + ".json";

        if (File.Exists(filePath) && !overwrite)
        {
            return(false);
        }
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        MapControllScriptForSerialization mcss = new MapControllScriptForSerialization();

        mcss.MapName      = MapName;
        mcss.BuildingName = BuildingName;

        return(JsonIO.JsonExport(mcss, path, name));
    }
Esempio n. 25
0
        /// <summary>
        /// Führt die Kernfunktion des Exports aus und gibt bei erfolgreichen Export den kompletten Pfad aus. andernfalls null.
        /// </summary>
        /// <returns></returns>
        public string Export()
        {
            string file   = _setting.FullPath;
            string result = null;

            // restore path
            if (!string.IsNullOrEmpty(_setting.Location) &&
                !Directory.Exists(_setting.Location))
            {
                Directory.CreateDirectory(_setting.Location);
            }

            if (JsonIO.SaveToJson(_exportData, file, _setting.Binder))
            {
                result = file;
            }

            // done!
            Log.Info($"json export successfull for '{result}'");
            return(result);
        }
Esempio n. 26
0
        public async Task ServiceCallAsync()
        {
            // arrange
            _endpoint = new HttpEndpoint
            {
                BaseAddress = "https://api.abalin.net",
                Request     = "/get/today?country=de",
                MethodName  = "get"
            };
            _service = new GenericService(new HttpClient(), _endpoint);
            _service.CallResponded += (o, e) =>
            {
                Log.Info($"Http responded with code: {e.StatusCode}");
            };

            // act
            var result = await _service.CallAsync <object>((s) => JsonIO.FromJsonString <object>(s));

            // assert
            Assert.IsNotNull(result);
        }
Esempio n. 27
0
    //IJsonSaveLoadable
    public bool JsonExport(string path, string name, bool overwrite)
    {
        string filePath = path + "/" + name + ".json";

        if (File.Exists(filePath) && !overwrite)
        {
            return(false);
        }
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        MapBuildingScriptForSerialization exporter = new MapBuildingScriptForSerialization();

        exporter.Origin                = Origin;
        exporter.BuildingName          = BuildingName;
        exporter.Status                = Status;
        exporter.MapChipIDField_Width  = MapChipIDField_Width;
        exporter.MapChipIDField_Height = MapChipIDField_Height;
        exporter.MapChipIDField        = MapChipIDField;
        exporter.CollisionField        = CollisionField;

        return(JsonIO.JsonExport(exporter, path, name));
    }
    public void LoadItemConversionInfo()
    {
        RecipesItemConversionAll = new LinkedList <ItemConversion>();
        RecipesItemConversion    = new Dictionary <string, LinkedList <ItemConversion> >();

        DirectoryInfo dir = new DirectoryInfo(SystemVariables.RootPath + "/Data/Item/ItemConversion");

        FileInfo[] info = dir.GetFiles("*.json");

        foreach (FileInfo f in info)
        {
            string         name = Path.GetFileNameWithoutExtension(f.Name);
            ItemConversion ic   = JsonIO.JsonImport <ItemConversion>(SystemVariables.RootPath + "/Data/Item/ItemConversion", name);
            RecipesItemConversionAll.AddLast(ic);
            foreach (var i in ic.Attribute)
            {
                if (!RecipesItemConversion.ContainsKey(i))
                {
                    RecipesItemConversion.Add(i, new LinkedList <ItemConversion>());
                }
                RecipesItemConversion[i].AddLast(ic);
            }
        }
    }
Esempio n. 29
0
 public static void SaveProxiesToJson(string filePath)
 {
     JsonIO.SaveObject(filePath, ProxyManager.Proxies);
 }
Esempio n. 30
0
 private static void SaveContentManifest()
 {
     JsonIO.Save(manifest, PathUtils.GetLocalPath(content_path, "content.json"));
 }