Example #1
0
 public void Init(string rawJson)
 {
     if (!_inited)
     {
         lock (_locker) {
             if (!_inited)
             {
                 if (!string.IsNullOrEmpty(rawJson))
                 {
                     try {
                         ServerJson data = Global.JsonSerializer.Deserialize <ServerJson>(rawJson);
                         this.Coins                   = data.Coins ?? new CoinData[0];
                         this.Groups                  = data.Groups ?? new GroupData[0];
                         this.CoinGroups              = data.CoinGroups ?? new CoinGroupData[0];
                         this.CoinKernels             = data.CoinKernels ?? new CoinKernelData[0];
                         this.Kernels                 = data.Kernels ?? new KernelData[0];
                         this.KernelInputs            = data.KernelInputs ?? new KernelInputData[0];
                         this.KernelOutputs           = data.KernelOutputs ?? new KernelOutputData[0];
                         this.KernelOutputFilters     = data.KernelOutputFilters ?? new KernelOutputFilterData[0];
                         this.KernelOutputTranslaters = data.KernelOutputTranslaters ?? new KernelOutputTranslaterData[0];
                         this.Pools                   = data.Pools ?? new PoolData[0];
                         this.SysDics                 = data.SysDics ?? new SysDicData[0];
                         this.SysDicItems             = data.SysDicItems ?? new SysDicItemData[0];
                         this.TimeStamp               = data.TimeStamp;
                         File.WriteAllText(SpecialPath.LocalJsonFileFullName, rawJson);
                     }
                     catch (Exception e) {
                         Global.Logger.ErrorDebugLine(e.Message, e);
                     }
                 }
                 _inited = true;
             }
         }
     }
 }
 static ReadOnlyServerRepository()
 {
     if (!File.Exists(SpecialPath.NTMinerJsonFileFullName))
     {
         data = new ServerJson();
     }
     else
     {
         data = Global.JsonSerializer.Deserialize <ServerJson>(File.ReadAllText(SpecialPath.NTMinerJsonFileFullName));
     }
 }
Example #3
0
        public static void Export()
        {
            INTMinerRoot root = NTMinerRoot.Current;
            ServerJson   data = new ServerJson()
            {
                CoinKernels             = root.CoinKernelSet.Cast <CoinKernelData>().ToList(),
                Coins                   = root.CoinSet.Cast <CoinData>().ToList(),
                Groups                  = root.GroupSet.Cast <GroupData>().ToList(),
                CoinGroups              = root.CoinGroupSet.Cast <CoinGroupData>().ToList(),
                KernelOutputFilters     = root.KernelOutputFilterSet.Cast <KernelOutputFilterData>().ToList(),
                KernelOutputTranslaters = root.KernelOutputTranslaterSet.Cast <KernelOutputTranslaterData>().ToList(),
                Kernels                 = root.KernelSet.Cast <KernelData>().ToList(),
                Pools                   = root.PoolSet.Cast <PoolData>().ToList(),
                SysDicItems             = root.SysDicItemSet.Cast <SysDicItemData>().ToList(),
                SysDics                 = root.SysDicSet.Cast <SysDicData>().ToList()
            };
            string json = Global.JsonSerializer.Serialize(data);

            File.WriteAllText(SpecialPath.ServerJsonFileFullName, json);
        }