本文整理汇总了C#中IDataContractSurrogate类的典型用法代码示例。如果您正苦于以下问题:C# IDataContractSurrogate类的具体用法?C# IDataContractSurrogate怎么用?C# IDataContractSurrogate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDataContractSurrogate类属于命名空间,在下文中一共展示了IDataContractSurrogate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataContractJsonSerializerOperationBehavior
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;
}
示例2: GetCustomDataToExport
internal static object GetCustomDataToExport(IDataContractSurrogate surrogate, Type clrType, Type dataContractType)
{
if (DataContract.GetBuiltInDataContract(clrType) != null)
{
return null;
}
return surrogate.GetCustomDataToExport(clrType, dataContractType);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DataContractSurrogateCaller.cs
示例3: GetDeserializedObject
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);
}
示例4: GetReferencedTypeOnImport
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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DataContractSurrogateCaller.cs
示例5: GetDataContractType
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;
}
示例6: DataContractSerializer
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)
{
}
示例7: DataContractJsonSerializer
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);
}
示例8: GetObjectToSerialize
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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:DataContractSurrogateCaller.cs
示例9: Deserialize
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);
}
示例10: AddDataContractSurrogate
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;
}
}
示例11: ConfigureOperationDescriptionBehaviors
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);
}
示例12: DataContractSurrogateBehavior
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]);
}
示例13: DataContractSerializer
public DataContractSerializer (Type type,
IEnumerable<Type> knownTypes,
int maxObjectsInGraph,
bool ignoreExtensionDataObject,
bool preserveObjectReferences,
IDataContractSurrogate dataContractSurrogate)
: this (type, knownTypes)
{
Initialize (maxObjectsInGraph,
ignoreExtensionDataObject,
preserveObjectReferences,
dataContractSurrogate);
}
示例14: GetSurrogatedType
internal static Type GetSurrogatedType(IDataContractSurrogate dataContractSurrogate, Type type)
{
return DataContractSurrogateCaller.GetDataContractType(dataContractSurrogate, DataContract.UnwrapNullableType(type));
}
示例15: Initialize
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;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:DataContractJsonSerializer.cs