Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ImageCollectionCodeDomSerializer.cs / 1 / ImageCollectionCodeDomSerializer.cs
namespace System.Windows.Forms.Design { using System.Design; using System.CodeDom; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Reflection; using System.ComponentModel.Design.Serialization; using System.Collections.Specialized; using System.Windows.Forms; ////// /// This serializer serializes string dictionaries. /// // public class ImageListCodeDomSerializer : CodeDomSerializer { ////// /// This method takes a CodeDomObject and deserializes into a real object. /// We don't do anything here. /// public override object Deserialize(IDesignerSerializationManager manager, object codeObject) { // if (manager == null || codeObject == null) { throw new ArgumentNullException( manager == null ? "manager" : "codeObject"); } // Find our base class's serializer. // CodeDomSerializer serializer = (CodeDomSerializer)manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer)); if (serializer == null) { Debug.Fail("Unable to find a CodeDom serializer for 'Component'. Has someone tampered with the serialization providers?"); return null; } return serializer.Deserialize(manager, codeObject); } ////// /// Serializes the given object into a CodeDom object. /// public override object Serialize(IDesignerSerializationManager manager, object value) { CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer)); object codeObject = baseSerializer.Serialize(manager, value); ImageList imageList = value as ImageList; if (imageList != null) { StringCollection imageKeys = imageList.Images.Keys; if (codeObject is CodeStatementCollection) { CodeExpression imageListObject = GetExpression(manager, value); if (imageListObject != null) { CodeExpression imageListImagesProperty = new CodePropertyReferenceExpression(imageListObject, "Images"); if (imageListImagesProperty != null) { for (int i = 0; i < imageKeys.Count; i++) { if ((imageKeys[i] != null) || (imageKeys[i].Length != 0)){ CodeMethodInvokeExpression setNameMethodCall = new CodeMethodInvokeExpression(imageListImagesProperty, "SetKeyName", new CodeExpression [] { new CodePrimitiveExpression(i), // SetKeyName(int, new CodePrimitiveExpression(imageKeys[i]) // string); }); ((CodeStatementCollection)codeObject).Add(setNameMethodCall); } } } } } } return codeObject; } } // Class ImageListCodeDomSerializer } // Namespace System.Windows.Forms.Design // 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
- MenuStrip.cs
- RelationshipConstraintValidator.cs
- AsyncCompletedEventArgs.cs
- ProfilePropertySettings.cs
- RC2CryptoServiceProvider.cs
- SqlDataSourceParameterParser.cs
- RegexStringValidator.cs
- ServiceModelEnumValidator.cs
- AssemblyBuilderData.cs
- MatrixTransform.cs
- BuildProviderCollection.cs
- XmlDictionaryWriter.cs
- HttpCapabilitiesSectionHandler.cs
- EventDescriptorCollection.cs
- CommandSet.cs
- ProfileGroupSettingsCollection.cs
- MenuItemAutomationPeer.cs
- ArgIterator.cs
- LexicalChunk.cs
- GenericPrincipal.cs
- AnnotationStore.cs
- RowUpdatedEventArgs.cs
- SqlProvider.cs
- SimpleBitVector32.cs
- ElementInit.cs
- LeafCellTreeNode.cs
- ScriptReference.cs
- MessageEventSubscriptionService.cs
- BufferedMessageData.cs
- Hash.cs
- __ConsoleStream.cs
- DataBoundControlHelper.cs
- CompareInfo.cs
- SqlUserDefinedTypeAttribute.cs
- MatrixAnimationUsingPath.cs
- SSmlParser.cs
- GuidConverter.cs
- HtmlProps.cs
- HTMLTagNameToTypeMapper.cs
- WinEventQueueItem.cs
- FunctionUpdateCommand.cs
- Token.cs
- SqlNotificationRequest.cs
- ViewStateException.cs
- complextypematerializer.cs
- clipboard.cs
- NetTcpSection.cs
- LocatorManager.cs
- Debug.cs
- SynchronizationLockException.cs
- ContentElement.cs
- EmptyQuery.cs
- RtType.cs
- CustomValidator.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- AnnotationResource.cs
- mongolianshape.cs
- AuthorizationRuleCollection.cs
- PropertyValueUIItem.cs
- AgileSafeNativeMemoryHandle.cs
- SafeFileMapViewHandle.cs
- MdiWindowListItemConverter.cs
- UntrustedRecipientException.cs
- JsonWriter.cs
- IxmlLineInfo.cs
- MasterPageParser.cs
- Matrix3DConverter.cs
- EpmSourcePathSegment.cs
- XslUrlEditor.cs
- SqlTypeSystemProvider.cs
- Transform3D.cs
- ValidatorCollection.cs
- Fonts.cs
- AttributeTable.cs
- TrayIconDesigner.cs
- WebServiceBindingAttribute.cs
- StyleCollection.cs
- DefaultValueAttribute.cs
- Opcode.cs
- XmlAttributeCollection.cs
- SmiConnection.cs
- ConfigXmlElement.cs
- RenderTargetBitmap.cs
- XmlSchemas.cs
- AttachedPropertyBrowsableAttribute.cs
- ByteBufferPool.cs
- SettingsBindableAttribute.cs
- SqlDataSource.cs
- ForEachAction.cs
- SecurityPolicySection.cs
- ToolStripArrowRenderEventArgs.cs
- DbTypeMap.cs
- ExpanderAutomationPeer.cs
- ApplicationTrust.cs
- ExpandSegment.cs
- ObjectDataProvider.cs
- BooleanProjectedSlot.cs
- ResumeStoryboard.cs
- CodeIdentifier.cs
- SqlExpander.cs