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
- LockCookie.cs
- SqlDataSourceFilteringEventArgs.cs
- EngineSite.cs
- PreloadedPackages.cs
- HttpRuntime.cs
- RegexMatch.cs
- TextElementEnumerator.cs
- ReceiveMessageAndVerifySecurityAsyncResultBase.cs
- GeometryHitTestParameters.cs
- ManagementInstaller.cs
- Vector3dCollection.cs
- BufferedReceiveManager.cs
- NestedContainer.cs
- AutomationPeer.cs
- SQLBoolean.cs
- RadioButtonFlatAdapter.cs
- BinaryObjectWriter.cs
- RuntimeHandles.cs
- OneOfElement.cs
- ControlValuePropertyAttribute.cs
- DateTimeConverter2.cs
- UnionCodeGroup.cs
- FixedTextBuilder.cs
- DataChangedEventManager.cs
- HttpRequestTraceRecord.cs
- ThicknessAnimation.cs
- SystemUnicastIPAddressInformation.cs
- Sql8ExpressionRewriter.cs
- SafeViewOfFileHandle.cs
- HtmlWindow.cs
- HandledMouseEvent.cs
- StoreAnnotationsMap.cs
- FormViewInsertEventArgs.cs
- NullEntityWrapper.cs
- PreviewControlDesigner.cs
- WaitHandleCannotBeOpenedException.cs
- StylusPointPropertyInfo.cs
- StringKeyFrameCollection.cs
- ListViewItem.cs
- XmlSchemaAppInfo.cs
- NavigationWindow.cs
- ResourceAssociationSet.cs
- FactoryGenerator.cs
- FormConverter.cs
- FrameSecurityDescriptor.cs
- TextEditorSpelling.cs
- TextServicesPropertyRanges.cs
- EmptyReadOnlyDictionaryInternal.cs
- figurelengthconverter.cs
- WindowsProgressbar.cs
- CompilationUnit.cs
- SoapIgnoreAttribute.cs
- DecimalKeyFrameCollection.cs
- PersistChildrenAttribute.cs
- XmlTypeMapping.cs
- DataGridViewAdvancedBorderStyle.cs
- securitycriticaldata.cs
- elementinformation.cs
- ApplicationContext.cs
- VersionedStream.cs
- InternalConfigSettingsFactory.cs
- XamlDesignerSerializationManager.cs
- TableParaClient.cs
- OperatingSystem.cs
- WebDescriptionAttribute.cs
- HtmlInputText.cs
- DataRecord.cs
- XmlText.cs
- AuthStoreRoleProvider.cs
- EqualityComparer.cs
- TableRow.cs
- Compensate.cs
- CacheVirtualItemsEvent.cs
- AnnotationService.cs
- ItemContainerGenerator.cs
- GeometryModel3D.cs
- ControlDesigner.cs
- XPathNavigatorKeyComparer.cs
- XamlToRtfWriter.cs
- QilVisitor.cs
- TextRangeEditLists.cs
- MenuItemCollection.cs
- CellRelation.cs
- AsyncContentLoadedEventArgs.cs
- XmlAtomicValue.cs
- RectAnimation.cs
- WindowsHyperlink.cs
- InputProviderSite.cs
- WmlListAdapter.cs
- RoutedEvent.cs
- StrokeCollection.cs
- _BasicClient.cs
- SQLDateTime.cs
- ObjectPersistData.cs
- StaticExtension.cs
- CookielessHelper.cs
- UpdateException.cs
- DataContractSerializerSection.cs
- ActiveDocumentEvent.cs
- _UriTypeConverter.cs