Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Attributes.cs / 2 / Attributes.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization { using System; using System.Globalization; using System.IO; using System.Xml; using System.Security; internal class Attributes { ////// Critical - Static field used to store the attribute names to read during deserialization. /// Static fields are marked SecurityCritical or readonly to prevent /// data from being modified or leaked to other components in appdomain. /// [SecurityCritical] static XmlDictionaryString[] serializationLocalNames; ////// Critical - Static field used to store the attribute names to read during deserialization. /// Static fields are marked SecurityCritical or readonly to prevent /// data from being modified or leaked to other components in appdomain. /// [SecurityCritical] static XmlDictionaryString[] schemaInstanceLocalNames; ////// Critical - initializes critical static fields /// Safe - doesn't leak anything /// [SecurityCritical, SecurityTreatAsSafe] static Attributes() { serializationLocalNames = new XmlDictionaryString[] { DictionaryGlobals.IdLocalName, DictionaryGlobals.ArraySizeLocalName, DictionaryGlobals.RefLocalName, DictionaryGlobals.ClrTypeLocalName, DictionaryGlobals.ClrAssemblyLocalName, DictionaryGlobals.ISerializableFactoryTypeLocalName }; schemaInstanceLocalNames = new XmlDictionaryString[] { DictionaryGlobals.XsiNilLocalName, DictionaryGlobals.XsiTypeLocalName }; } internal string Id; internal string Ref; internal string XsiTypeName; internal string XsiTypeNamespace; internal string XsiTypePrefix; internal bool XsiNil; internal string ClrAssembly; internal string ClrType; internal int ArraySZSize; internal string FactoryTypeName; internal string FactoryTypeNamespace; internal string FactoryTypePrefix; internal bool UnrecognizedAttributesFound; [SecurityCritical, SecurityTreatAsSafe] internal void Read (XmlReaderDelegator reader) { Reset(); while (reader.MoveToNextAttribute()) { switch (reader.IndexOfLocalName(serializationLocalNames, DictionaryGlobals.SerializationNamespace)) { case 0: ReadId(reader); break; case 1: ReadArraySize(reader); break; case 2: ReadRef(reader); break; case 3: ClrType = reader.Value; break; case 4: ClrAssembly = reader.Value; break; case 5: ReadFactoryType(reader); break; default: switch (reader.IndexOfLocalName(schemaInstanceLocalNames, DictionaryGlobals.SchemaInstanceNamespace)) { case 0: ReadXsiNil(reader); break; case 1: ReadXsiType(reader); break; default: if (!reader.IsNamespaceUri(DictionaryGlobals.XmlnsNamespace)) UnrecognizedAttributesFound = true; break; } break; } } reader.MoveToElement(); } internal void Reset() { Id = Globals.NewObjectId; Ref = Globals.NewObjectId; XsiTypeName = null; XsiTypeNamespace = null; XsiTypePrefix = null; XsiNil = false; ClrAssembly = null; ClrType = null; ArraySZSize = -1; FactoryTypeName = null; FactoryTypeNamespace = null; FactoryTypePrefix = null; UnrecognizedAttributesFound = false; } void ReadId(XmlReaderDelegator reader) { Id = reader.ReadContentAsString(); if (string.IsNullOrEmpty(Id)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.InvalidXsIdDefinition, Id))); } } void ReadRef(XmlReaderDelegator reader) { Ref = reader.ReadContentAsString(); if (string.IsNullOrEmpty(Ref)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.InvalidXsRefDefinition, Ref))); } } void ReadXsiNil(XmlReaderDelegator reader) { XsiNil = reader.ReadContentAsBoolean(); } void ReadArraySize(XmlReaderDelegator reader) { ArraySZSize = reader.ReadContentAsInt(); if (ArraySZSize < 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.InvalidSizeDefinition, ArraySZSize))); } void ReadXsiType(XmlReaderDelegator reader) { string xsiTypeString = reader.Value; if (xsiTypeString != null && xsiTypeString.Length > 0) XmlObjectSerializerReadContext.ParseQualifiedName(xsiTypeString, reader, out XsiTypeName, out XsiTypeNamespace, out XsiTypePrefix); } void ReadFactoryType(XmlReaderDelegator reader) { string factoryTypeString = reader.Value; if (factoryTypeString != null && factoryTypeString.Length > 0) XmlObjectSerializerReadContext.ParseQualifiedName(factoryTypeString, reader, out FactoryTypeName, out FactoryTypeNamespace, out FactoryTypePrefix); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Pkcs9Attribute.cs
- SocketAddress.cs
- AspCompat.cs
- TreeChangeInfo.cs
- CatalogZoneBase.cs
- ByteStreamMessageEncodingElement.cs
- FocusManager.cs
- SerialStream.cs
- DocumentXPathNavigator.cs
- XmlToDatasetMap.cs
- BamlLocalizationDictionary.cs
- XPathEmptyIterator.cs
- TypeHelpers.cs
- NamespaceEmitter.cs
- TextServicesLoader.cs
- RSAPKCS1SignatureDeformatter.cs
- XmlDesignerDataSourceView.cs
- DesignerTransaction.cs
- CodeCastExpression.cs
- ObjectPropertyMapping.cs
- TabControl.cs
- CertificateReferenceElement.cs
- AddressAlreadyInUseException.cs
- ProjectedWrapper.cs
- AttributeEmitter.cs
- SqlXmlStorage.cs
- XMLUtil.cs
- VirtualDirectoryMapping.cs
- WebSysDisplayNameAttribute.cs
- CodeMemberEvent.cs
- _NativeSSPI.cs
- Assert.cs
- XmlHierarchicalEnumerable.cs
- XPathDescendantIterator.cs
- GAC.cs
- TemplateLookupAction.cs
- BindingSource.cs
- ConfigUtil.cs
- ContentTextAutomationPeer.cs
- ImageSourceValueSerializer.cs
- CachedRequestParams.cs
- MatrixConverter.cs
- MetadataArtifactLoaderResource.cs
- PropertyRef.cs
- DynamicResourceExtensionConverter.cs
- ListManagerBindingsCollection.cs
- SecurityTokenTypes.cs
- RuntimeEnvironment.cs
- PrintPreviewGraphics.cs
- EndpointDiscoveryMetadata.cs
- UnsafeNativeMethods.cs
- EmptyEnumerator.cs
- EditableRegion.cs
- SelectorAutomationPeer.cs
- RunInstallerAttribute.cs
- XamlVector3DCollectionSerializer.cs
- SafeNativeMethods.cs
- AvTraceDetails.cs
- DataGridPagingPage.cs
- SystemResourceHost.cs
- FormsAuthentication.cs
- unsafenativemethodsother.cs
- EncoderReplacementFallback.cs
- RepeatBehaviorConverter.cs
- ApplicationHost.cs
- PrivilegedConfigurationManager.cs
- HtmlInputPassword.cs
- QueryConverter.cs
- DbXmlEnabledProviderManifest.cs
- XLinq.cs
- CustomAssemblyResolver.cs
- BamlWriter.cs
- MenuItemCollectionEditor.cs
- ServicePointManager.cs
- FloaterParaClient.cs
- MissingFieldException.cs
- EditingCommands.cs
- ToolStripButton.cs
- BidPrivateBase.cs
- ServiceReference.cs
- InheritanceAttribute.cs
- InfoCardKeyedHashAlgorithm.cs
- LabelTarget.cs
- ImageSourceConverter.cs
- BamlTreeUpdater.cs
- controlskin.cs
- RTLAwareMessageBox.cs
- MemberInfoSerializationHolder.cs
- CopyOfAction.cs
- ExtendLockAsyncResult.cs
- XamlVector3DCollectionSerializer.cs
- GrammarBuilderBase.cs
- HandlerWithFactory.cs
- JapaneseCalendar.cs
- SharedUtils.cs
- XmlAtomicValue.cs
- InputReferenceExpression.cs
- EventBuilder.cs
- WebBrowserNavigatingEventHandler.cs
- DbModificationCommandTree.cs