Пример #1
0
        public static CLogSidecar FromJson(string json)
        {
            ClogSidecar_V2 me  = ClogSidecar_V2.FromJson(json);
            CLogSidecar    ret = new CLogSidecar(me);

            return(ret);
        }
Пример #2
0
        public static ClogSidecar_V2 FromJson(string json)
        {
            try
            {
                JsonSerializerSettings s = new JsonSerializerSettings();
                s.Context = new StreamingContext(StreamingContextStates.Other, json);

                ClogSidecar_V2 ret = JsonConvert.DeserializeObject <ClogSidecar_V2>(json, s);

                if (1 == ret.Version)
                {
                    ClogSidecar_V1 v1 = ClogSidecar_V1.FromJson(json);
                    ret                  = new ClogSidecar_V2();
                    ret.Version          = 2;
                    ret.EventBundlesV2   = v1.EventBundlesV2;
                    ret.ConfigFile       = v1.ConfigFile;
                    ret.ModuleUniqueness = CLogModuleUsageInformation_V2.ConvertFromV1(v1.ModuleUniqueness);
                }

                if (2 != ret.Version)
                {
                    throw new CLogEnterReadOnlyModeException($"Invalid sidecar file version {ret.Version}, our max version is 2 - consider updating CLOG", CLogHandledException.ExceptionType.SidecarFileVersionMismatch, null);
                }
                return(ret);
            }
            catch (System.Exception e)
            {
                throw new CLogEnterReadOnlyModeException($"Invalid sidecar file version - it looks corrupted", CLogHandledException.ExceptionType.SidecarCorrupted, null, e);
            }
        }
Пример #3
0
 private CLogSidecar(ClogSidecar_V2 me)
 {
     SetSideCar(me);
 }
Пример #4
0
 private void SetSideCar(ClogSidecar_V2 file)
 {
     _sideCarFile       = file;
     _myUsageModuleInfo = new CLogModuleUsageInformation(file.ModuleUniqueness);
 }