Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Serialization / XmlSerializerFactory.cs / 1305376 / 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); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlRootAttribute root) { return CreateSerializer(type, null, new Type[0], root, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, Type[] extraTypes) { return CreateSerializer(type, null, extraTypes, null, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides) { return CreateSerializer(type, overrides, new Type[0], 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); } public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location) { #pragma warning disable 618 // Passing through null evidence to centralize the CreateSerializer implementation return CreateSerializer(type, overrides, extraTypes, root, defaultNamespace, location, null); #pragma warning restore 618 } ///[To be supplied.] ////// /// [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateSerializer which does not take an Evidence parameter. See http://go2.microsoft.com/fwlink/?LinkId=131738 for more information.")] 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. //------------------------------------------------------------------------------ //[To be supplied.] ///// 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); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlRootAttribute root) { return CreateSerializer(type, null, new Type[0], root, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, Type[] extraTypes) { return CreateSerializer(type, null, extraTypes, null, null, null); } ///[To be supplied.] ////// /// public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides) { return CreateSerializer(type, overrides, new Type[0], 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); } public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location) { #pragma warning disable 618 // Passing through null evidence to centralize the CreateSerializer implementation return CreateSerializer(type, overrides, extraTypes, root, defaultNamespace, location, null); #pragma warning restore 618 } ///[To be supplied.] ////// /// [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateSerializer which does not take an Evidence parameter. See http://go2.microsoft.com/fwlink/?LinkId=131738 for more information.")] 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.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NumberEdit.cs
- DesignerEventService.cs
- ConfigurationLocation.cs
- PathFigureCollection.cs
- sapiproxy.cs
- wgx_render.cs
- DockAndAnchorLayout.cs
- Calendar.cs
- XmlTypeAttribute.cs
- ModelTreeManager.cs
- IPHostEntry.cs
- TypeConverterAttribute.cs
- DeviceContext.cs
- WebPartsPersonalizationAuthorization.cs
- MissingMemberException.cs
- ConfigurationManagerInternalFactory.cs
- ContainerControlDesigner.cs
- DeobfuscatingStream.cs
- DataGridRelationshipRow.cs
- PasswordPropertyTextAttribute.cs
- SystemIPv4InterfaceProperties.cs
- ArrayElementGridEntry.cs
- Animatable.cs
- UriSection.cs
- AuthenticatingEventArgs.cs
- IndexedGlyphRun.cs
- Label.cs
- ConnectionManagementSection.cs
- RemotingSurrogateSelector.cs
- TreeNodeCollection.cs
- GeometryValueSerializer.cs
- RequestCacheEntry.cs
- DataControlFieldCollection.cs
- ConsumerConnectionPoint.cs
- PocoEntityKeyStrategy.cs
- HandlerWithFactory.cs
- XmlSchemaAnnotation.cs
- MenuRendererClassic.cs
- mansign.cs
- StandardToolWindows.cs
- ImageButton.cs
- OdbcHandle.cs
- OverflowException.cs
- SQLRoleProvider.cs
- CapabilitiesState.cs
- WebPartConnectionsCloseVerb.cs
- ItemsPanelTemplate.cs
- HostVisual.cs
- IPipelineRuntime.cs
- DocumentEventArgs.cs
- SplitterCancelEvent.cs
- ClientApiGenerator.cs
- DataGridCommandEventArgs.cs
- SynchronizedPool.cs
- OledbConnectionStringbuilder.cs
- XPathArrayIterator.cs
- FunctionMappingTranslator.cs
- _IPv6Address.cs
- CapabilitiesState.cs
- ObjectManager.cs
- DbReferenceCollection.cs
- RoleService.cs
- HttpBrowserCapabilitiesWrapper.cs
- CompilationSection.cs
- WindowsScroll.cs
- AuthStoreRoleProvider.cs
- SByte.cs
- SocketException.cs
- MarkupExtensionSerializer.cs
- ObjectConverter.cs
- QueryOutputWriter.cs
- LocationSectionRecord.cs
- DrawListViewSubItemEventArgs.cs
- NegotiationTokenProvider.cs
- RunInstallerAttribute.cs
- ExpressionConverter.cs
- WpfXamlType.cs
- WindowsRegion.cs
- Registry.cs
- DeploymentSectionCache.cs
- HttpModuleAction.cs
- ExpressionBuilder.cs
- Application.cs
- RolePrincipal.cs
- UserControlBuildProvider.cs
- ServiceModelExtensionCollectionElement.cs
- ProviderUtil.cs
- AccessControlList.cs
- ViewManager.cs
- QueueAccessMode.cs
- PageAsyncTask.cs
- DataFormat.cs
- DocumentReferenceCollection.cs
- NameObjectCollectionBase.cs
- FormatterServices.cs
- BinHexDecoder.cs
- WithStatement.cs
- CodeTypeMember.cs
- ProxyFragment.cs
- FixUpCollection.cs