本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
示例8: SetTempAssembly
internal void SetTempAssembly(TempAssembly tempAssembly, XmlMapping mapping)
{
_tempAssembly = tempAssembly;
_mapping = mapping;
_typedSerializer = true;
}
示例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
}
示例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
}
示例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);
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
}