Example #1
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);
            }
        }
Example #2
0
 public ClogSidecar_V2()
 {
     Version          = 2;
     ModuleUniqueness = new CLogModuleUsageInformation_V2();
 }