本文整理汇总了C#中System.Xml.Serialization.TempAssembly类的典型用法代码示例。如果您正苦于以下问题:C# TempAssembly类的具体用法?C# TempAssembly怎么用?C# TempAssembly使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TempAssembly类属于System.Xml.Serialization命名空间,在下文中一共展示了TempAssembly类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SetTempAssembly
internal void SetTempAssembly(TempAssembly tempAssembly, XmlMapping mapping) {
this.tempAssembly = tempAssembly;
this.mapping = mapping;
this.typedSerializer = true;
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:5,代码来源:xmlserializer.cs
示例17: XmlSerializer
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlSerializer(XmlTypeMapping xmlTypeMapping)
{
if (xmlTypeMapping == null)
throw new ArgumentNullException(nameof(xmlTypeMapping));
#if !NET_NATIVE
_tempAssembly = GenerateTempAssembly(xmlTypeMapping);
#endif
_mapping = xmlTypeMapping;
}
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:13,代码来源:XmlSerializer.cs
示例18: FromMappings
/// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.FromMappings1"]/*' />
/// <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>();
XmlSerializerImplementation contract = null;
Assembly assembly = type == null ? null : TempAssembly.LoadGeneratedAssembly(type, null, out contract);
TempAssembly tempAssembly = null;
if (assembly == 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);
}
}
}
else
{
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:omariom,项目名称:corefx,代码行数:48,代码来源:XmlSerializer.cs
示例19: Init
// this method must be called before any generated deserialization methods are called
internal void Init(XmlReader r, XmlDeserializationEvents events, string encodingStyle, TempAssembly tempAssembly)
{
_events = events;
Init(tempAssembly);
Init(r, encodingStyle);
}
开发者ID:RendleLabs,项目名称:corefx,代码行数:7,代码来源:XmlSerializationReader.cs
示例20: GetSerializersFromCache
private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
{
XmlSerializer[] serializers = new XmlSerializer[mappings.Length];
Dictionary<XmlSerializerMappingKey, XmlSerializer> typedMappingTable = null;
lock (s_xmlSerializerTable)
{
if (!s_xmlSerializerTable.TryGetValue(type, out typedMappingTable))
{
typedMappingTable = new Dictionary<XmlSerializerMappingKey, XmlSerializer>();
s_xmlSerializerTable[type] = typedMappingTable;
}
}
lock (typedMappingTable)
{
var pendingKeys = new Dictionary<XmlSerializerMappingKey, int>();
for (int i = 0; i < mappings.Length; i++)
{
XmlSerializerMappingKey mappingKey = new XmlSerializerMappingKey(mappings[i]);
if (!typedMappingTable.TryGetValue(mappingKey, out serializers[i]))
{
pendingKeys.Add(mappingKey, i);
}
}
if (pendingKeys.Count > 0)
{
XmlMapping[] pendingMappings = new XmlMapping[pendingKeys.Count];
int index = 0;
foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
{
pendingMappings[index++] = mappingKey.Mapping;
}
TempAssembly tempAssembly = new TempAssembly(pendingMappings, new Type[] { type }, null, null, null);
XmlSerializerImplementation contract = tempAssembly.Contract;
foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
{
index = pendingKeys[mappingKey];
serializers[index] = (XmlSerializer)contract.TypedSerializers[mappingKey.Mapping.Key];
serializers[index].SetTempAssembly(tempAssembly, mappingKey.Mapping);
typedMappingTable[mappingKey] = serializers[index];
}
}
}
return serializers;
}
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:51,代码来源:XmlSerializer.cs
注:本文中的System.Xml.Serialization.TempAssembly类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论