//#region Generic //public static object FromBytes<T>(this object value, byte[] bytes, ref int position) //{ // if (typeof(T) == typeof(long?)) // { // return ((long?)value).FromBytes(bytes, ref position); // } // if (typeof(T) == typeof(int?)) // { // return ((int?)value).FromBytes(bytes, ref position); // } // return ((TLObject)value).FromBytes(bytes, ref position); //} //public static byte[] ToBytes(this object value) //{ // if (value is long?) // { // return BitConverter.GetBytes((long?)value ?? 0); // } // if (value is int?) // { // return BitConverter.GetBytes((int?)value ?? 0); // } // return ((TLObject)value).ToBytes(); //} //public static object FromStream<T>(this object value, Stream input) //{ // if (typeof(T) == typeof(long?)) // { // var buffer = new byte[8]; // input.Read(buffer, 0, 8); // value = BitConverter.ToInt64(buffer, 0); // return value; // } // if (typeof(T) == typeof(int?)) // { // var buffer = new byte[4]; // input.Read(buffer, 0, 4); // value = BitConverter.ToInt32(buffer, 0); // return value; // } // return ((TLObject)value).FromStream(input); //} //public static void ToStream(this object value, Stream output) //{ // if (value is long?) // { // output.Write(BitConverter.GetBytes((long?)value ?? 0), 0, 8); // return; // } // else if (value is int?) // { // output.Write(BitConverter.GetBytes((int?)value ?? 0), 0, 4); // return; // } // ((TLObject)value).ToStream(output); //} //#endregion public static TLConfig Merge(TLConfig oldConfig, TLCdnConfig cdnConfig) { foreach (var dcOption in oldConfig.DCOptions) { if (dcOption.IsCdn) { var keys = new List <string>(); foreach (var newDCOption in cdnConfig.PublicKeys.Where(x => x.DCId.Equals(dcOption.Id))) { keys.Add(newDCOption.PublicKey); } dcOption.PublicKeys = keys.Count > 0 ? keys.ToArray() : null; } } return(oldConfig); }
public override void DeserializeResponse(BinaryReader br) { Response = (TLCdnConfig)ObjectUtils.DeserializeObject(br); }