Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Objects / ProxyDataContractResolver.cs / 1305376 / ProxyDataContractResolver.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Runtime.Serialization; namespace System.Data.Objects { ////// A DataContractResolver that knows how to resolve proxy types created for persistent /// ignorant classes to their base types. This is used with the DataContractSerializer. /// public class ProxyDataContractResolver : DataContractResolver { private XsdDataContractExporter _exporter = new XsdDataContractExporter(); public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver) { EntityUtil.CheckStringArgument(typeName, "typeName"); EntityUtil.CheckStringArgument(typeNamespace, "typeNamespace"); EntityUtil.CheckArgumentNull(declaredType, "declaredType"); EntityUtil.CheckArgumentNull(knownTypeResolver, "knownTypeResolver"); return knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType ,null); } public override bool TryResolveType(Type dataContractType, Type declaredType, DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString typeName, out System.Xml.XmlDictionaryString typeNamespace) { EntityUtil.CheckArgumentNull(dataContractType, "dataContractType"); EntityUtil.CheckArgumentNull(declaredType, "declaredType"); EntityUtil.CheckArgumentNull(knownTypeResolver, "knownTypeResolver"); Type nonProxyType = ObjectContext.GetObjectType(dataContractType); if (nonProxyType != dataContractType) { // Type was a proxy type, so map the name to the non-proxy name XmlQualifiedName qualifiedName = _exporter.GetSchemaTypeName(nonProxyType); XmlDictionary dictionary = new XmlDictionary(2); typeName = new XmlDictionaryString(dictionary, qualifiedName.Name, 0); typeNamespace = new XmlDictionaryString(dictionary, qualifiedName.Namespace, 1); return true; } else { // Type was not a proxy type, so do the default return knownTypeResolver.TryResolveType(dataContractType, declaredType, null, out typeName, out 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
- TraceFilter.cs
- ZoneIdentityPermission.cs
- PropertyInformation.cs
- XComponentModel.cs
- GiveFeedbackEvent.cs
- SharedPersonalizationStateInfo.cs
- SeekableReadStream.cs
- XmlSchemaAttributeGroup.cs
- DictionaryChange.cs
- LinqDataSourceStatusEventArgs.cs
- CellNormalizer.cs
- Exceptions.cs
- TableRow.cs
- BufferModesCollection.cs
- NestPullup.cs
- PagesSection.cs
- FocusChangedEventArgs.cs
- LinkedResource.cs
- WebPartExportVerb.cs
- ModelTreeEnumerator.cs
- LocalizabilityAttribute.cs
- DictationGrammar.cs
- ConfigurationSectionGroupCollection.cs
- TypeSystem.cs
- AttachmentService.cs
- NetworkStream.cs
- SystemInformation.cs
- TemplateBindingExpressionConverter.cs
- OciEnlistContext.cs
- XamlToRtfParser.cs
- BaseAppDomainProtocolHandler.cs
- XmlSchemaAnnotated.cs
- DynamicDataRoute.cs
- PersonalizationProvider.cs
- Rect3D.cs
- CodeCompiler.cs
- DrawingCollection.cs
- QueryExpr.cs
- SettingsAttributes.cs
- StylusPoint.cs
- EdgeModeValidation.cs
- Parsers.cs
- UserPreferenceChangingEventArgs.cs
- FrameworkElementFactoryMarkupObject.cs
- PageClientProxyGenerator.cs
- FrugalList.cs
- basevalidator.cs
- ConnectionsZone.cs
- AccessedThroughPropertyAttribute.cs
- PolyQuadraticBezierSegment.cs
- JsonByteArrayDataContract.cs
- GlyphElement.cs
- ActivityContext.cs
- AssemblyAttributesGoHere.cs
- IImplicitResourceProvider.cs
- ExtendedPropertyCollection.cs
- WindowsAltTab.cs
- InvariantComparer.cs
- Size3D.cs
- TextContainerChangedEventArgs.cs
- ElementHostAutomationPeer.cs
- StringHelper.cs
- ScrollBarRenderer.cs
- CachedBitmap.cs
- PathFigureCollectionValueSerializer.cs
- InputReportEventArgs.cs
- ToolstripProfessionalRenderer.cs
- StyleBamlRecordReader.cs
- CodeValidator.cs
- AnonymousIdentificationModule.cs
- UriParserTemplates.cs
- FocusWithinProperty.cs
- TriggerActionCollection.cs
- FormClosedEvent.cs
- ProfileGroupSettings.cs
- ResXBuildProvider.cs
- XmlSchemaAny.cs
- EdmFunction.cs
- SQLDateTimeStorage.cs
- TextEmbeddedObject.cs
- ValueQuery.cs
- MessageBox.cs
- UrlAuthFailedErrorFormatter.cs
- IndexedGlyphRun.cs
- Underline.cs
- SectionInput.cs
- TypefaceMetricsCache.cs
- DisposableCollectionWrapper.cs
- ContentControl.cs
- MemoryMappedFileSecurity.cs
- CapiHashAlgorithm.cs
- ThemeDictionaryExtension.cs
- FileDialogPermission.cs
- CodeArrayIndexerExpression.cs
- DoubleStorage.cs
- TreeChangeInfo.cs
- XmlNodeChangedEventManager.cs
- filewebrequest.cs
- QuaternionAnimationBase.cs
- ControlAdapter.cs