public ContractResolver(IFactory entityFactory, IKnownSerializationTypes knowTypes) { _entityFactory = entityFactory; _knowTypes = knowTypes; foreach (Type type in ReflectTypes().Concat(_knowTypes.GetKnownTypes())) { string typeNamespace = GetNamespace(type); string typeName = GetName(type); _typeToNames[type] = new Tuple <string, string>(typeNamespace, typeName); if (_namesToType.ContainsKey(typeNamespace) == false) { _namesToType[typeNamespace] = new Dictionary <string, Type>(); } _namesToType[typeNamespace][typeName] = type; } }
public ContractResolver(IFactory entityFactory, IKnownSerializationTypes knowTypes) { _entityFactory = entityFactory; _knowTypes = knowTypes; foreach (Type type in ReflectTypes().Concat(_knowTypes.GetKnownTypes())) { string typeNamespace = GetNamespace(type); string typeName = GetName(type); _typeToNames[type] = new Tuple<string, string>(typeNamespace, typeName); if (_namesToType.ContainsKey(typeNamespace) == false) { _namesToType[typeNamespace] = new Dictionary<string, Type>(); } _namesToType[typeNamespace][typeName] = type; } }
public static T DeepClone <T>(this T obj, IKnownSerializationTypes knownTypes) { if (knownTypes == null) { throw new ArgumentNullException("knownTypes"); } T cloned = default(T); var serializer = new DataContractSerializer(typeof(T), knownTypes.GetKnownTypes(), maxItemsInObjectGraph: 0x7FFF, ignoreExtensionDataObject: false, preserveObjectReferences: true, dataContractSurrogate: null); using (var ms = new System.IO.MemoryStream()) { serializer.WriteObject(ms, obj); ms.Seek(0, System.IO.SeekOrigin.Begin); cloned = (T)serializer.ReadObject(ms); } return(cloned); }
public DataContractSurrogate(IFactory entityFactory, IKnownSerializationTypes knowTypes) { _entityFactory = entityFactory; _knowTypes = knowTypes; }