internal XmlObjectSerializerReadContextComplex(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver) : base(serializer, rootTypeDataContract, dataContractResolver) { this.mode = SerializationMode.SharedContract; this.preserveObjectReferences = serializer.PreserveObjectReferences; this.dataContractSurrogate = serializer.DataContractSurrogate; }
internal static object GetCustomDataToExport(IDataContractSurrogate surrogate, Type clrType, Type dataContractType) { if (DataContract.GetBuiltInDataContract(clrType) != null) { return null; } return surrogate.GetCustomDataToExport(clrType, dataContractType); }
internal static Type GetReferencedTypeOnImport(IDataContractSurrogate surrogate, string typeName, string typeNamespace, object customData) { if (DataContract.GetBuiltInDataContract(typeName, typeNamespace) != null) { return null; } return surrogate.GetReferencedTypeOnImport(typeName, typeNamespace, customData); }
public DataContractJsonSerializerOperationBehavior(OperationDescription description, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) : base(description) { this.MaxItemsInObjectGraph = maxItemsInObjectGraph; this.IgnoreExtensionDataObject = ignoreExtensionDataObject; this.DataContractSurrogate = dataContractSurrogate; this.alwaysEmitTypeInformation = alwaysEmitTypeInformation; }
internal static object GetDeserializedObject(IDataContractSurrogate surrogate, object obj, Type objType, Type memberType) { if (obj == null) return null; if (DataContract.GetBuiltInDataContract(objType) != null) return obj; return surrogate.GetDeserializedObject(obj, memberType); }
internal static Type GetDataContractType(IDataContractSurrogate surrogate, Type type) { if (DataContract.GetBuiltInDataContract(type) != null) return type; Type dcType = surrogate.GetDataContractType(type); if (dcType == null) return type; return dcType; }
public DataContractSerializer(Type type, string rootName, string rootNamespace, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) : this(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, null) { }
public DataContractJsonSerializer(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { EmitTypeInformation emitTypeInformation = alwaysEmitTypeInformation ? EmitTypeInformation.Always : EmitTypeInformation.AsNeeded; Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, emitTypeInformation, false, null, false); }
public DataContractSerializer(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) { Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, false); }
public DataContractJsonSerializer(Type type, string rootName, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { EmitTypeInformation emitTypeInformation = alwaysEmitTypeInformation ? EmitTypeInformation.Always : EmitTypeInformation.AsNeeded; XmlDictionary dictionary = new XmlDictionary(2); Initialize(type, dictionary.Add(rootName), knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, emitTypeInformation, false, null, false); }
internal static object GetObjectToSerialize(IDataContractSurrogate surrogate, object obj, Type objType, Type membertype) { if (obj == null) { return null; } if (DataContract.GetBuiltInDataContract(objType) != null) { return obj; } return surrogate.GetObjectToSerialize(obj, membertype); }
public static object Deserialize (XmlReader reader, Type declaredType, KnownTypeCollection knownTypes, IDataContractSurrogate surrogate, DataContractResolver resolver, DataContractResolver defaultResolver, string name, string ns, bool verifyObjectName) { reader.MoveToContent (); if (verifyObjectName) if (reader.NodeType != XmlNodeType.Element || reader.LocalName != name || reader.NamespaceURI != ns) throw new SerializationException (String.Format ("Expected element '{0}' in namespace '{1}', but found {2} node '{3}' in namespace '{4}'", name, ns, reader.NodeType, reader.LocalName, reader.NamespaceURI)); // Verify (knownTypes, declaredType, name, ns, reader); return new XmlFormatterDeserializer (knownTypes, surrogate, resolver, defaultResolver).Deserialize (declaredType, reader); }
public static void AddDataContractSurrogate(this ServiceHostBase host, IDataContractSurrogate surrogate) { foreach (var endpoint in host.Description.Endpoints) { foreach (var operation in endpoint.Contract.Operations) { var dc = operation.Behaviors.Find<DataContractSerializerOperationBehavior>(); if (dc != null) { dc.DataContractSurrogate = surrogate; } } } var exporter = host.GetXsdDataContractExporter(); if (exporter != null) { exporter.Options.DataContractSurrogate = surrogate; } }
private void ConfigureOperationDescriptionBehaviors(OperationDescription operation, IDataContractSurrogate contractSurrogate) { DataContractSerializerOperationBehavior item = new DataContractSerializerOperationBehavior(operation, TypeLoader.DefaultDataContractFormatAttribute); if (contractSurrogate != null) { item.DataContractSurrogate = contractSurrogate; } operation.Behaviors.Add(item); operation.Behaviors.Add(new OperationInvokerBehavior()); if ((this.info.TransactionOption == TransactionOption.Supported) || (this.info.TransactionOption == TransactionOption.Required)) { operation.Behaviors.Add(new TransactionFlowAttribute(TransactionFlowOption.Allowed)); } OperationBehaviorAttribute attribute = new OperationBehaviorAttribute { TransactionAutoComplete = true, TransactionScopeRequired = false }; operation.Behaviors.Add(attribute); }
public SingleBodyParameterDataContractMessageFormatter(OperationDescription operation, Type parameterType, bool isRequestFormatter, bool useJsonFormat, DataContractSerializerOperationBehavior dcsob) : base(operation, isRequestFormatter, "DataContractSerializer") { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parameterType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameterType"); } if (dcsob == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dcsob"); } this.parameterDataContractType = DataContractSerializerOperationFormatter.GetSubstituteDataContractType(parameterType, out isQueryable); this.isParameterCollectionInterfaceDataContract = IsTypeCollectionInterface(this.parameterDataContractType); List<Type> tmp = new List<Type>(); if (operation.KnownTypes != null) { foreach (Type knownType in operation.KnownTypes) { tmp.Add(knownType); } } Type nullableType = UnwrapNullableType(this.parameterDataContractType); if (nullableType != this.parameterDataContractType) { tmp.Add(nullableType); } this.surrogate = dcsob.DataContractSurrogate; this.ignoreExtensionData = dcsob.IgnoreExtensionDataObject; this.maxItemsInObjectGraph = dcsob.MaxItemsInObjectGraph; this.knownTypes = tmp.AsReadOnly(); ValidateType(this.parameterDataContractType, surrogate, this.knownTypes); this.useJsonFormat = useJsonFormat; CreateInputSerializers(this.parameterDataContractType); thisLock = new Object(); }
internal DataContractSet(DataContractSet dataContractSet) { if (dataContractSet == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("dataContractSet")); } this.dataContractSurrogate = dataContractSet.dataContractSurrogate; this.referencedTypes = dataContractSet.referencedTypes; this.referencedCollectionTypes = dataContractSet.referencedCollectionTypes; foreach (KeyValuePair<XmlQualifiedName, DataContract> pair in dataContractSet) { this.Add(pair.Key, pair.Value); } if (dataContractSet.processedContracts != null) { foreach (KeyValuePair<DataContract, object> pair2 in dataContractSet.processedContracts) { this.ProcessedContracts.Add(pair2.Key, pair2.Value); } } }
public DataContractSurrogateBehavior(Type surrogateType) { if (typeof(IDataContractSurrogate).IsAssignableFrom(surrogateType) == false) { throw new ArgumentException(string.Format( "The data contract surrogate {0} does not implement {1}.", surrogateType.FullName, typeof(IDataContractSurrogate).FullName), "surrogateType"); } var surrogateCtor = surrogateType.GetConstructor(Type.EmptyTypes); if (surrogateCtor == null) { throw new ArgumentException(string.Format( "The data contract surrogate {0} does not have an empty public constructor.", surrogateType.FullName)); } surrogate = (IDataContractSurrogate)surrogateCtor.Invoke(new object[0]); }
internal DataContractSet(DataContractSet dataContractSet) { if (dataContractSet == null) throw Fx.Exception.AsError(new ArgumentNullException("dataContractSet")); this.dataContractSurrogate = dataContractSet.dataContractSurrogate; this.referencedTypes = dataContractSet.referencedTypes; this.referencedCollectionTypes = dataContractSet.referencedCollectionTypes; foreach (KeyValuePair<XmlQualifiedName, DataContract> pair in dataContractSet) { Add(pair.Key, pair.Value); } if (dataContractSet.processedContracts != null) { foreach (KeyValuePair<DataContract, object> pair in dataContractSet.processedContracts) { ProcessedContracts.Add(pair.Key, pair.Value); } } }
/// <summary> /// Create a new instance of a DataContractJsonSerializationProvider that uses an underlying /// DataContractJsonSerializer that is created with the supplied arguments. /// </summary> public DataContractJsonSerializationProvider(Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) : base(type, new DataContractJsonSerializer(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation)) { }
void Initialize(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver, bool serializeReadOnlyTypes) { CheckNull(type, "type"); this.rootType = type; if (knownTypes != null) { this.knownTypeList = new List<Type>(); foreach (Type knownType in knownTypes) { this.knownTypeList.Add(knownType); } } if (maxItemsInObjectGraph < 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxItemsInObjectGraph", SR.GetString(SR.ValueMustBeNonNegative))); this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.preserveObjectReferences = preserveObjectReferences; this.dataContractSurrogate = dataContractSurrogate; this.dataContractResolver = dataContractResolver; this.serializeReadOnlyTypes = serializeReadOnlyTypes; }
public DataContractJsonSerializer(Type type, XmlDictionaryString rootName, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { this.Initialize(type, rootName, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation); }
public DataContractSerializer(Type type, string rootName, string rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) { XmlDictionary dictionary = new XmlDictionary(2); this.Initialize(type, dictionary.Add(rootName), dictionary.Add(DataContract.GetNamespace(rootNamespace)), knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate); }
/// <summary> /// Create a new instance of a DataContractSerializationProvider that uses an underlying /// DataContractSerializer that is created with the supplied arguments. /// </summary> public DataContractSerializationProvider(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) : base(type, new DataContractSerializer(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver)) { }
internal static void GetKnownCustomDataTypes(IDataContractSurrogate surrogate, Collection <Type> customDataTypes) { surrogate.GetKnownCustomDataTypes(customDataTypes); }
static void Serialize <T>(T instance, string fileName, IList <Type> knownTypes, int maxItemsInObjectGraph = int.MaxValue, bool ignoreExtensionDataObject = false, bool preserveObjectReferences = false, IDataContractSurrogate surrogate = null) { var serializer = new DataContractSerializer(typeof(T), knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, surrogate); using (XmlWriter writer = new XmlTextWriter(fileName, Encoding.UTF8)) { serializer.WriteObject(writer, instance); } Process.Start(fileName); }
internal static Type GetSurrogatedType(IDataContractSurrogate dataContractSurrogate, Type type) { return(DataContractSurrogateCaller.GetDataContractType(dataContractSurrogate, DataContract.UnwrapNullableType(type))); }
internal void SetDataContractSurrogate(IDataContractSurrogate adapter) { dataContractSurrogate = adapter; }
/// <summary> /// Initializes a new instance of the <see cref="DataContractJsonRoundtripSerializer{T}"/> class. /// </summary> /// <param name="maxItemsInObjectGraph">The maximum number of items in the graph to serialize or deserialize. The default is <c>4</c>.</param> /// <param name="ignoreExtensionDataObject">true to ignore the <see cref="IExtensibleDataObject"/> interface upon serialization and ignore unexpected data upon deserialization; otherwise, false. The default is false.</param> /// <param name="dataContractSurrogate">An implementation of the <see cref="IDataContractSurrogate"/> to customize the serialization process.</param> /// <param name="alwaysEmitTypeInformation">true to emit type information; otherwise, false. The default is false.</param> public DataContractJsonRoundtripSerializer(int maxItemsInObjectGraph = 4, bool ignoreExtensionDataObject = false, IDataContractSurrogate dataContractSurrogate = null, bool alwaysEmitTypeInformation = false) { _stream = new MemoryStream(); _serializer = new DataContractJsonSerializer( typeof(T), new[] { typeof(T) }, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation);; }
private static DataContractSerializer CreateSerializer <T>(IDataContractSurrogate surrogate) { return(new DataContractSerializer(typeof(T), new Type[] { }, Int32.MaxValue, false, true, surrogate)); }
internal static CodeTypeDeclaration ProcessImportedType(IDataContractSurrogate surrogate, CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit) { return(surrogate.ProcessImportedType(typeDeclaration, compileUnit)); }
internal DataContractSet(IDataContractSurrogate dataContractSurrogate) : this(dataContractSurrogate, null, null) { }
internal DataContractSet(IDataContractSurrogate dataContractSurrogate, ICollection <Type> referencedTypes, ICollection <Type> referencedCollectionTypes) { _dataContractSurrogate = dataContractSurrogate; _referencedTypes = referencedTypes; _referencedCollectionTypes = referencedCollectionTypes; }
public DataContractSerializer(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, System.Runtime.Serialization.DataContractResolver dataContractResolver) : this(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate) { this.dataContractResolver = dataContractResolver; }
public DataContractSerializerBinary(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) { serializer = new DataContractSerializer(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate); InitNamespaces(type, knownTypes); }
internal static object GetCustomDataToExport(IDataContractSurrogate surrogate, MemberInfo memberInfo, Type dataContractType) { return(surrogate.GetCustomDataToExport(memberInfo, dataContractType)); }
private void Initialize(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) { this.Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate); this.rootName = rootName; this.rootNamespace = rootNamespace; }
/// <summary> /// Initializes a new instance of the <see cref="DataContractJsonDeserializer"/> class. /// </summary> /// <param name="maxItemsInObjectGraph">The maximum number of items in the graph to serialize or deserialize. The default is <c>4</c>.</param> /// <param name="ignoreExtensionDataObject">true to ignore the <see cref="IExtensibleDataObject"/> interface upon serialization and ignore unexpected data upon deserialization; otherwise, false. The default is false.</param> /// <param name="dataContractSurrogate">An implementation of the <see cref="IDataContractSurrogate"/> to customize the serialization process.</param> /// <param name="alwaysEmitTypeInformation">true to emit type information; otherwise, false. The default is false.</param> public DataContractJsonDeserializer(int maxItemsInObjectGraph = 4, bool ignoreExtensionDataObject = false, IDataContractSurrogate dataContractSurrogate = null, bool alwaysEmitTypeInformation = false) { _alwaysEmitTypeInformation = alwaysEmitTypeInformation; _ignoreExtensionDataObject = ignoreExtensionDataObject; _dataContractSurrogate = dataContractSurrogate; _maxItemsInObjectGraph = maxItemsInObjectGraph; }
/// <summary> /// Create a new instance of a DataContractSerializationProvider that uses an underlying /// DataContractSerializer that is created with the supplied arguments. /// </summary> public DataContractSerializationProvider(Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) : base(type, new DataContractSerializer(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate)) { }
internal static object SurrogateToDataContractType(IDataContractSurrogate dataContractSurrogate, object oldObj, Type surrogatedDeclaredType, ref Type objType) { object obj = DataContractSurrogateCaller.GetObjectToSerialize(dataContractSurrogate, oldObj, objType, surrogatedDeclaredType); if (obj != oldObj) { if (obj == null) objType = Globals.TypeOfObject; else objType = obj.GetType(); } return obj; }
ContractDescription CreateContractDescriptionInternal(Guid iid, Type type) { ComContractElement contractConfigElement = ConfigLoader.LookupComContract(iid); if (contractConfigElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.InterfaceNotFoundInConfig, iid))); } if (String.IsNullOrEmpty(contractConfigElement.Name) || String.IsNullOrEmpty(contractConfigElement.Namespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.CannotHaveNullOrEmptyNameOrNamespaceForIID, iid))); } ContractDescription contract = new ContractDescription(contractConfigElement.Name, contractConfigElement.Namespace); contract.ContractType = type; contract.SessionMode = contractConfigElement.RequiresSession ? SessionMode.Required : SessionMode.Allowed; bool methodFound = false; List <Guid> guidList = new List <Guid>(); foreach (ComPersistableTypeElement typeElement in contractConfigElement.PersistableTypes) { Guid typeGuid = Fx.CreateGuid(typeElement.ID); guidList.Add(typeGuid); } IDataContractSurrogate contractSurrogate = null; // We create a surrogate when the persistable types config section is there // even if we have no types that we allow. // That way we have control over the error when the client tries to make a call // persistable type. if (guidList.Count > 0 || contractConfigElement.PersistableTypes.EmitClear) { contractSurrogate = new DataContractSurrogateForPersistWrapper(guidList.ToArray()); } foreach (ComMethodElement configMethod in contractConfigElement.ExposedMethods) { methodFound = false; foreach (MethodInfo method in type.GetMethods()) { if (method.Name == configMethod.ExposedMethod) { OperationDescription operation = CreateOperationDescription(contract, method, contractConfigElement, (null != contractSurrogate)); ConfigureOperationDescriptionBehaviors(operation, contractSurrogate); contract.Operations.Add(operation); methodFound = true; break; } } if (!methodFound) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.MethodGivenInConfigNotFoundOnInterface, configMethod.ExposedMethod, iid))); } } if (contract.Operations.Count == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.NoneOfTheMethodsForInterfaceFoundInConfig, iid))); } ConfigureContractDescriptionBehaviors(contract); return(contract); }
private void Initialize(Type type, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { XmlObjectSerializer.CheckNull(type, "type"); this.rootType = type; if (knownTypes != null) { this.knownTypeList = new List<Type>(); foreach (Type type2 in knownTypes) { this.knownTypeList.Add(type2); if (type2 != null) { this.AddCollectionItemTypeToKnownTypes(type2); } } } if (maxItemsInObjectGraph < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxItemsInObjectGraph", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative"))); } this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.dataContractSurrogate = dataContractSurrogate; this.alwaysEmitTypeInformation = alwaysEmitTypeInformation; }
public DataContractSerializer(Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) { this.Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate); }
public DataContractJsonSerializer (Type type, string rootName, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) : this (type, rootName, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, alwaysEmitTypeInformation) { surrogate = dataContractSurrogate; }
public DataContractSerializer(Type type, string rootName, string rootNamespace, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) { XmlDictionary dictionary = new XmlDictionary(2); Initialize(type, dictionary.Add(rootName), dictionary.Add(DataContract.GetNamespace(rootNamespace)), knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, false); }
private void Initialize(Type type, XmlDictionaryString rootName, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { this.Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation); this.rootName = ConvertXmlNameToJsonName(rootName); this.rootNameRequiresMapping = CheckIfJsonNameRequiresMapping(this.rootName); }
public DataContractSerializer (Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable<Type> knownTypes, int maxObjectsInGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) : this (type, rootName, rootNamespace, knownTypes, maxObjectsInGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate) { DataContractResolver = dataContractResolver; }
public XmlCommentsDataSurrogate(IDataContractSurrogate prevSurrogate, XmlCommentFormat format) : this(prevSurrogate) { this.format = format; }
public DataContractJsonSerializer(Type type, XmlDictionaryString rootName, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) : this(type, rootName != null ? rootName.Value : default_root_name, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation) { }
void Initialize(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver, bool serializeReadOnlyTypes) { Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, serializeReadOnlyTypes); // validate root name and namespace are both non-null this.rootName = rootName; this.rootNamespace = rootNamespace; }
private static DataContractSerializer CreateDataContractSerializer(Type type, IDataContractSurrogate dataContractSurrogate) { IList <Type> knownTypes = new List <Type>() { typeof(InputFile), typeof(ColumnInfo), typeof(DataPacket), typeof(DataBlockBuilder.DataBlock), typeof(CodecStreamBuilder.CodecStream), typeof(FragmentContainer), typeof(DetectorDataContractSurrogate.DetectorSurrogate), typeof(CodecParametersBuilder.CodecParameters), typeof(ReferenceHeader), typeof(ReferenceHeaderFile), typeof(ReferenceHeaderDatabase), }; return(new DataContractSerializer(type, knownTypes, int.MaxValue, false, true, dataContractSurrogate)); }
internal static Type GetSurrogatedType(IDataContractSurrogate dataContractSurrogate, Type type) { return DataContractSurrogateCaller.GetDataContractType(dataContractSurrogate, DataContract.UnwrapNullableType(type)); }
private void Initialize(Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { XmlObjectSerializer.CheckNull(type, "type"); this.rootType = type; if (knownTypes != null) { this.knownTypeList = new List <Type>(); foreach (Type type2 in knownTypes) { this.knownTypeList.Add(type2); if (type2 != null) { this.AddCollectionItemTypeToKnownTypes(type2); } } } if (maxItemsInObjectGraph < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxItemsInObjectGraph", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative"))); } this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.dataContractSurrogate = dataContractSurrogate; this.alwaysEmitTypeInformation = alwaysEmitTypeInformation; }
private void Initialize(Type type, XmlDictionaryString rootName, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { this.Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation); this.rootName = ConvertXmlNameToJsonName(rootName); this.rootNameRequiresMapping = CheckIfJsonNameRequiresMapping(this.rootName); }
public DataContractJsonSerializer(Type type, XmlDictionaryString rootName, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) { this.Initialize(type, rootName, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, dataContractSurrogate, alwaysEmitTypeInformation); }
public DataContractSerializer (Type type, IEnumerable<Type> knownTypes, int maxObjectsInGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) : this (type, knownTypes) { Initialize (maxObjectsInGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate); }
public DataContractJsonSerializer(Type type, string rootName, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, IDataContractSurrogate dataContractSurrogate, bool alwaysEmitTypeInformation) : this(type, rootName, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, alwaysEmitTypeInformation) { surrogate = dataContractSurrogate; }
void Initialize ( int maxObjectsInGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) { if (maxObjectsInGraph < 0) throw new ArgumentOutOfRangeException ("maxObjectsInGraph must not be negative."); max_items = maxObjectsInGraph; ignore_ext = ignoreExtensionDataObject; preserve_refs = preserveObjectReferences; surrogate = dataContractSurrogate; }
public XmlCommentsDataSurrogate(IDataContractSurrogate prevSurrogate) { this.prevSurrogate = prevSurrogate; }