Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Xml / System / Xml / Serialization / Advanced / SchemaImporterExtension.cs / 1 / SchemaImporterExtension.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Serialization.Advanced { using System.Xml.Schema; using System.Xml; using System.Collections; using System.Collections.Specialized; using System.CodeDom; using System.CodeDom.Compiler; using System.Xml.Serialization; ////// /// /// public abstract class SchemaImporterExtension { ///[To be supplied.] ///public virtual string ImportSchemaType(string name, string ns, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual string ImportAnyElement(XmlSchemaAny any, bool mixed, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual CodeExpression ImportDefaultValue(string value, string type) { return null; } } public class SchemaImporterExtensionCollection : CollectionBase { Hashtable exNames; internal Hashtable Names { get { if (exNames == null) exNames = new Hashtable(); return exNames; } } public int Add(SchemaImporterExtension extension) { return Add(extension.GetType().FullName, extension); } public int Add(string name, Type type) { if (type.IsSubclassOf(typeof(SchemaImporterExtension))) { return Add(name, (SchemaImporterExtension)Activator.CreateInstance(type)); } else { throw new ArgumentException(Res.GetString(Res.XmlInvalidSchemaExtension, type)); } } public void Remove(string name) { if (Names[name] != null) { List.Remove(Names[name]); Names[name] = null; } } public new void Clear() { Names.Clear(); List.Clear(); } internal SchemaImporterExtensionCollection Clone() { SchemaImporterExtensionCollection clone = new SchemaImporterExtensionCollection(); clone.exNames = (Hashtable)this.Names.Clone(); foreach (object o in this.List) { clone.List.Add(o); } return clone; } public SchemaImporterExtension this[int index] { get { return (SchemaImporterExtension)List[index]; } set { List[index] = value; } } internal int Add(string name, SchemaImporterExtension extension) { if (Names[name] != null) { if (Names[name].GetType() != extension.GetType()) { throw new InvalidOperationException(Res.GetString(Res.XmlConfigurationDuplicateExtension, name)); } return -1; } Names[name] = extension; return List.Add(extension); } public void Insert(int index, SchemaImporterExtension extension) { List.Insert(index, extension); } public int IndexOf(SchemaImporterExtension extension) { return List.IndexOf(extension); } public bool Contains(SchemaImporterExtension extension) { return List.Contains(extension); } public void Remove(SchemaImporterExtension extension) { List.Remove(extension); } public void CopyTo(SchemaImporterExtension[] array, int index) { List.CopyTo(array, index); } } internal class MappedTypeDesc { string name; string ns; XmlSchemaType xsdType; XmlSchemaObject context; string clrType; SchemaImporterExtension extension; CodeNamespace code; bool exported = false; StringCollection references; internal MappedTypeDesc(string clrType, string name, string ns, XmlSchemaType xsdType, XmlSchemaObject context, SchemaImporterExtension extension, CodeNamespace code, StringCollection references) { this.clrType = clrType.Replace('+', '.'); this.name = name; this.ns = ns; this.xsdType = xsdType; this.context = context; this.code = code; this.references = references; this.extension = extension; } internal SchemaImporterExtension Extension { get { return extension; } } internal string Name { get { return clrType; } } internal StringCollection ReferencedAssemblies { get { if (references == null) references = new StringCollection(); return references; } } internal CodeTypeDeclaration ExportTypeDefinition(CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit) { if (exported) return null; exported = true; foreach(CodeNamespaceImport import in code.Imports) { codeNamespace.Imports.Add(import); } CodeTypeDeclaration codeClass = null; string comment = Res.GetString(Res.XmlExtensionComment, extension.GetType().FullName); foreach(CodeTypeDeclaration type in code.Types) { if (clrType == type.Name) { if (codeClass != null) throw new InvalidOperationException(Res.GetString(Res.XmlExtensionDuplicateDefinition, extension.GetType().FullName, clrType)); codeClass = type; } type.Comments.Add(new CodeCommentStatement(comment, false)); codeNamespace.Types.Add(type); } if (codeCompileUnit != null) { foreach(string reference in ReferencedAssemblies) { if (codeCompileUnit.ReferencedAssemblies.Contains(reference)) continue; codeCompileUnit.ReferencedAssemblies.Add(reference); } } return codeClass; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Serialization.Advanced { using System.Xml.Schema; using System.Xml; using System.Collections; using System.Collections.Specialized; using System.CodeDom; using System.CodeDom.Compiler; using System.Xml.Serialization; ////// /// /// public abstract class SchemaImporterExtension { ///[To be supplied.] ///public virtual string ImportSchemaType(string name, string ns, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual string ImportAnyElement(XmlSchemaAny any, bool mixed, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) { return null; } /// public virtual CodeExpression ImportDefaultValue(string value, string type) { return null; } } public class SchemaImporterExtensionCollection : CollectionBase { Hashtable exNames; internal Hashtable Names { get { if (exNames == null) exNames = new Hashtable(); return exNames; } } public int Add(SchemaImporterExtension extension) { return Add(extension.GetType().FullName, extension); } public int Add(string name, Type type) { if (type.IsSubclassOf(typeof(SchemaImporterExtension))) { return Add(name, (SchemaImporterExtension)Activator.CreateInstance(type)); } else { throw new ArgumentException(Res.GetString(Res.XmlInvalidSchemaExtension, type)); } } public void Remove(string name) { if (Names[name] != null) { List.Remove(Names[name]); Names[name] = null; } } public new void Clear() { Names.Clear(); List.Clear(); } internal SchemaImporterExtensionCollection Clone() { SchemaImporterExtensionCollection clone = new SchemaImporterExtensionCollection(); clone.exNames = (Hashtable)this.Names.Clone(); foreach (object o in this.List) { clone.List.Add(o); } return clone; } public SchemaImporterExtension this[int index] { get { return (SchemaImporterExtension)List[index]; } set { List[index] = value; } } internal int Add(string name, SchemaImporterExtension extension) { if (Names[name] != null) { if (Names[name].GetType() != extension.GetType()) { throw new InvalidOperationException(Res.GetString(Res.XmlConfigurationDuplicateExtension, name)); } return -1; } Names[name] = extension; return List.Add(extension); } public void Insert(int index, SchemaImporterExtension extension) { List.Insert(index, extension); } public int IndexOf(SchemaImporterExtension extension) { return List.IndexOf(extension); } public bool Contains(SchemaImporterExtension extension) { return List.Contains(extension); } public void Remove(SchemaImporterExtension extension) { List.Remove(extension); } public void CopyTo(SchemaImporterExtension[] array, int index) { List.CopyTo(array, index); } } internal class MappedTypeDesc { string name; string ns; XmlSchemaType xsdType; XmlSchemaObject context; string clrType; SchemaImporterExtension extension; CodeNamespace code; bool exported = false; StringCollection references; internal MappedTypeDesc(string clrType, string name, string ns, XmlSchemaType xsdType, XmlSchemaObject context, SchemaImporterExtension extension, CodeNamespace code, StringCollection references) { this.clrType = clrType.Replace('+', '.'); this.name = name; this.ns = ns; this.xsdType = xsdType; this.context = context; this.code = code; this.references = references; this.extension = extension; } internal SchemaImporterExtension Extension { get { return extension; } } internal string Name { get { return clrType; } } internal StringCollection ReferencedAssemblies { get { if (references == null) references = new StringCollection(); return references; } } internal CodeTypeDeclaration ExportTypeDefinition(CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit) { if (exported) return null; exported = true; foreach(CodeNamespaceImport import in code.Imports) { codeNamespace.Imports.Add(import); } CodeTypeDeclaration codeClass = null; string comment = Res.GetString(Res.XmlExtensionComment, extension.GetType().FullName); foreach(CodeTypeDeclaration type in code.Types) { if (clrType == type.Name) { if (codeClass != null) throw new InvalidOperationException(Res.GetString(Res.XmlExtensionDuplicateDefinition, extension.GetType().FullName, clrType)); codeClass = type; } type.Comments.Add(new CodeCommentStatement(comment, false)); codeNamespace.Types.Add(type); } if (codeCompileUnit != null) { foreach(string reference in ReferencedAssemblies) { if (codeCompileUnit.ReferencedAssemblies.Contains(reference)) continue; codeCompileUnit.ReferencedAssemblies.Add(reference); } } return codeClass; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MissingMethodException.cs
- CacheRequest.cs
- BasicExpandProvider.cs
- EntityViewGenerationAttribute.cs
- ZipFileInfoCollection.cs
- DBConcurrencyException.cs
- XpsDocumentEvent.cs
- EventListenerClientSide.cs
- MenuCommandService.cs
- GorillaCodec.cs
- AppDomainUnloadedException.cs
- PrtCap_Builder.cs
- WebBrowserUriTypeConverter.cs
- RemotingConfigParser.cs
- OdbcUtils.cs
- StructuredTypeEmitter.cs
- MimeImporter.cs
- EncoderBestFitFallback.cs
- HttpServerUtilityWrapper.cs
- DisplayMemberTemplateSelector.cs
- ProfileInfo.cs
- DrawingAttributes.cs
- TransformerTypeCollection.cs
- ChineseLunisolarCalendar.cs
- ContentIterators.cs
- HttpHandlerActionCollection.cs
- TimeSpanMinutesConverter.cs
- GACMembershipCondition.cs
- documentsequencetextview.cs
- SoapObjectWriter.cs
- TextBlock.cs
- ErrorStyle.cs
- FlowchartStart.xaml.cs
- CodeParameterDeclarationExpressionCollection.cs
- GlyphTypeface.cs
- OdbcConnectionPoolProviderInfo.cs
- CollectionBuilder.cs
- GridProviderWrapper.cs
- BatchWriter.cs
- ExpandSegment.cs
- WeakReferenceList.cs
- XmlWriterTraceListener.cs
- WebHttpEndpoint.cs
- Tokenizer.cs
- UnsafeNativeMethods.cs
- FixedSOMTextRun.cs
- InputReferenceExpression.cs
- OuterGlowBitmapEffect.cs
- TextEditorMouse.cs
- EntitySqlQueryCacheEntry.cs
- ProxyAssemblyNotLoadedException.cs
- SafeHGlobalHandleCritical.cs
- HttpConfigurationContext.cs
- BitmapMetadata.cs
- PersonalizablePropertyEntry.cs
- PieceNameHelper.cs
- Decimal.cs
- ListViewTableCell.cs
- IImplicitResourceProvider.cs
- MutexSecurity.cs
- HttpContext.cs
- StatusStrip.cs
- LogRecordSequence.cs
- BulletedList.cs
- XmlSchemaValidator.cs
- ReferenceAssemblyAttribute.cs
- Error.cs
- SQLByte.cs
- Composition.cs
- OneOf.cs
- DataGridViewRow.cs
- XNameTypeConverter.cs
- SqlAliaser.cs
- TrailingSpaceComparer.cs
- EpmSourceTree.cs
- SessionPageStatePersister.cs
- X500Name.cs
- CapabilitiesSection.cs
- Misc.cs
- PerspectiveCamera.cs
- DataServiceQueryException.cs
- NameValuePair.cs
- Tuple.cs
- EndOfStreamException.cs
- MsmqMessageProperty.cs
- GAC.cs
- InvokePattern.cs
- SafeEventLogWriteHandle.cs
- DoWorkEventArgs.cs
- CharEnumerator.cs
- _AutoWebProxyScriptEngine.cs
- UserPreference.cs
- versioninfo.cs
- TabControlEvent.cs
- Helper.cs
- Hex.cs
- Single.cs
- DocumentPageViewAutomationPeer.cs
- MailAddressCollection.cs
- AnnotationHighlightLayer.cs