Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ToolStripMenuItemCodeDomSerializer.cs / 1 / ToolStripMenuItemCodeDomSerializer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.ToolStripMenuItemCodeDomSerializer..ctor()")] namespace System.Windows.Forms.Design { using System; using System.Diagnostics; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; ////// The Reason for having a CustomSerializer for ToolStripMenuItem is the existance of Dummy ToolStripMenuItem for ContextMenuStrips. /// We add this Dummy ToolStripMenuItem on the "Non Site" ToolStrip to Host the DropDown which facilitates the entry of New MenuItems. /// These items are then added to the ContextMenuStrip that we are designing. /// But we dont want the Dummy ToolStripMenuItem to Serialize and hence the need for this Custom Serializer. /// internal class ToolStripMenuItemCodeDomSerializer : System.ComponentModel.Design.Serialization.CodeDomSerializer { ////// We implement this for the abstract method on CodeDomSerializer. /// public override object Deserialize(IDesignerSerializationManager manager, object codeObject) { return GetBaseSerializer(manager).Deserialize(manager, codeObject); } ////// This is a small helper method that returns the serializer for base Class /// private CodeDomSerializer GetBaseSerializer(IDesignerSerializationManager manager) { return (CodeDomSerializer)manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer)); } ////// /// We implement this for the abstract method on CodeDomSerializer. This method /// takes an object graph, and serializes the object into CodeDom elements. /// public override object Serialize(IDesignerSerializationManager manager, object value) { ToolStripMenuItem item = value as ToolStripMenuItem; ToolStrip parent = item.GetCurrentParent() as ToolStrip; //Dont Serialize if we are Dummy Item ... if ((item != null) && !(item.IsOnDropDown) && (parent != null) && (parent .Site == null)) { //dont serialize anything... return null; } else { CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer)); return baseSerializer.Serialize(manager, value); } } } } // 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
- EntityClassGenerator.cs
- TextEffect.cs
- WeakReadOnlyCollection.cs
- FolderNameEditor.cs
- CacheDependency.cs
- ConcurrentStack.cs
- DesignerCommandAdapter.cs
- NetSectionGroup.cs
- SchemaElementLookUpTable.cs
- GZipUtils.cs
- EntityConnectionStringBuilder.cs
- RequestCacheManager.cs
- RbTree.cs
- NativeRecognizer.cs
- QilInvoke.cs
- EntityDataSourceColumn.cs
- ExceptionUtil.cs
- HandoffBehavior.cs
- Completion.cs
- TransactionsSectionGroup.cs
- ParameterToken.cs
- httpstaticobjectscollection.cs
- KeyEvent.cs
- Trigger.cs
- NegotiateStream.cs
- CodeExpressionCollection.cs
- Function.cs
- ToolBarButtonDesigner.cs
- CustomAttribute.cs
- StorageEntityTypeMapping.cs
- PrintControllerWithStatusDialog.cs
- ListViewCancelEventArgs.cs
- FileInfo.cs
- ClientUrlResolverWrapper.cs
- TransactionBridge.cs
- AppSettingsExpressionBuilder.cs
- IISMapPath.cs
- RoleManagerEventArgs.cs
- StringUtil.cs
- CatalogUtil.cs
- CommonRemoteMemoryBlock.cs
- XmlNullResolver.cs
- SpotLight.cs
- XmlDeclaration.cs
- SecureUICommand.cs
- ValidatorCompatibilityHelper.cs
- ConfigurationErrorsException.cs
- WebPartMovingEventArgs.cs
- ListViewCancelEventArgs.cs
- ListBoxItemWrapperAutomationPeer.cs
- Sequence.cs
- FormsAuthenticationModule.cs
- ReferencedAssembly.cs
- HighContrastHelper.cs
- PermissionSet.cs
- SerializationSectionGroup.cs
- ISSmlParser.cs
- FastEncoderWindow.cs
- XamlFigureLengthSerializer.cs
- TypeResolvingOptionsAttribute.cs
- _ProxyRegBlob.cs
- Hashtable.cs
- ConfigurationLoaderException.cs
- altserialization.cs
- Effect.cs
- EntityDataSourceChangedEventArgs.cs
- PasswordPropertyTextAttribute.cs
- BinaryQueryOperator.cs
- XmlSchemaNotation.cs
- HotSpotCollection.cs
- OptimizedTemplateContent.cs
- HorizontalAlignConverter.cs
- SafeRegistryKey.cs
- ProxyBuilder.cs
- DoubleCollection.cs
- exports.cs
- WindowProviderWrapper.cs
- InstanceDataCollection.cs
- TypeDescriptionProvider.cs
- AnnotationResourceChangedEventArgs.cs
- SiteMapNodeItemEventArgs.cs
- RoutedCommand.cs
- PocoEntityKeyStrategy.cs
- WebPartHelpVerb.cs
- HttpProfileGroupBase.cs
- InstanceDataCollectionCollection.cs
- UriTemplateLiteralPathSegment.cs
- SystemDropShadowChrome.cs
- ILGen.cs
- TypeInformation.cs
- ComponentRenameEvent.cs
- OptimizedTemplateContentHelper.cs
- MenuItemStyleCollection.cs
- MimeWriter.cs
- WebHeaderCollection.cs
- ConsumerConnectionPointCollection.cs
- ResourceAssociationTypeEnd.cs
- CacheVirtualItemsEvent.cs
- OleDbMetaDataFactory.cs
- ConstructorArgumentAttribute.cs