internal static BackSyncCookieWriter Create(Type cookieType) { int num = 0; BackSyncCookieAttribute[] cookieAttributeDefinitions = null; ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "Cookie Type {0}", cookieType.Name); BackSyncCookieAttribute.CreateBackSyncCookieAttributeDefinitions(null, cookieType, out num, out cookieAttributeDefinitions); return(new BackSyncCookieWriter(cookieAttributeDefinitions)); }
// Token: 0x060061F2 RID: 25074 RVA: 0x0014F300 File Offset: 0x0014D500 internal static BackSyncCookieReader Create(byte[] binaryCookie, Type cookieType) { int attributeCount = 0; BackSyncCookieAttribute[] cookieAttributeDefinitions = null; ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "Cookie Type {0}", cookieType.Name); BackSyncCookieAttribute.CreateBackSyncCookieAttributeDefinitions(binaryCookie, cookieType, out attributeCount, out cookieAttributeDefinitions); return(new BackSyncCookieReader(attributeCount, cookieAttributeDefinitions, binaryCookie)); }
// Token: 0x060061E7 RID: 25063 RVA: 0x0014EEB8 File Offset: 0x0014D0B8 internal static void CreateBackSyncCookieAttributeDefinitions(byte[] binaryCookie, Type cookieType, out int cookieAttributeCount, out BackSyncCookieAttribute[] backSyncCookieAttributeDefinitions) { BackSyncCookieAttribute[][] array = null; int num = 0; if (cookieType.Equals(typeof(BackSyncCookie))) { array = BackSyncCookie.BackSyncCookieAttributeSchemaByVersions; num = 4; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema BackSyncCookie.BackSyncCookieAttributeSchemaByVersions"); } else if (cookieType.Equals(typeof(ObjectFullSyncPageToken))) { array = ObjectFullSyncPageToken.ObjectFullSyncPageTokenAttributeSchemaByVersions; num = 2; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema ObjectFullSyncPageToken.ObjectFullSyncPageTokenAttributeSchemaByVersions"); } else if (cookieType.Equals(typeof(TenantFullSyncPageToken))) { array = TenantFullSyncPageToken.TenantFullSyncPageTokenAttributeSchemaByVersions; num = 3; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema TenantFullSyncPageToken.TenantFullSyncPageTokenAttributeSchemaByVersions"); } else if (cookieType.Equals(typeof(FullSyncObjectCookie))) { array = FullSyncObjectCookie.FullSyncObjectCookieAttributeSchemaByVersions; num = 1; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema FullSyncObjectCookie.FullSyncObjectCookieAttributeSchemaByVersions"); } else if (cookieType.Equals(typeof(MergePageToken))) { array = MergePageToken.MergePageTokenAttributeSchemaByVersions; num = 2; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema MergePageToken.MergePageTokenAttributeSchemaByVersions"); } else if (cookieType.Equals(typeof(TenantRelocationSyncPageToken))) { array = TenantRelocationSyncPageToken.TenantRelocationSyncPageTokenAttributeSchemaByVersions; num = 1; ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Cookie schema TenantRelocationSyncPageToken.TenantRelocationSyncPageTokenAttributeSchemaByVersions"); } else { ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "Invalid cookie type {0}", cookieType.Name); } ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Cookie schema attribute version count = {0}", array.Length); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Cookie schema current version (version starts from 0) = {0}", num); int num2 = num; if (binaryCookie != null) { ServiceInstanceId arg; BackSyncCookieAttribute.ReadCookieVersion(binaryCookie, out num2, out arg); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Binary cookie version = {0}", num2); ExTraceGlobals.BackSyncTracer.TraceDebug <ServiceInstanceId>((long)SyncConfiguration.TraceId, "Binary cookie service instance id = {0}", arg); if (num2 < 0) { ExTraceGlobals.BackSyncTracer.TraceError((long)SyncConfiguration.TraceId, "Cookie version is less than zero"); throw new InvalidCookieException(); } num2 = Math.Min(num2, num); } ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Parse cookie using version {0}", num2); int num3 = 0; int num4 = 0; List <BackSyncCookieAttribute> list = new List <BackSyncCookieAttribute>(); foreach (BackSyncCookieAttribute[] array3 in array) { ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Add attribute from cookie schema version {0}", num4); foreach (BackSyncCookieAttribute backSyncCookieAttribute in array3) { ExTraceGlobals.BackSyncTracer.TraceDebug <string, string>((long)SyncConfiguration.TraceId, "Add attribute {0} ({1})", backSyncCookieAttribute.Name, backSyncCookieAttribute.DataType.Name); list.Add(backSyncCookieAttribute); if (num4 <= num2) { num3++; ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Attribute count = {0}", num3); } } num4++; } ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "Return attribute count = {0}", num3); cookieAttributeCount = num3; backSyncCookieAttributeDefinitions = list.ToArray(); }
internal void WriteNextAttributeValue(object attributeValue) { ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Write next attribute value"); BackSyncCookieAttribute backSyncCookieAttribute = this.attributeDefinitions[this.currentAttributeIndex]; ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "Attribute {0}", backSyncCookieAttribute.ToString()); if (backSyncCookieAttribute.DataType.Equals(typeof(int))) { this.cookieBinaryWriter.Write((int)attributeValue); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Int32) = {0}", new object[] { attributeValue }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(long))) { this.cookieBinaryWriter.Write((long)attributeValue); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Int64) = {0}", new object[] { attributeValue }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(bool))) { this.cookieBinaryWriter.Write((bool)attributeValue); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Boolean) = {0}", new object[] { attributeValue }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(Guid))) { Guid arg = (Guid)attributeValue; this.cookieBinaryWriter.Write(arg.ToByteArray()); ExTraceGlobals.BackSyncTracer.TraceDebug <Guid>((long)SyncConfiguration.TraceId, "attributeValue (Guid) = {0}", arg); } else if (backSyncCookieAttribute.DataType.Equals(typeof(string))) { if (attributeValue != null) { this.cookieBinaryWriter.Write((string)attributeValue); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (string) = {0}", new object[] { attributeValue }); } else { this.cookieBinaryWriter.Write(string.Empty); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (string) = \"\""); } } else if (backSyncCookieAttribute.DataType.Equals(typeof(byte[]))) { if (attributeValue != null) { byte[] array = (byte[])attributeValue; this.cookieBinaryWriter.Write(array.Length); this.cookieBinaryWriter.Write(array); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "attributeValue (byte[]) size = {0}", array.Length); ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, " Base64String {0}", Convert.ToBase64String(array)); } else { this.cookieBinaryWriter.Write(0); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (byte[]) size = 0"); } } else { if (!backSyncCookieAttribute.DataType.Equals(typeof(string[]))) { ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "Invalid attribute data type {0}", backSyncCookieAttribute.DataType.Name); throw new InvalidCookieException(); } if (attributeValue != null) { string[] array2 = (string[])attributeValue; this.cookieBinaryWriter.Write(array2.Length); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "attributeValue (string[]) size = {0}", array2.Length); foreach (string text in array2) { this.cookieBinaryWriter.Write(text); ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, " value[] = \"{0}\"", text); } } else { this.cookieBinaryWriter.Write(0); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (string[]) size = 0"); } } this.currentAttributeIndex++; }
// Token: 0x060061F5 RID: 25077 RVA: 0x0014F3B4 File Offset: 0x0014D5B4 internal object GetNextAttributeValue() { ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "Get next attribute value"); BackSyncCookieAttribute backSyncCookieAttribute = this.attributeDefinitions[this.currentAttributeIndex]; ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, "Attribute {0}", backSyncCookieAttribute.ToString()); object obj = backSyncCookieAttribute.DefaultValue; ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "this.cookieAttributeCount = {0}", this.cookieAttributeCount); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "this.currentAttributeIndex = {0}", this.currentAttributeIndex); if (this.currentAttributeIndex < this.cookieAttributeCount) { if (backSyncCookieAttribute.DataType.Equals(typeof(int))) { obj = this.cookieBinaryReader.ReadInt32(); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Int32) = {0}", new object[] { obj }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(long))) { obj = this.cookieBinaryReader.ReadInt64(); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Int64) = {0}", new object[] { obj }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(bool))) { obj = this.cookieBinaryReader.ReadBoolean(); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Boolean) = {0}", new object[] { obj }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(Guid))) { obj = new Guid(this.cookieBinaryReader.ReadBytes(16)); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (Guid) = {0}", new object[] { obj }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(string))) { obj = this.cookieBinaryReader.ReadString(); ExTraceGlobals.BackSyncTracer.TraceDebug((long)SyncConfiguration.TraceId, "attributeValue (string) = {0}", new object[] { obj }); } else if (backSyncCookieAttribute.DataType.Equals(typeof(byte[]))) { int num = this.cookieBinaryReader.ReadInt32(); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "attributeValue (bypte[]) size = {0}", num); if (num > 0) { obj = this.cookieBinaryReader.ReadBytes(num); ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, " Base64String {0}", Convert.ToBase64String((byte[])obj)); } else { obj = null; } } else { if (!backSyncCookieAttribute.DataType.Equals(typeof(string[]))) { ExTraceGlobals.BackSyncTracer.TraceError <string>((long)SyncConfiguration.TraceId, "Invalid attribute data type {0}", backSyncCookieAttribute.DataType.Name); throw new InvalidCookieException(); } int num2 = this.cookieBinaryReader.ReadInt32(); ExTraceGlobals.BackSyncTracer.TraceDebug <int>((long)SyncConfiguration.TraceId, "attributeValue (string[]) size = {0}", num2); if (num2 > 0) { List <string> list = new List <string>(); for (int i = 0; i < num2; i++) { string text = this.cookieBinaryReader.ReadString(); ExTraceGlobals.BackSyncTracer.TraceDebug <int, string>((long)SyncConfiguration.TraceId, " value[{0}] = \"{1}\"", i, text); list.Add(text); } obj = list.ToArray(); } else { obj = null; } } } else { obj = backSyncCookieAttribute.DefaultValue; ExTraceGlobals.BackSyncTracer.TraceDebug <string>((long)SyncConfiguration.TraceId, " attributeValue (Default) = {0}", (obj != null) ? obj.ToString() : "NULL"); } this.currentAttributeIndex++; return(obj); }