本文整理汇总了C#中System.Runtime.Serialization.DataContract类的典型用法代码示例。如果您正苦于以下问题:C# DataContract类的具体用法?C# DataContract怎么用?C# DataContract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataContract类属于System.Runtime.Serialization命名空间,在下文中一共展示了DataContract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:27,代码来源:XmlObjectSerializerReadContextComplexJson.cs
示例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);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:SchemaExporter.cs
示例3: XmlObjectSerializerReadContextComplex
internal XmlObjectSerializerReadContextComplex(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
: base(serializer, rootTypeDataContract, dataContractResolver)
{
_mode = SerializationMode.SharedContract;
_preserveObjectReferences = serializer.PreserveObjectReferences;
_serializationSurrogateProvider = serializer.SerializationSurrogateProvider;
}
开发者ID:nadyalo,项目名称:corefx,代码行数:7,代码来源:XmlObjectSerializerReadContextComplex.cs
示例4: Add
public void Add(XmlQualifiedName name, DataContract dataContract)
{
if (!dataContract.IsBuiltInDataContract)
{
this.InternalAdd(name, dataContract);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:DataContractSet.cs
示例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;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:XmlObjectSerializerReadContextComplex.cs
示例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;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:XmlObjectSerializerReadContextComplexJson.cs
示例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)));
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:8,代码来源:XPathQueryGenerator.cs
示例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;
}
开发者ID:johnhhm,项目名称:corefx,代码行数:8,代码来源:JsonDataContract.cs
示例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;
}
开发者ID:yangjunhua,项目名称:mono,代码行数:10,代码来源:XmlObjectSerializerContext.cs
示例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;
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:11,代码来源:XmlObjectSerializerReadContextComplexJson.cs
示例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;
}
}
开发者ID:johnhhm,项目名称:corefx,代码行数:12,代码来源:JsonDataContract.cs
示例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)));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:XmlObjectSerializer.cs
示例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);
}
}
开发者ID:johnhhm,项目名称:corefx,代码行数:14,代码来源:XmlObjectSerializerReadContextComplex.cs
示例16: 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;
#if NET_NATIVE
// The c passed in could be a clone which is different from the original key,
// We'll need to get the original key data contract from generated assembly.
DataContract keyDc = DataContract.GetDataContractFromGeneratedAssembly(c.UnderlyingType);
return JsonReadWriteDelegates.GetJsonDelegates().TryGetValue(keyDc, out result) ? result : null;
#else
return JsonReadWriteDelegates.GetJsonDelegates().TryGetValue(c, out result) ? result : null;
#endif
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:15,代码来源:JsonDataContract.cs
示例17: WriteCollectionToXml
public void WriteCollectionToXml (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, CollectionDataContract collectionContract)
{
this.writer = xmlWriter;
this.obj = obj;
this.ctx = context;
this.dataContract = collectionContract;
InitArgs (collectionContract.UnderlyingType);
// DemandMemberAccessPermission(memberAccessFlag);
if (collectionContract.IsReadOnlyContract)
{
DataContract.ThrowInvalidDataContractException (collectionContract.SerializationExceptionMessage, null);
}
WriteCollection (collectionContract);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:17,代码来源:XmlFormatWriterGenerator_static.cs
示例18: WriteToXml
public void WriteToXml (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract dataContract)
{
this.writer = xmlWriter;
this.obj = obj;
this.ctx = context;
this.dataContract = dataContract;
InitArgs (classContract.UnderlyingType);
// DemandSerializationFormatterPermission (classContract) - irrelevant
// DemandMemberAccessPermission (memberAccessFlag) - irrelevant
if (classContract.IsReadOnlyContract)
{
DataContract.ThrowInvalidDataContractException (classContract.SerializationExceptionMessage, null);
}
WriteClass (classContract);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:19,代码来源:XmlFormatWriterGenerator_static.cs
示例19: GetDataContract
internal DataContract GetDataContract(RuntimeTypeHandle typeHandle, Type type, ref Hashtable surrogateDataContracts)
{
DataContract contract = GetDataContractFromSurrogateSelector(this.surrogateSelector, this.Context, typeHandle, type, ref surrogateDataContracts);
if (contract != null)
{
return contract;
}
if (this.cachedDataContract == null)
{
contract = DataContract.GetDataContract(typeHandle, type, SerializationMode.SharedType);
this.cachedDataContract = contract;
return contract;
}
DataContract cachedDataContract = this.cachedDataContract;
if (cachedDataContract.UnderlyingType.TypeHandle.Equals(typeHandle))
{
return cachedDataContract;
}
return DataContract.GetDataContract(typeHandle, type, SerializationMode.SharedType);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:NetDataContractSerializer.cs
示例20: HandleCollectionAssignedToObject
private void HandleCollectionAssignedToObject(Type declaredType, ref DataContract dataContract, ref object obj, ref bool verifyKnownType)
{
if ((declaredType != dataContract.UnderlyingType) && (dataContract is CollectionDataContract))
{
if (verifyKnownType)
{
this.VerifyType(dataContract, declaredType);
verifyKnownType = false;
}
if (((CollectionDataContract) dataContract).Kind == CollectionKind.Dictionary)
{
IDictionary dictionary = obj as IDictionary;
Dictionary<object, object> dictionary2 = new Dictionary<object, object>();
foreach (DictionaryEntry entry in dictionary)
{
dictionary2.Add(entry.Key, entry.Value);
}
obj = dictionary2;
}
dataContract = base.GetDataContract(Globals.TypeOfIEnumerable);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:XmlObjectSerializerWriteContextComplexJson.cs
注:本文中的System.Runtime.Serialization.DataContract类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论