Exemplo 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();
            }
        }
Exemplo 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);
            }
        }
Exemplo 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");
            }
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo n.º 6
0
        public static void LoadProxiesFromJson(string filePath)
        {
            List <Proxy> proxies = JsonIO.DeserializeObject <List <Proxy> >(filePath);

            ProxyManager.Proxies.Clear();
            ProxyManager.Proxies.AddRange(proxies);
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo n.º 9
0
 public void SaveProfile(string profileName)
 {
     if (!Directory.Exists(FolderName))
     {
         Directory.CreateDirectory(FolderName);
     }
     ChangeFileName(profileName);
     JsonIO.Save(SavePath, profileData);
 }
Exemplo 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);
        }
Exemplo 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);
    }
Exemplo 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);
    }
Exemplo 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);
    }
Exemplo 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)で適用する.
Exemplo 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);
    }
Exemplo 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;
        }
Exemplo 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"
                }); });
        }
Exemplo 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));
    }
Exemplo 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);
    }
Exemplo 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);
    }
Exemplo 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()));
            }
        }
Exemplo 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));
    }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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));
    }
Exemplo n.º 28
0
    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);
            }
        }
    }
Exemplo n.º 29
0
 public static void SaveProxiesToJson(string filePath)
 {
     JsonIO.SaveObject(filePath, ProxyManager.Proxies);
 }
Exemplo n.º 30
0
 private static void SaveContentManifest()
 {
     JsonIO.Save(manifest, PathUtils.GetLocalPath(content_path, "content.json"));
 }