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


C# Serialization.TempAssembly類代碼示例

本文整理匯總了C#中System.Xml.Serialization.TempAssembly的典型用法代碼示例。如果您正苦於以下問題:C# TempAssembly類的具體用法?C# TempAssembly怎麽用?C# TempAssembly使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TempAssembly類屬於System.Xml.Serialization命名空間,在下文中一共展示了TempAssembly類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: XmlSerializer

 /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace) {
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     for (int i = 0; i < extraTypes.Length; i++)
         importer.IncludeType(extraTypes[i]);
     tempAssembly = GenerateTempAssembly(importer.ImportTypeMapping(type, root));
     this.events.sender = this;
 }
開發者ID:ArildF,項目名稱:masters,代碼行數:11,代碼來源:xmlserializer.cs

示例2: CreateSerializer

 public XmlSerializer CreateSerializer(Type type, string defaultNamespace)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     TempAssembly assembly = cache[defaultNamespace, type];
     XmlTypeMapping xmlMapping = null;
     if (assembly == null)
     {
         lock (cache)
         {
             assembly = cache[defaultNamespace, type];
             if (assembly == null)
             {
                 XmlSerializerImplementation implementation;
                 if (TempAssembly.LoadGeneratedAssembly(type, defaultNamespace, out implementation) == null)
                 {
                     xmlMapping = new XmlReflectionImporter(defaultNamespace).ImportTypeMapping(type, null, defaultNamespace);
                     assembly = XmlSerializer.GenerateTempAssembly(xmlMapping, type, defaultNamespace);
                 }
                 else
                 {
                     assembly = new TempAssembly(implementation);
                 }
                 cache.Add(defaultNamespace, type, assembly);
             }
         }
     }
     if (xmlMapping == null)
     {
         xmlMapping = XmlReflectionImporter.GetTopLevelMapping(type, defaultNamespace);
     }
     return assembly.Contract.GetSerializer(type);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:35,代碼來源:XmlSerializerFactory.cs

示例3: Init

 // this method must be called before any generated serialization methods are called
 internal void Init(XmlWriter w, XmlSerializerNamespaces namespaces, string encodingStyle, string idBase, TempAssembly tempAssembly) {
     this.w = w;
     this.namespaces = namespaces;
     this.soap12 = (encodingStyle == Soap12.Encoding);
     this.idBase = idBase;
     Init(tempAssembly);
 }
開發者ID:uQr,項目名稱:referencesource,代碼行數:8,代碼來源:XmlSerializationWriter.cs

示例4: Init

 internal void Init(TempAssembly tempAssembly)
 {
     this.tempAssembly = tempAssembly;
     if ((tempAssembly != null) && tempAssembly.NeedAssembyResolve)
     {
         this.threadCode = Thread.CurrentThread.GetHashCode();
         this.assemblyResolver = new ResolveEventHandler(this.OnAssemblyResolve);
         AppDomain.CurrentDomain.AssemblyResolve += this.assemblyResolver;
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:10,代碼來源:XmlSerializationGeneratedCode.cs

示例5: Init

 internal void Init(TempAssembly tempAssembly) {
     this.tempAssembly = tempAssembly;
     // only hook the assembly resolver if we have something to help us do the resolution
     if (tempAssembly != null && tempAssembly.NeedAssembyResolve) {
         // we save the threadcode to make sure we don't handle any resolve events for any other threads
         threadCode = Thread.CurrentThread.GetHashCode();
         assemblyResolver = new ResolveEventHandler(OnAssemblyResolve);
         AppDomain.CurrentDomain.AssemblyResolve += assemblyResolver;
     }
 }
開發者ID:uQr,項目名稱:referencesource,代碼行數:10,代碼來源:XmlSerializationGeneratedCode.cs

示例6: Add

 internal void Add(string ns, object o, TempAssembly assembly)
 {
     TempAssemblyCacheKey key = new TempAssemblyCacheKey(ns, o);
     lock (this)
     {
         if (this.cache[key] != assembly)
         {
             Hashtable hashtable = new Hashtable();
             foreach (object obj2 in this.cache.Keys)
             {
                 hashtable.Add(obj2, this.cache[obj2]);
             }
             this.cache = hashtable;
             this.cache[key] = assembly;
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:17,代碼來源:TempAssemblyCache.cs

示例7: CreateSerializer

 /// <include file='doc\XmlSerializerFactory.uex' path='docs/doc[@for="XmlSerializerFactory.CreateSerializer1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlSerializer CreateSerializer(Type type, string defaultNamespace)
 {
     if (type == null)
         throw new ArgumentNullException(nameof(type));
     TempAssembly tempAssembly = s_cache[defaultNamespace, type];
     XmlTypeMapping mapping = null;
     if (tempAssembly == null)
     {
         lock (s_cache)
         {
             tempAssembly = s_cache[defaultNamespace, type];
             if (tempAssembly == null)
             {
                 XmlSerializerImplementation contract;
                 Assembly assembly = TempAssembly.LoadGeneratedAssembly(type, defaultNamespace, out contract);
                 if (assembly == null)
                 {
                     // need to reflect and generate new serialization assembly
                     XmlReflectionImporter importer = new XmlReflectionImporter(defaultNamespace);
                     mapping = importer.ImportTypeMapping(type, null, defaultNamespace);
                     tempAssembly = XmlSerializer.GenerateTempAssembly(mapping, type, defaultNamespace);
                 }
                 else
                 {
                     tempAssembly = new TempAssembly(contract);
                 }
                 s_cache.Add(defaultNamespace, type, tempAssembly);
             }
         }
     }
     if (mapping == null)
     {
         mapping = XmlReflectionImporter.GetTopLevelMapping(type, defaultNamespace);
     }
     return (XmlSerializer)tempAssembly.Contract.GetSerializer(type);
 }
開發者ID:Corillian,項目名稱:corefx,代碼行數:40,代碼來源:XmlSerializerFactory.cs

示例8: SetTempAssembly

 internal void SetTempAssembly(TempAssembly tempAssembly, XmlMapping mapping)
 {
     _tempAssembly = tempAssembly;
     _mapping = mapping;
     _typedSerializer = true;
 }
開發者ID:SamuelEnglard,項目名稱:corefx,代碼行數:6,代碼來源:XmlSerializer.cs

示例9: Init

        private void Init(Type type, string defaultNamespace)
        {
            if (type == null)
                throw new ArgumentNullException(nameof(type));

            DefaultNamespace = defaultNamespace;
            rootType = type;

            _mapping = GetKnownMapping(type, defaultNamespace);
            if (_mapping != null)
            {
                _primitiveType = type;
                return;
            }
#if !NET_NATIVE
            _tempAssembly = s_cache[defaultNamespace, type];
            if (_tempAssembly == null)
            {
                lock (s_cache)
                {
                    _tempAssembly = s_cache[defaultNamespace, type];
                    if (_tempAssembly == null)
                    {
                        {
                            // need to reflect and generate new serialization assembly
                            XmlReflectionImporter importer = new XmlReflectionImporter(defaultNamespace);
                            _mapping = importer.ImportTypeMapping(type, null, defaultNamespace);
                            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace);
                        }
                    }
                    s_cache.Add(defaultNamespace, type, _tempAssembly);
                }
            }
            if (_mapping == null)
            {
                _mapping = XmlReflectionImporter.GetTopLevelMapping(type, defaultNamespace);
            }
#else
            XmlSerializerImplementation contract = GetXmlSerializerContractFromGeneratedAssembly();

            if (contract != null)
            {
                this.innerSerializer = contract.GetSerializer(type);
            }
            else if (ReflectionMethodEnabled)
            {
                var importer = new XmlReflectionImporter(defaultNamespace);
                _mapping = importer.ImportTypeMapping(type, null, defaultNamespace);

                if (_mapping == null)
                {
                    _mapping = XmlReflectionImporter.GetTopLevelMapping(type, defaultNamespace);
                }
            }
#endif
        }
開發者ID:SamuelEnglard,項目名稱:corefx,代碼行數:56,代碼來源:XmlSerializer.cs

示例10: FromMappings

        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static XmlSerializer[] FromMappings(XmlMapping[] mappings, Type type)
        {
            if (mappings == null || mappings.Length == 0) return Array.Empty<XmlSerializer>();

#if NET_NATIVE
            var serializers = new XmlSerializer[mappings.Length];
            for(int i=0;i<mappings.Length;i++)
            {
                serializers[i] = new XmlSerializer();
                serializers[i].rootType = type;
                serializers[i]._mapping = mappings[i];
            }

            return serializers;
#else
            XmlSerializerImplementation contract = null;
            TempAssembly tempAssembly = null;
            {
                if (XmlMapping.IsShallow(mappings))
                {
                    return Array.Empty<XmlSerializer>();
                }
                else
                {
                    if (type == null)
                    {
                        tempAssembly = new TempAssembly(mappings, new Type[] { type }, null, null, null);
                        XmlSerializer[] serializers = new XmlSerializer[mappings.Length];

                        contract = tempAssembly.Contract;

                        for (int i = 0; i < serializers.Length; i++)
                        {
                            serializers[i] = (XmlSerializer)contract.TypedSerializers[mappings[i].Key];
                            serializers[i].SetTempAssembly(tempAssembly, mappings[i]);
                        }

                        return serializers;
                    }
                    else
                    {
                        // Use XmlSerializer cache when the type is not null.
                        return GetSerializersFromCache(mappings, type);
                    }
                }
            }
#endif
        }
開發者ID:SamuelEnglard,項目名稱:corefx,代碼行數:51,代碼來源:XmlSerializer.cs

示例11: XmlSerializer

 public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence) {
     if (type == null)
         throw new ArgumentNullException("type");
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     for (int i = 0; i < extraTypes.Length; i++)
         importer.IncludeType(extraTypes[i]);
     this.mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
     tempAssembly = GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence);
 }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:9,代碼來源:xmlserializer.cs

示例12: FromMappings

 public static XmlSerializer[] FromMappings(XmlMapping[] mappings, Evidence evidence) {
     if (mappings == null || mappings.Length == 0) return new XmlSerializer[0];
     if (XmlMapping.IsShallow(mappings)) {
         return new XmlSerializer[0];
     }
     TempAssembly tempAssembly = new TempAssembly(mappings, new Type[0], null, null, evidence);
     XmlSerializerImplementation contract = tempAssembly.Contract;
     XmlSerializer[] serializers = new XmlSerializer[mappings.Length];
     for (int i = 0; i < serializers.Length; i++) {
         serializers[i] = (XmlSerializer)contract.TypedSerializers[mappings[i].Key];
     }
     return serializers;
 }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:13,代碼來源:xmlserializer.cs

示例13: XmlSerializer

        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer7"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        internal XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
        {
            if (type == null)
                throw new ArgumentNullException(nameof(type));

            DefaultNamespace = defaultNamespace;
            rootType = type;
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
            if (extraTypes != null)
            {
                for (int i = 0; i < extraTypes.Length; i++)
                    importer.IncludeType(extraTypes[i]);
            }
            _mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
            if (location != null || evidence != null)
            {
                DemandForUserLocationOrEvidence();
            }

#if !NET_NATIVE
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace, location, evidence);
#endif
        }
開發者ID:alessandromontividiu03,項目名稱:corefx,代碼行數:27,代碼來源:XmlSerializer.cs

示例14: FromMappings

 /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.FromMappings"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static XmlSerializer[] FromMappings(XmlMapping[] mappings) {
     if (mappings.Length == 0) return new XmlSerializer[0];
     TempAssembly tempAssembly = new TempAssembly(mappings);
     XmlSerializer[] serializers = new XmlSerializer[mappings.Length];
     for (int i = 0; i < serializers.Length; i++)
         serializers[i] = new XmlSerializer(tempAssembly, i);
     return serializers;
 }
開發者ID:ArildF,項目名稱:masters,代碼行數:12,代碼來源:xmlserializer.cs

示例15: Add

 internal void Add(string ns, object o, TempAssembly assembly) {
     TempAssemblyCacheKey key = new TempAssemblyCacheKey(ns, o);
     lock(this) {
         if (cache[key] == assembly) return;
         Hashtable clone = new Hashtable();
         foreach (object k in cache.Keys) {
             clone.Add(k, cache[k]);
         }
         cache = clone;
         cache[key] = assembly;
     }
 }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:12,代碼來源:compilation.cs


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