本文整理汇总了C#中System.Xml.Serialization.TypeScope类的典型用法代码示例。如果您正苦于以下问题:C# TypeScope类的具体用法?C# TypeScope怎么用?C# TypeScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeScope类属于System.Xml.Serialization命名空间,在下文中一共展示了TypeScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlMapping
internal XmlMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access)
{
_scope = scope;
_accessor = accessor;
_access = access;
_shallow = scope == null;
}
示例2: XmlMembersMapping
internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor) : base(scope) {
this.accessor = accessor;
MembersMapping mapping = (MembersMapping)accessor.Mapping;
mappings = new XmlMemberMapping[mapping.Members.Length];
for (int i = 0; i < mappings.Length; i++)
mappings[i] = new XmlMemberMapping(scope, mapping.Members[i]);
}
示例3: XmlMapping
internal XmlMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access)
{
this.scope = scope;
this.accessor = accessor;
this.access = access;
this.shallow = scope == null;
}
示例4: CheckScope
void CheckScope(TypeScope scope) {
if (this.scope == null) {
this.scope = scope;
}
else if (this.scope != scope) {
throw new InvalidOperationException(Res.GetString(Res.XmlMappingsScopeMismatch));
}
}
示例5: SoapReflectionImporter
/// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.SoapReflectionImporter3"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides, string defaultNamespace) {
if (defaultNamespace == null)
defaultNamespace = String.Empty;
if (attributeOverrides == null)
attributeOverrides = new SoapAttributeOverrides();
this.attributeOverrides = attributeOverrides;
this.defaultNs = defaultNamespace;
this.typeScope = new TypeScope();
this.modelScope = new ModelScope(this.typeScope);
}
示例6: CheckScope
private void CheckScope(TypeScope scope)
{
if (_scope == null)
{
_scope = scope;
}
else if (_scope != scope)
{
throw new InvalidOperationException(SR.XmlMappingsScopeMismatch);
}
}
示例7: XmlSerializationILGen
internal XmlSerializationILGen(TypeScope[] scopes, string access, string className) {
this.scopes = scopes;
if (scopes.Length > 0) {
stringTypeDesc = scopes[0].GetTypeDesc(typeof(string));
qnameTypeDesc = scopes[0].GetTypeDesc(typeof(XmlQualifiedName));
}
this.raCodeGen = new ReflectionAwareILGen();
this.className = className;
System.Diagnostics.Debug.Assert(access == "public");
this.typeAttributes = TypeAttributes.Public;
}
示例8: XmlReflectionImporter
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlReflectionImporter(XmlAttributeOverrides attributeOverrides, string defaultNamespace)
{
if (defaultNamespace == null)
defaultNamespace = String.Empty;
if (attributeOverrides == null)
attributeOverrides = new XmlAttributeOverrides();
_attributeOverrides = attributeOverrides;
_defaultNs = defaultNamespace;
_typeScope = new TypeScope();
_modelScope = new ModelScope(_typeScope);
}
示例9: XmlSerializationCodeGen
internal XmlSerializationCodeGen(IndentedWriter writer, TypeScope[] scopes, string access, string className) {
this.writer = writer;
this.scopes = scopes;
if (scopes.Length > 0) {
stringTypeDesc = scopes[0].GetTypeDesc(typeof(string));
qnameTypeDesc = scopes[0].GetTypeDesc(typeof(XmlQualifiedName));
}
this.raCodeGen = new ReflectionAwareCodeGen(writer);
this.className = className;
this.access = access;
}
示例10: XmlMembersMapping
internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access) : base(scope, accessor, access) {
MembersMapping mapping = (MembersMapping)accessor.Mapping;
StringBuilder key = new StringBuilder();
key.Append(":");
mappings = new XmlMemberMapping[mapping.Members.Length];
for (int i = 0; i < mappings.Length; i++) {
if (mapping.Members[i].TypeDesc.Type != null) {
key.Append(GenerateKey(mapping.Members[i].TypeDesc.Type, null, null));
key.Append(":");
}
mappings[i] = new XmlMemberMapping(mapping.Members[i]);
}
SetKeyInternal(key.ToString());
}
示例11: XmlReflectionImporter
public XmlReflectionImporter(XmlAttributeOverrides attributeOverrides, string defaultNamespace)
{
this.defaultAttributes = new XmlAttributes();
this.types = new System.Xml.Serialization.NameTable();
this.nullables = new System.Xml.Serialization.NameTable();
this.elements = new System.Xml.Serialization.NameTable();
this.anonymous = new Hashtable();
this.choiceNum = 1;
if (defaultNamespace == null)
{
defaultNamespace = string.Empty;
}
if (attributeOverrides == null)
{
attributeOverrides = new XmlAttributeOverrides();
}
this.attributeOverrides = attributeOverrides;
this.defaultNs = defaultNamespace;
this.typeScope = new TypeScope();
this.modelScope = new ModelScope(this.typeScope);
}
示例12: XmlTypeMapping
internal XmlTypeMapping(TypeScope scope, ElementAccessor accessor) : base(scope, accessor) {
}
示例13: XmlMapping
internal XmlMapping(TypeScope scope, ElementAccessor accessor) : this(scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write){
}
示例14: GenerateAssembly
internal static Assembly GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, string defaultNamespace, Evidence evidence, CompilerParameters parameters, Assembly assembly, Hashtable assemblies) {
FileIOPermission.Assert();
for (int i = 0; i < xmlMappings.Length; i++) {
xmlMappings[i].CheckShallow();
}
Compiler compiler = new Compiler();
try {
Hashtable scopeTable = new Hashtable();
foreach (XmlMapping mapping in xmlMappings)
scopeTable[mapping.Scope] = mapping;
TypeScope[] scopes = new TypeScope[scopeTable.Keys.Count];
scopeTable.Keys.CopyTo(scopes, 0);
assemblies.Clear();
Hashtable importedTypes = new Hashtable();
foreach (TypeScope scope in scopes) {
foreach (Type t in scope.Types) {
compiler.AddImport(t, importedTypes);
Assembly a = t.Assembly;
string name = a.FullName;
if (assemblies[name] != null)
continue;
if (!a.GlobalAssemblyCache) {
assemblies[name] = a;
}
}
}
for (int i = 0; i < types.Length; i++) {
compiler.AddImport(types[i], importedTypes);
}
compiler.AddImport(typeof(object).Assembly);
compiler.AddImport(typeof(XmlSerializer).Assembly);
IndentedWriter writer = new IndentedWriter(compiler.Source, false);
writer.WriteLine("#if _DYNAMIC_XMLSERIALIZER_COMPILATION");
writer.WriteLine("[assembly:System.Security.AllowPartiallyTrustedCallers()]");
writer.WriteLine("[assembly:System.Security.SecurityTransparent()]");
writer.WriteLine("#endif");
// Add AssemblyVersion attribute to match parent accembly version
if (types != null && types.Length > 0 && types[0] != null) {
writer.WriteLine("[assembly:System.Reflection.AssemblyVersionAttribute(\"" + types[0].Assembly.GetName().Version.ToString() + "\")]");
}
if (assembly != null && types.Length > 0) {
for (int i = 0; i < types.Length; i++) {
Type type = types[i];
if (type == null)
continue;
if (DynamicAssemblies.IsTypeDynamic(type)) {
throw new InvalidOperationException(Res.GetString(Res.XmlPregenTypeDynamic, types[i].FullName));
}
}
writer.Write("[assembly:");
writer.Write(typeof(XmlSerializerVersionAttribute).FullName);
writer.Write("(");
writer.Write("ParentAssemblyId=");
ReflectionAwareCodeGen.WriteQuotedCSharpString(writer, GenerateAssemblyId(types[0]));
writer.Write(", Version=");
ReflectionAwareCodeGen.WriteQuotedCSharpString(writer, ThisAssembly.Version);
if (defaultNamespace != null) {
writer.Write(", Namespace=");
ReflectionAwareCodeGen.WriteQuotedCSharpString(writer, defaultNamespace);
}
writer.WriteLine(")]");
}
CodeIdentifiers classes = new CodeIdentifiers();
classes.AddUnique("XmlSerializationWriter", "XmlSerializationWriter");
classes.AddUnique("XmlSerializationReader", "XmlSerializationReader");
string suffix = null;
if (types != null && types.Length == 1 && types[0] != null) {
suffix = CodeIdentifier.MakeValid(types[0].Name);
if (types[0].IsArray) {
suffix += "Array";
}
}
writer.WriteLine("namespace " + GeneratedAssemblyNamespace + " {");
writer.Indent++;
writer.WriteLine();
string writerClass = "XmlSerializationWriter" + suffix;
writerClass = classes.AddUnique(writerClass, writerClass);
XmlSerializationWriterCodeGen writerCodeGen = new XmlSerializationWriterCodeGen(writer, scopes, "public", writerClass);
writerCodeGen.GenerateBegin();
string[] writeMethodNames = new string[xmlMappings.Length];
for (int i = 0; i < xmlMappings.Length; i++) {
writeMethodNames[i] = writerCodeGen.GenerateElement(xmlMappings[i]);
}
writerCodeGen.GenerateEnd();
writer.WriteLine();
string readerClass = "XmlSerializationReader" + suffix;
readerClass = classes.AddUnique(readerClass, readerClass);
XmlSerializationReaderCodeGen readerCodeGen = new XmlSerializationReaderCodeGen(writer, scopes, "public", readerClass);
readerCodeGen.GenerateBegin();
//.........这里部分代码省略.........
示例15: ExportRootIfNecessary
private void ExportRootIfNecessary(TypeScope typeScope)
{
if (this.needToExportRoot)
{
foreach (TypeMapping mapping in typeScope.TypeMappings)
{
if ((mapping is StructMapping) && mapping.TypeDesc.IsRoot)
{
this.ExportDerivedMappings((StructMapping) mapping);
}
else if (mapping is ArrayMapping)
{
this.ExportArrayMapping((ArrayMapping) mapping, mapping.Namespace, null);
}
else if (mapping is SerializableMapping)
{
this.ExportSpecialMapping((SerializableMapping) mapping, mapping.Namespace, false, null);
}
}
}
}