當前位置: 首頁>>代碼示例>>C#>>正文


C# Serialization.DataContract類代碼示例

本文整理匯總了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);
            }
        }
開發者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


注:本文中的System.Runtime.Serialization.DataContract類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。