Code:
/ FX-1434 / FX-1434 / 1.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
- MetadataCache.cs
- HashMembershipCondition.cs
- GlobalizationSection.cs
- Int16.cs
- ThrowHelper.cs
- CanonicalXml.cs
- ClrPerspective.cs
- WizardPanel.cs
- SectionVisual.cs
- TokenBasedSet.cs
- KeyboardDevice.cs
- SyndicationSerializer.cs
- SQLSingleStorage.cs
- HyperLinkField.cs
- StructuredCompositeActivityDesigner.cs
- TreeWalkHelper.cs
- KeyInterop.cs
- RelationalExpressions.cs
- VScrollBar.cs
- SystemIcmpV4Statistics.cs
- messageonlyhwndwrapper.cs
- ScrollItemPattern.cs
- SourceInterpreter.cs
- invalidudtexception.cs
- TaiwanCalendar.cs
- StyleSheetComponentEditor.cs
- ObjectListCommandsPage.cs
- RequestSecurityTokenForGetBrowserToken.cs
- TextWriter.cs
- RunWorkerCompletedEventArgs.cs
- UInt16.cs
- CodeObject.cs
- IUnknownConstantAttribute.cs
- ObjectConverter.cs
- RecommendedAsConfigurableAttribute.cs
- Script.cs
- XmlImplementation.cs
- SslStreamSecurityBindingElement.cs
- InputReferenceExpression.cs
- WebPartDisplayModeCancelEventArgs.cs
- SemanticKeyElement.cs
- MobileSysDescriptionAttribute.cs
- TypeDependencyAttribute.cs
- SectionUpdates.cs
- SqlProcedureAttribute.cs
- BindingNavigatorDesigner.cs
- TrustManager.cs
- ReadOnlyHierarchicalDataSource.cs
- CompiledRegexRunnerFactory.cs
- XpsFixedPageReaderWriter.cs
- SecurityCriticalDataForSet.cs
- VerificationAttribute.cs
- CounterSampleCalculator.cs
- TargetFrameworkAttribute.cs
- followingquery.cs
- ScriptResourceAttribute.cs
- NestedContainer.cs
- SendSecurityHeaderElement.cs
- FlagsAttribute.cs
- BoundField.cs
- sqlmetadatafactory.cs
- WebPartCollection.cs
- CompilerState.cs
- RuleDefinitions.cs
- WebPartHelpVerb.cs
- IISMapPath.cs
- ZipIOLocalFileHeader.cs
- HMACMD5.cs
- HostedAspNetEnvironment.cs
- LocalizationParserHooks.cs
- SignatureHelper.cs
- StaticFileHandler.cs
- ResourceManagerWrapper.cs
- TextUtf8RawTextWriter.cs
- WinEventHandler.cs
- ComplexTypeEmitter.cs
- CheckBox.cs
- ThicknessKeyFrameCollection.cs
- PersonalizationProvider.cs
- AssemblyName.cs
- SizeLimitedCache.cs
- Container.cs
- CompoundFileStreamReference.cs
- SynchronousChannel.cs
- CodeAttachEventStatement.cs
- TransactionContextManager.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ScriptResourceHandler.cs
- MachineKey.cs
- VoiceSynthesis.cs
- DefaultEventAttribute.cs
- TdsEnums.cs
- DiscreteKeyFrames.cs
- WebContext.cs
- ObjectRef.cs
- Tag.cs
- ColorMap.cs
- Int16KeyFrameCollection.cs
- NewExpression.cs
- TypeNameConverter.cs