private static ITLPropertySerializationAgent[] CreateSerializationAgents(IEnumerable <TLPropertyInfo> tlPropertyInfos, TLSerializersBucket serializersBucket) { return(tlPropertyInfos.OrderBy(info => info.Order).Distinct().Select( tlPropertyInfo => { PropertyInfo propertyInfo = tlPropertyInfo.PropertyInfo; Type propType = propertyInfo.PropertyType; ITLPropertySerializationAgent serializationAgent; if (propType == typeof(object)) { /* * https://core.telegram.org/mtproto/serialize#object-pseudotype * Object Pseudotype * The Object pseudotype is a “type” which can take on values that belong to any boxed type in the schema. */ serializationAgent = new TLObjectPropertySerializationAgent(tlPropertyInfo); } else { ITLSerializer tlSerializer = serializersBucket[propType]; Debug.Assert(tlSerializer != null); var vectorSerializer = tlSerializer as ITLVectorSerializer; if (vectorSerializer != null) { TLSerializationMode?itemsSerializationModeOverride = GetVectorItemsSerializationModeOverride( vectorSerializer, propertyInfo, serializersBucket); serializationAgent = new TLVectorPropertySerializationAgent(tlPropertyInfo, vectorSerializer, itemsSerializationModeOverride); } else { serializationAgent = new TLPropertySerializationAgent(tlPropertyInfo, tlSerializer); } } return serializationAgent; }).ToArray()); }
private static ITLPropertySerializationAgent[] CreateSerializationAgents(IEnumerable<TLPropertyInfo> tlPropertyInfos, TLSerializersBucket serializersBucket) { return tlPropertyInfos.OrderBy(info => info.Order).Distinct().Select( tlPropertyInfo => { PropertyInfo propertyInfo = tlPropertyInfo.PropertyInfo; Type propType = propertyInfo.PropertyType; ITLPropertySerializationAgent serializationAgent; if (propType == typeof (object)) { /* * https://core.telegram.org/mtproto/serialize#object-pseudotype * Object Pseudotype * The Object pseudotype is a “type” which can take on values that belong to any boxed type in the schema. */ serializationAgent = new TLObjectPropertySerializationAgent(tlPropertyInfo); } else { ITLSerializer tlSerializer = serializersBucket[propType]; Debug.Assert(tlSerializer != null); var vectorSerializer = tlSerializer as ITLVectorSerializer; if (vectorSerializer != null) { TLSerializationMode? itemsSerializationModeOverride = GetVectorItemsSerializationModeOverride( vectorSerializer, propertyInfo, serializersBucket); serializationAgent = new TLVectorPropertySerializationAgent(tlPropertyInfo, vectorSerializer, itemsSerializationModeOverride); } else { serializationAgent = new TLPropertySerializationAgent(tlPropertyInfo, tlSerializer); } } return serializationAgent; }).ToArray(); }