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
- CompilerGlobalScopeAttribute.cs
- oledbmetadatacolumnnames.cs
- PolicyValidator.cs
- GestureRecognitionResult.cs
- PerformanceCounterManager.cs
- CheckBoxStandardAdapter.cs
- WebEventTraceProvider.cs
- BuilderPropertyEntry.cs
- figurelengthconverter.cs
- Filter.cs
- CoTaskMemHandle.cs
- WebPartEditorCancelVerb.cs
- DataGridViewCellMouseEventArgs.cs
- DeclarativeCatalogPart.cs
- ConfigXmlAttribute.cs
- SQLDateTime.cs
- HostUtils.cs
- NamespaceCollection.cs
- PersistChildrenAttribute.cs
- XmlConvert.cs
- TabPanel.cs
- Clause.cs
- XmlTextWriter.cs
- DependencySource.cs
- PinnedBufferMemoryStream.cs
- ComplexLine.cs
- ReflectionUtil.cs
- MaterializeFromAtom.cs
- ActivitySurrogateSelector.cs
- IERequestCache.cs
- SwitchLevelAttribute.cs
- SliderAutomationPeer.cs
- ServiceDescriptionReflector.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- TriggerActionCollection.cs
- SearchExpression.cs
- XamlSerializer.cs
- SqlConnectionStringBuilder.cs
- Crc32.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ContainerControl.cs
- WorkflowItemsPresenter.cs
- RawStylusInputCustomData.cs
- ExternalCalls.cs
- ZipPackagePart.cs
- TableStyle.cs
- Helpers.cs
- RichTextBox.cs
- DataBoundControlActionList.cs
- XmlSchemaSimpleTypeRestriction.cs
- HitTestWithGeometryDrawingContextWalker.cs
- ReadOnlyHierarchicalDataSourceView.cs
- DataContractJsonSerializerOperationFormatter.cs
- OleDbConnectionInternal.cs
- CommandField.cs
- ColumnClickEvent.cs
- EntityDataSourceWrapperCollection.cs
- ErrorHandler.cs
- CultureNotFoundException.cs
- RulePatternOps.cs
- XmlDataLoader.cs
- DataAdapter.cs
- Range.cs
- SafeWaitHandle.cs
- QuadTree.cs
- EdmSchemaError.cs
- DbProviderConfigurationHandler.cs
- DllNotFoundException.cs
- ToolTipService.cs
- FontStretch.cs
- CodeSnippetExpression.cs
- TransformGroup.cs
- ValidationRuleCollection.cs
- securitymgrsite.cs
- GridViewUpdateEventArgs.cs
- BoundField.cs
- ControlValuePropertyAttribute.cs
- ConnectionStringSettings.cs
- ConfigXmlCDataSection.cs
- TaiwanCalendar.cs
- SubstitutionDesigner.cs
- PixelFormat.cs
- MouseBinding.cs
- KeyboardNavigation.cs
- SortedList.cs
- Stylesheet.cs
- AnnotationStore.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SmtpFailedRecipientsException.cs
- ExceptionHandlers.cs
- HashStream.cs
- SessionPageStatePersister.cs
- DoubleAnimation.cs
- OptimizerPatterns.cs
- DataMemberAttribute.cs
- DropShadowEffect.cs
- FormViewDeleteEventArgs.cs
- SqlNotificationRequest.cs
- UnmanagedMemoryStream.cs
- OleDbDataAdapter.cs