Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / CompMod / System / ComponentModel / Design / Serialization / CodeDomSerializationProvider.cs / 1 / CodeDomSerializationProvider.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel.Design.Serialization { using System.Design; using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Resources; using System.Runtime.Serialization; using System.Globalization; ////// /// This is the serialization provider for all code dom serializers. /// internal sealed class CodeDomSerializationProvider : IDesignerSerializationProvider { ////// Returns a code dom serializer /// private object GetCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType) { // If this isn't a serializer type we recognize, do nothing. Also, if metadata specified // a custom serializer, then use it. if (currentSerializer != null) { return null; } // Null is a valid value that can be passed into GetSerializer. It indicates // that the value we need to serialize is null, in which case we handle it // through the PrimitiveCodeDomSerializer. // if (objectType == null) { return PrimitiveCodeDomSerializer.Default; } // Support for components. // if (typeof(IComponent).IsAssignableFrom(objectType)) { return ComponentCodeDomSerializer.Default; } // We special case enums. They do have instance descriptors, but we want // better looking code than the instance descriptor can provide for flags, // so we do it ourselves. // if (typeof(Enum).IsAssignableFrom(objectType)) { return EnumCodeDomSerializer.Default; } // We will provide a serializer for any intrinsic types. // if (objectType.IsPrimitive || objectType.IsEnum || objectType == typeof(string)) { return PrimitiveCodeDomSerializer.Default; } // And one for collections. // if (typeof(ICollection).IsAssignableFrom(objectType)) { return CollectionCodeDomSerializer.Default; } // And one for IContainer if (typeof(IContainer).IsAssignableFrom(objectType)) { return ContainerCodeDomSerializer.Default; } // And one for resources // if (typeof(ResourceManager).IsAssignableFrom(objectType)) { return ResourceCodeDomSerializer.Default; } // The default serializer can do any object including those with instance descriptors. return CodeDomSerializer.Default; } ////// Returns a code dom serializer for members /// private object GetMemberCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType) { // Don't provide our serializer if someone else already had one if (currentSerializer != null) { return null; } if (typeof(PropertyDescriptor).IsAssignableFrom(objectType)) { return PropertyMemberCodeDomSerializer.Default; } if (typeof(EventDescriptor).IsAssignableFrom(objectType)) { return EventMemberCodeDomSerializer.Default; } return null; } ////// Returns a code dom serializer for types /// private object GetTypeCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType) { // Don't provide our serializer if someone else already had one if (currentSerializer != null) { return null; } if (typeof(IComponent).IsAssignableFrom(objectType)) { return ComponentTypeCodeDomSerializer.Default; } return TypeCodeDomSerializer.Default; } ////// /// This will be called by the serialization manager when it /// is trying to locate a serialzer for an object type. /// If this serialization provider can provide a serializer /// that is of the correct type, it should return it. /// Otherwise, it should return null. /// object IDesignerSerializationProvider.GetSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType) { if (serializerType == typeof(CodeDomSerializer)) { return GetCodeDomSerializer(manager, currentSerializer, objectType, serializerType); } else if (serializerType == typeof(MemberCodeDomSerializer)) { return GetMemberCodeDomSerializer(manager, currentSerializer, objectType, serializerType); } else if (serializerType == typeof(TypeCodeDomSerializer)) { return GetTypeCodeDomSerializer(manager, currentSerializer, objectType, serializerType); } return null; // don't understand this type of serializer. } } } // 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
- XmlEnumAttribute.cs
- GradientBrush.cs
- FileSystemEnumerable.cs
- StatusBar.cs
- HtmlGenericControl.cs
- SAPIEngineTypes.cs
- AppSettingsSection.cs
- CommonProperties.cs
- CodeMethodReturnStatement.cs
- ModifyActivitiesPropertyDescriptor.cs
- XmlAnyAttributeAttribute.cs
- XamlReaderHelper.cs
- ArraySubsetEnumerator.cs
- PLINQETWProvider.cs
- ApplicationServiceManager.cs
- RealProxy.cs
- PropertyInfoSet.cs
- XmlDocumentType.cs
- ByteAnimationBase.cs
- PageRanges.cs
- MenuCommandService.cs
- GridViewPageEventArgs.cs
- BehaviorEditorPart.cs
- PointCollection.cs
- EncodingStreamWrapper.cs
- PersonalizationProviderHelper.cs
- InstanceLockLostException.cs
- ConvertEvent.cs
- KnowledgeBase.cs
- SimplePropertyEntry.cs
- JapaneseCalendar.cs
- PropertyDescriptorComparer.cs
- PictureBox.cs
- TextHintingModeValidation.cs
- BindingGroup.cs
- ObjectListCommandsPage.cs
- ThumbAutomationPeer.cs
- FileAuthorizationModule.cs
- OleDbRowUpdatingEvent.cs
- DefaultPropertiesToSend.cs
- CatalogZone.cs
- SatelliteContractVersionAttribute.cs
- UnionQueryOperator.cs
- CodeTypeReferenceCollection.cs
- EditableTreeList.cs
- CreatingCookieEventArgs.cs
- MenuTracker.cs
- CodeDOMUtility.cs
- ConfigXmlDocument.cs
- ControlBindingsConverter.cs
- DataBindingCollectionConverter.cs
- MultiBinding.cs
- QilGeneratorEnv.cs
- IsolatedStorageFilePermission.cs
- ControlValuePropertyAttribute.cs
- TextDecoration.cs
- WpfXamlLoader.cs
- PasswordPropertyTextAttribute.cs
- WorkflowInstanceUnhandledExceptionRecord.cs
- CompositeDataBoundControl.cs
- Point.cs
- DoubleCollectionConverter.cs
- __TransparentProxy.cs
- GregorianCalendar.cs
- login.cs
- EtwTrackingBehavior.cs
- CodeMemberProperty.cs
- ConnectivityStatus.cs
- BrowsableAttribute.cs
- BasicBrowserDialog.cs
- HitTestWithPointDrawingContextWalker.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- TreeNode.cs
- InsufficientExecutionStackException.cs
- QilLoop.cs
- UseManagedPresentationElement.cs
- ZipIOModeEnforcingStream.cs
- OleDbStruct.cs
- CompiledRegexRunner.cs
- DataColumnPropertyDescriptor.cs
- OleServicesContext.cs
- DataGridTablesFactory.cs
- ReachIDocumentPaginatorSerializer.cs
- XmlDataImplementation.cs
- RichTextBoxDesigner.cs
- Roles.cs
- TransformGroup.cs
- DeploymentExceptionMapper.cs
- ProxySimple.cs
- TranslateTransform.cs
- RayHitTestParameters.cs
- PrePostDescendentsWalker.cs
- SchemaTableOptionalColumn.cs
- UrlPath.cs
- latinshape.cs
- RegexMatchCollection.cs
- Point3DConverter.cs
- FullTrustAssembly.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ContourSegment.cs