本文整理匯總了C#中System.Runtime.Serialization.DataContract類的典型用法代碼示例。如果您正苦於以下問題:C# DataContract類的具體用法?C# DataContract怎麽用?C# DataContract使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DataContract類屬於System.Runtime.Serialization命名空間,在下文中一共展示了DataContract類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckIfTypeNeedsVerifcation
internal void CheckIfTypeNeedsVerifcation(DataContract declaredContract, DataContract runtimeContract)
{
bool verifyType = true;
CollectionDataContract collectionContract = declaredContract as CollectionDataContract;
if (collectionContract != null && collectionContract.UnderlyingType.GetTypeInfo().IsInterface)
{
switch (collectionContract.Kind)
{
case CollectionKind.Dictionary:
case CollectionKind.GenericDictionary:
verifyType = declaredContract.Name == runtimeContract.Name;
break;
default:
Type t = collectionContract.ItemType.MakeArrayType();
verifyType = (t != runtimeContract.UnderlyingType);
break;
}
}
if (verifyType)
{
this.PushKnownTypes(declaredContract);
VerifyType(runtimeContract);
this.PopKnownTypes(declaredContract);
}
}
示例2: ExportDataContract
void ExportDataContract(DataContract dataContract)
{
if (dataContract.IsBuiltInDataContract)
return;
else if (dataContract is XmlDataContract)
ExportXmlDataContract((XmlDataContract)dataContract);
else
{
XmlSchema schema = GetSchema(dataContract.StableName.Namespace);
if (dataContract is ClassDataContract)
{
ClassDataContract classDataContract = (ClassDataContract)dataContract;
if (classDataContract.IsISerializable)
ExportISerializableDataContract(classDataContract, schema);
else
ExportClassDataContract(classDataContract, schema);
}
else if (dataContract is CollectionDataContract)
ExportCollectionDataContract((CollectionDataContract)dataContract, schema);
else if (dataContract is EnumDataContract)
ExportEnumDataContract((EnumDataContract)dataContract, schema);
ExportTopLevelElement(dataContract, schema);
Schemas.Reprocess(schema);
}
}
示例3: XmlObjectSerializerReadContextComplex
internal XmlObjectSerializerReadContextComplex(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
: base(serializer, rootTypeDataContract, dataContractResolver)
{
_mode = SerializationMode.SharedContract;
_preserveObjectReferences = serializer.PreserveObjectReferences;
_serializationSurrogateProvider = serializer.SerializationSurrogateProvider;
}
示例4: Add
public void Add(XmlQualifiedName name, DataContract dataContract)
{
if (!dataContract.IsBuiltInDataContract)
{
this.InternalAdd(name, dataContract);
}
}
示例5: XmlObjectSerializerReadContextComplex
internal XmlObjectSerializerReadContextComplex(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
: base(serializer, rootTypeDataContract, dataContractResolver)
{
this.mode = SerializationMode.SharedContract;
this.preserveObjectReferences = serializer.PreserveObjectReferences;
this.dataContractSurrogate = serializer.DataContractSurrogate;
}
示例6: XmlObjectSerializerWriteContextComplexJson
public XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract) : base(serializer, serializer.MaxItemsInObjectGraph, new StreamingContext(StreamingContextStates.All), serializer.IgnoreExtensionDataObject)
{
this.alwaysEmitXsiType = serializer.AlwaysEmitTypeInformation;
base.rootTypeDataContract = rootTypeDataContract;
base.serializerKnownTypeList = serializer.knownTypeList;
base.dataContractSurrogate = serializer.DataContractSurrogate;
}
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:XmlObjectSerializerWriteContextComplexJson.cs
示例7: XmlObjectSerializerReadContextComplexJson
public XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
: base(null, int.MaxValue, new StreamingContext(), true)
{
this.rootTypeDataContract = rootTypeDataContract;
this.serializerKnownTypeList = serializer.KnownTypes;
_jsonSerializer = serializer;
}
示例8: GetRevisedItemContract
internal static DataContract GetRevisedItemContract(DataContract oldItemContract)
{
if (((oldItemContract != null) && oldItemContract.UnderlyingType.IsGenericType) && (oldItemContract.UnderlyingType.GetGenericTypeDefinition() == Globals.TypeOfKeyValue))
{
return ClassDataContract.CreateClassDataContractForKeyValue(oldItemContract.UnderlyingType, oldItemContract.Namespace, new string[] { "Key", "Value" });
}
return oldItemContract;
}
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:8,代碼來源:XmlObjectSerializerWriteContextComplexJson.cs
示例9: ProcessDataContract
static DataContract ProcessDataContract(DataContract contract, ExportContext context, MemberInfo memberNode)
{
if (contract is ClassDataContract)
{
return ProcessClassDataContract((ClassDataContract)contract, context, memberNode);
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.QueryGeneratorPathToMemberNotFound)));
}
示例10: GetGeneratedReadWriteDelegates
public static JsonReadWriteDelegates GetGeneratedReadWriteDelegates(DataContract c)
{
// this method used to be rewritten by an IL transform
// with the restructuring for multi-file, this is no longer true - instead
// this has become a normal method
JsonReadWriteDelegates result;
return JsonReadWriteDelegates.GetJsonDelegates().TryGetValue(c, out result) ? result : null;
}
示例11: XmlObjectSerializerContext
internal XmlObjectSerializerContext(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
: this(serializer,
serializer.MaxItemsInObjectGraph,
new StreamingContext(StreamingContextStates.All),
serializer.IgnoreExtensionDataObject,
dataContractResolver)
{
this.rootTypeDataContract = rootTypeDataContract;
this.serializerKnownTypeList = serializer.knownTypeList;
}
示例12: ResolveDataContractFromType
internal DataContract ResolveDataContractFromType(string typeName, string typeNs, DataContract memberTypeContract)
{
this.PushKnownTypes(this.rootTypeDataContract);
this.PushKnownTypes(memberTypeContract);
XmlQualifiedName qname = ParseQualifiedName(typeName);
DataContract contract = ResolveDataContractFromKnownTypes(qname.Name, TrimNamespace(qname.Namespace), memberTypeContract);
this.PopKnownTypes(this.rootTypeDataContract);
this.PopKnownTypes(memberTypeContract);
return contract;
}
示例13: GetReadWriteDelegatesFromGeneratedAssembly
internal static JsonReadWriteDelegates GetReadWriteDelegatesFromGeneratedAssembly(DataContract c)
{
JsonReadWriteDelegates result = GetGeneratedReadWriteDelegates(c);
if (result == null)
{
throw new InvalidDataContractException(string.Format(SR.SerializationCodeIsMissingForType, c.UnderlyingType.ToString()));
}
else
{
return result;
}
}
示例14: CheckIfNeedsContractNsAtRoot
internal bool CheckIfNeedsContractNsAtRoot(XmlDictionaryString name, XmlDictionaryString ns, DataContract contract)
{
if (name == null)
{
return false;
}
if ((contract.IsBuiltInDataContract || !contract.CanContainReferences) || contract.IsISerializable)
{
return false;
}
string str = XmlDictionaryString.GetString(contract.Namespace);
return (!string.IsNullOrEmpty(str) && !(str == XmlDictionaryString.GetString(ns)));
}
示例15: InternalDeserialize
internal override object InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, string name, string ns)
{
if (_mode == SerializationMode.SharedContract)
{
//if (dataContractSurrogate == null)
return base.InternalDeserialize(xmlReader, declaredType, dataContract, name, ns);
//else
// return InternalDeserializeWithSurrogate(xmlReader, declaredType, dataContract, name, ns);
}
else
{
return InternalDeserializeInSharedTypeMode(xmlReader, -1, declaredType, name, ns);
}
}