Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / IDataContractSurrogate.cs / 1305376 / IDataContractSurrogate.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization { using System; using System.CodeDom; using System.Reflection; using System.Collections.ObjectModel; public interface IDataContractSurrogate { Type GetDataContractType(Type type); object GetObjectToSerialize(object obj, Type targetType); object GetDeserializedObject(object obj, Type targetType); object GetCustomDataToExport(MemberInfo memberInfo, Type dataContractType); object GetCustomDataToExport(Type clrType, Type dataContractType); void GetKnownCustomDataTypes(CollectioncustomDataTypes); Type GetReferencedTypeOnImport(string typeName, string typeNamespace, object customData); CodeTypeDeclaration ProcessImportedType(CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit); } static class DataContractSurrogateCaller { internal static Type GetDataContractType(IDataContractSurrogate surrogate, Type type) { if (DataContract.GetBuiltInDataContract(type)!= null) return type; Type dcType = surrogate.GetDataContractType(type); if(dcType == null) return type; return dcType; } internal static object GetObjectToSerialize(IDataContractSurrogate surrogate, object obj, Type objType, Type membertype) { if(obj == null) return null; if (DataContract.GetBuiltInDataContract(objType)!= null) return obj; return surrogate.GetObjectToSerialize(obj, membertype); } internal static object GetDeserializedObject(IDataContractSurrogate surrogate, object obj, Type objType, Type memberType) { if(obj == null) return null; if (DataContract.GetBuiltInDataContract(objType)!= null) return obj; return surrogate.GetDeserializedObject(obj, memberType); } internal static object GetCustomDataToExport(IDataContractSurrogate surrogate, MemberInfo memberInfo, Type dataContractType) { return surrogate.GetCustomDataToExport(memberInfo, dataContractType); } internal static object GetCustomDataToExport(IDataContractSurrogate surrogate, Type clrType, Type dataContractType) { if (DataContract.GetBuiltInDataContract(clrType)!= null) return null; return surrogate.GetCustomDataToExport(clrType, dataContractType); } internal static void GetKnownCustomDataTypes(IDataContractSurrogate surrogate, Collection customDataTypes) { surrogate.GetKnownCustomDataTypes(customDataTypes); } internal static Type GetReferencedTypeOnImport(IDataContractSurrogate surrogate, string typeName, string typeNamespace, object customData) { if(DataContract.GetBuiltInDataContract(typeName, typeNamespace) != null) return null; return surrogate.GetReferencedTypeOnImport(typeName, typeNamespace, customData); } internal static CodeTypeDeclaration ProcessImportedType(IDataContractSurrogate surrogate, CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit) { return surrogate.ProcessImportedType(typeDeclaration, compileUnit); } } } // 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
- XmlC14NWriter.cs
- InkCanvas.cs
- HttpModuleAction.cs
- SchemaConstraints.cs
- EditorPart.cs
- WorkflowViewService.cs
- OLEDB_Enum.cs
- Expression.cs
- GridViewAutomationPeer.cs
- TrackingProfile.cs
- SegmentInfo.cs
- EntitySqlException.cs
- TextBox.cs
- DatagridviewDisplayedBandsData.cs
- ErrorProvider.cs
- HtmlFormWrapper.cs
- ErrorProvider.cs
- RepeaterItemEventArgs.cs
- SplitContainer.cs
- AppSettingsExpressionBuilder.cs
- DeviceSpecific.cs
- QilChoice.cs
- FormatterServices.cs
- shaperfactoryquerycachekey.cs
- BamlLocalizableResourceKey.cs
- SynchronizationLockException.cs
- Typography.cs
- HttpHandlerAction.cs
- SpotLight.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- HybridWebProxyFinder.cs
- ScrollContentPresenter.cs
- AmbientEnvironment.cs
- ApplicationDirectory.cs
- MarkupExtensionParser.cs
- ColorConvertedBitmapExtension.cs
- UpdateCommandGenerator.cs
- ArcSegment.cs
- TransactionContext.cs
- NotifyIcon.cs
- JsonStringDataContract.cs
- xmlfixedPageInfo.cs
- ErrorStyle.cs
- DropShadowEffect.cs
- ProcessInputEventArgs.cs
- CodeTypeReferenceSerializer.cs
- PackageRelationship.cs
- PropertyValueChangedEvent.cs
- ResourcesBuildProvider.cs
- BulletedListEventArgs.cs
- ProgressChangedEventArgs.cs
- IncrementalHitTester.cs
- ZipIOExtraFieldZip64Element.cs
- Int64.cs
- LocalIdCollection.cs
- HostSecurityManager.cs
- ToolStripComboBox.cs
- FixedDocumentPaginator.cs
- MsmqOutputMessage.cs
- PriorityRange.cs
- CroppedBitmap.cs
- DrawListViewColumnHeaderEventArgs.cs
- TypefaceCollection.cs
- JsonUriDataContract.cs
- PolicyLevel.cs
- ConfigXmlWhitespace.cs
- SamlAuthorizationDecisionStatement.cs
- DocumentOrderQuery.cs
- DecoderFallbackWithFailureFlag.cs
- GAC.cs
- SqlOuterApplyReducer.cs
- OneOf.cs
- ImageListDesigner.cs
- Util.cs
- MetadataArtifactLoader.cs
- ListItemCollection.cs
- PenContexts.cs
- EntityDataSourceChangingEventArgs.cs
- HttpEncoderUtility.cs
- ClientBuildManagerCallback.cs
- PropertyGrid.cs
- ApplicationDirectoryMembershipCondition.cs
- WebSysDisplayNameAttribute.cs
- SessionStateContainer.cs
- SortedList.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- ContextTokenTypeConverter.cs
- ElapsedEventArgs.cs
- MemoryStream.cs
- DateTimeSerializationSection.cs
- CorruptingExceptionCommon.cs
- ConditionValidator.cs
- Debug.cs
- EndEvent.cs
- SecurityRuntime.cs
- ComponentCollection.cs
- DoWorkEventArgs.cs
- DataListItemEventArgs.cs
- DataSetFieldSchema.cs
- Validator.cs