Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / KnownTypeDataContractResolver.cs / 1305376 / KnownTypeDataContractResolver.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Serialization { using System.Xml; sealed class KnownTypeDataContractResolver : DataContractResolver { XmlObjectSerializerContext context; internal KnownTypeDataContractResolver(XmlObjectSerializerContext context) { Fx.Assert(context != null, "KnownTypeDataContractResolver should not be instantiated with a null context"); this.context = context; } public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace) { if (type == null) { typeName = null; typeNamespace = null; return false; } if (declaredType != null && declaredType.IsInterface && CollectionDataContract.IsCollectionInterface(declaredType)) { typeName = null; typeNamespace = null; return true; } DataContract contract = DataContract.GetDataContract(type); if (context.IsKnownType(contract, contract.KnownDataContracts, declaredType)) { typeName = contract.Name; typeNamespace = contract.Namespace; return true; } else { typeName = null; typeNamespace = null; return false; } } public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver) { if (typeName == null || typeNamespace == null) return null; return context.ResolveNameFromKnownTypes(new XmlQualifiedName(typeName, typeNamespace)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Serialization { using System.Xml; sealed class KnownTypeDataContractResolver : DataContractResolver { XmlObjectSerializerContext context; internal KnownTypeDataContractResolver(XmlObjectSerializerContext context) { Fx.Assert(context != null, "KnownTypeDataContractResolver should not be instantiated with a null context"); this.context = context; } public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace) { if (type == null) { typeName = null; typeNamespace = null; return false; } if (declaredType != null && declaredType.IsInterface && CollectionDataContract.IsCollectionInterface(declaredType)) { typeName = null; typeNamespace = null; return true; } DataContract contract = DataContract.GetDataContract(type); if (context.IsKnownType(contract, contract.KnownDataContracts, declaredType)) { typeName = contract.Name; typeNamespace = contract.Namespace; return true; } else { typeName = null; typeNamespace = null; return false; } } public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver) { if (typeName == null || typeNamespace == null) return null; return context.ResolveNameFromKnownTypes(new XmlQualifiedName(typeName, typeNamespace)); } } } // 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
- TypeBuilderInstantiation.cs
- AutoResizedEvent.cs
- EndpointAddressMessageFilter.cs
- Int64.cs
- LinearKeyFrames.cs
- Win32Native.cs
- MimeReturn.cs
- ProxyWebPartManagerDesigner.cs
- ArrayHelper.cs
- Inline.cs
- WizardPanel.cs
- XmlSerializerFormatAttribute.cs
- Utils.cs
- HandlerBase.cs
- StringAnimationBase.cs
- ConnectionManagementElement.cs
- _RequestLifetimeSetter.cs
- XmlSchemaParticle.cs
- FieldTemplateUserControl.cs
- DataBinding.cs
- CodePropertyReferenceExpression.cs
- DiagnosticsConfigurationHandler.cs
- NamespaceMapping.cs
- XslAstAnalyzer.cs
- SecurityState.cs
- _TLSstream.cs
- InputReferenceExpression.cs
- SafeFileMapViewHandle.cs
- Enlistment.cs
- RemotingConfigParser.cs
- InstanceHandleReference.cs
- DataSourceCacheDurationConverter.cs
- KeyEvent.cs
- DetailsViewRow.cs
- X509Extension.cs
- Deflater.cs
- ContentPresenter.cs
- XPathScanner.cs
- TemplateControl.cs
- HyperLink.cs
- QuaternionIndependentAnimationStorage.cs
- StrokeSerializer.cs
- LocalizeDesigner.cs
- CollectionChangeEventArgs.cs
- ArrayList.cs
- Panel.cs
- PathParser.cs
- CellParaClient.cs
- JoinCqlBlock.cs
- Root.cs
- ImageDrawing.cs
- MultiBinding.cs
- _HelperAsyncResults.cs
- GradientSpreadMethodValidation.cs
- _UriSyntax.cs
- ReadOnlyMetadataCollection.cs
- ActivationArguments.cs
- StructuredTypeEmitter.cs
- XPathExpr.cs
- StylusPointPropertyId.cs
- IntellisenseTextBox.cs
- HtmlImage.cs
- DeploymentSectionCache.cs
- InputScope.cs
- UntypedNullExpression.cs
- XmlNodeChangedEventManager.cs
- ColorContext.cs
- InfoCardArgumentException.cs
- SQLMoneyStorage.cs
- GeneralTransformGroup.cs
- FilterEventArgs.cs
- Control.cs
- ParserExtension.cs
- PrinterResolution.cs
- EdmSchemaError.cs
- FreeFormDesigner.cs
- TextSelectionProcessor.cs
- ChildDocumentBlock.cs
- WebBrowsableAttribute.cs
- SimpleHandlerBuildProvider.cs
- ControlPersister.cs
- ImpersonateTokenRef.cs
- CookieParameter.cs
- CompiledRegexRunnerFactory.cs
- SqlCommandBuilder.cs
- RuntimeHelpers.cs
- XsltInput.cs
- ResourceReferenceExpression.cs
- FirstMatchCodeGroup.cs
- SQLDecimal.cs
- PathParser.cs
- ProtocolInformationWriter.cs
- Form.cs
- DataGridViewColumnCollection.cs
- CodeEntryPointMethod.cs
- Label.cs
- XmlUtil.cs
- InvalidateEvent.cs
- ValidationHelper.cs
- PlatformNotSupportedException.cs