Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / Serialization / XmlSerializerFactory.cs / 1 / XmlSerializerFactory.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- namespace System.Xml.Serialization { using System.Reflection; using System.Collections; using System.IO; using System.Xml.Schema; using System; using System.Text; using System.Threading; using System.Globalization; using System.Security.Permissions; using System.Security.Policy; using System.Xml.Serialization.Configuration; using System.Diagnostics; using System.CodeDom.Compiler; ////// /// public class XmlSerializerFactory { static TempAssemblyCache cache = new TempAssemblyCache(); ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace) { return CreateSerializer(type, overrides, extraTypes, root, defaultNamespace, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlRootAttribute root) { return CreateSerializer(type, null, new Type[0], root, null, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, Type[] extraTypes) { return CreateSerializer(type, null, extraTypes, null, null, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides) { return CreateSerializer(type, overrides, new Type[0], null, null, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(XmlTypeMapping xmlTypeMapping) { TempAssembly tempAssembly = XmlSerializer.GenerateTempAssembly(xmlTypeMapping); return (XmlSerializer)tempAssembly.Contract.TypedSerializers[xmlTypeMapping.Key]; } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type) { return CreateSerializer(type, (string)null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, string defaultNamespace) { if (type == null) throw new ArgumentNullException("type"); TempAssembly tempAssembly = cache[defaultNamespace, type]; XmlTypeMapping mapping = null; if (tempAssembly == null) { lock (cache) { tempAssembly = 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); } cache.Add(defaultNamespace, type, tempAssembly); } } } if (mapping == null) { mapping = XmlReflectionImporter.GetTopLevelMapping(type, defaultNamespace); } return (XmlSerializer)tempAssembly.Contract.GetSerializer(type); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(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]); XmlTypeMapping mapping = importer.ImportTypeMapping(type, root, defaultNamespace); TempAssembly tempAssembly = XmlSerializer.GenerateTempAssembly(mapping, type, defaultNamespace, location, evidence); return (XmlSerializer)tempAssembly.Contract.TypedSerializers[mapping.Key]; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListMarkerLine.cs
- COM2TypeInfoProcessor.cs
- AmbientProperties.cs
- IdnMapping.cs
- SoapServerMethod.cs
- SchemaTableColumn.cs
- HttpModuleCollection.cs
- RuleRef.cs
- PerfCounters.cs
- UInt16.cs
- XmlUrlResolver.cs
- SQLStringStorage.cs
- BaseDataList.cs
- SqlCacheDependencySection.cs
- XomlCompilerResults.cs
- DataObjectMethodAttribute.cs
- DeclarativeCatalogPartDesigner.cs
- xml.cs
- PerspectiveCamera.cs
- PeerEndPoint.cs
- CodeSnippetStatement.cs
- XmlBinaryWriterSession.cs
- CodeDomDecompiler.cs
- WindowsScrollBarBits.cs
- TemplatedControlDesigner.cs
- ClientConvert.cs
- ButtonPopupAdapter.cs
- WindowsListViewItem.cs
- SettingsPropertyValueCollection.cs
- EntityUtil.cs
- RangeValidator.cs
- DataGridTextColumn.cs
- PeerCustomResolverSettings.cs
- _ProxyChain.cs
- SafeEventLogWriteHandle.cs
- WebSysDescriptionAttribute.cs
- CodeIterationStatement.cs
- EventLogInternal.cs
- IgnoreDeviceFilterElement.cs
- SliderAutomationPeer.cs
- DataSourceControlBuilder.cs
- PasswordPropertyTextAttribute.cs
- Stopwatch.cs
- ProjectionPath.cs
- LinkClickEvent.cs
- XamlGridLengthSerializer.cs
- WeakReferenceKey.cs
- FormViewInsertedEventArgs.cs
- ControlCachePolicy.cs
- PackageDigitalSignatureManager.cs
- Content.cs
- OracleBinary.cs
- ZipIOCentralDirectoryFileHeader.cs
- TextTreeText.cs
- ServiceObjectContainer.cs
- BitmapCacheBrush.cs
- SafeCryptContextHandle.cs
- CertificateManager.cs
- COM2PropertyDescriptor.cs
- ListControl.cs
- ConfigurationSectionHelper.cs
- BinHexDecoder.cs
- NativeMethodsOther.cs
- TextSpanModifier.cs
- WorkflowPageSetupDialog.cs
- DecoderFallback.cs
- ButtonChrome.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- ColumnMapProcessor.cs
- Trace.cs
- RelationalExpressions.cs
- PrintDialog.cs
- EDesignUtil.cs
- DashStyles.cs
- ListItemParagraph.cs
- TreeNodeEventArgs.cs
- SQLInt64.cs
- Interlocked.cs
- RegexTypeEditor.cs
- ScrollChangedEventArgs.cs
- CriticalHandle.cs
- ZoomingMessageFilter.cs
- ApplicationSecurityManager.cs
- UniqueID.cs
- MethodCallTranslator.cs
- Pen.cs
- BitmapMetadataEnumerator.cs
- Classification.cs
- NumberFormatInfo.cs
- FormatterServicesNoSerializableCheck.cs
- WebPartDisplayModeCancelEventArgs.cs
- StylusCollection.cs
- CheckBoxField.cs
- FixedSOMTable.cs
- TextDecoration.cs
- CmsUtils.cs
- ScriptMethodAttribute.cs
- EngineSiteSapi.cs
- DependencyObjectCodeDomSerializer.cs
- HtmlImage.cs