Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / StringDictionaryEditor.cs / 1 / StringDictionaryEditor.cs
namespace System.Diagnostics.Design { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.IO; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Windows.Forms; using System.Drawing; using System.Drawing.Design; using System.Windows.Forms.ComponentModel; using System.Windows.Forms.Design; using System.Collections.Specialized; using System.Design; internal class EditableDictionaryEntry { public string _name; public string _value; public EditableDictionaryEntry(string name, string value) { _name = name; _value = value; } public string Name { get { return _name; } set { _name = value; } } public string Value { get { return _value; } set { _value = value; } } } internal class StringDictionaryEditor : CollectionEditor { public StringDictionaryEditor(Type type) : base(type) {} protected override Type CreateCollectionItemType() { return typeof(EditableDictionaryEntry); } protected override object CreateInstance(Type itemType) { return new EditableDictionaryEntry("name", "value"); } protected override object SetItems(object editValue, object[] value) { StringDictionary dictionary = editValue as StringDictionary; if (dictionary == null) { throw new ArgumentNullException("editValue"); } dictionary.Clear(); foreach (EditableDictionaryEntry entry in value) { dictionary[entry.Name] = entry.Value; } return dictionary; } protected override object[] GetItems(object editValue) { if (editValue != null) { StringDictionary dictionary = editValue as StringDictionary; if (dictionary == null) { throw new ArgumentNullException("editValue"); } object[] ret = new object[dictionary.Count]; int pos = 0; foreach (DictionaryEntry entry in dictionary) { EditableDictionaryEntry newEntry = new EditableDictionaryEntry((string)entry.Key, (string)entry.Value); ret[pos++] = newEntry; } return ret; } return new object[0]; } protected override CollectionForm CreateCollectionForm() { CollectionForm form = base.CreateCollectionForm(); form.Text = SR.GetString(SR.StringDictionaryEditorTitle); form.CollectionEditable = true; return form; } } } // 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
- AddInActivator.cs
- QilVisitor.cs
- XslNumber.cs
- FixedFindEngine.cs
- CodeSubDirectory.cs
- RestClientProxyHandler.cs
- DataServiceProcessingPipelineEventArgs.cs
- FontFaceLayoutInfo.cs
- DataGridViewSelectedColumnCollection.cs
- QilPatternFactory.cs
- XsdSchemaFileEditor.cs
- WindowsGraphics2.cs
- SqlCachedBuffer.cs
- MatrixConverter.cs
- ConsoleKeyInfo.cs
- StylusDownEventArgs.cs
- ApplicationSecurityInfo.cs
- StringFormat.cs
- ToolStripProgressBar.cs
- BoolExpression.cs
- WebContentFormatHelper.cs
- ExtentKey.cs
- ImageCodecInfoPrivate.cs
- BitmapEffectInput.cs
- FreezableCollection.cs
- DocumentSchemaValidator.cs
- InvalidFilterCriteriaException.cs
- Utilities.cs
- TaskFormBase.cs
- AttributeCollection.cs
- FlowDocumentReader.cs
- CapabilitiesRule.cs
- RewritingValidator.cs
- String.cs
- XmlSchemaProviderAttribute.cs
- UnaryNode.cs
- MediaContextNotificationWindow.cs
- TextBoxLine.cs
- ComponentSerializationService.cs
- OletxCommittableTransaction.cs
- SourceItem.cs
- BaseInfoTable.cs
- Rfc2898DeriveBytes.cs
- XPathSelectionIterator.cs
- DispatchWrapper.cs
- DbConnectionStringBuilder.cs
- CharacterHit.cs
- printdlgexmarshaler.cs
- BasicCellRelation.cs
- HttpBrowserCapabilitiesWrapper.cs
- Soap.cs
- HandlerWithFactory.cs
- KeyGesture.cs
- IntPtr.cs
- DrawToolTipEventArgs.cs
- PassportIdentity.cs
- WorkflowDesignerColors.cs
- SmtpNtlmAuthenticationModule.cs
- SystemNetworkInterface.cs
- SqlServer2KCompatibilityAnnotation.cs
- Content.cs
- PrintPreviewGraphics.cs
- Accessible.cs
- dtdvalidator.cs
- AvTraceDetails.cs
- TextBoxBase.cs
- WorkflowInstanceExtensionProvider.cs
- DateTimeSerializationSection.cs
- FlowLayoutSettings.cs
- WeakReferenceKey.cs
- StreamGeometry.cs
- Bits.cs
- SecurityAlgorithmSuiteConverter.cs
- NativeDirectoryServicesQueryAPIs.cs
- WebPartUtil.cs
- WebConfigurationFileMap.cs
- ThreadPoolTaskScheduler.cs
- Receive.cs
- MetadataItem.cs
- KeyFrames.cs
- PositiveTimeSpanValidator.cs
- MediaTimeline.cs
- CrossAppDomainChannel.cs
- Track.cs
- WebPartMovingEventArgs.cs
- DaylightTime.cs
- ToolStripDropDownMenu.cs
- KeyInfo.cs
- DataGridViewRowPostPaintEventArgs.cs
- EventSourceCreationData.cs
- HeaderedContentControl.cs
- SyndicationDeserializer.cs
- ConfigurationSection.cs
- smtpconnection.cs
- PropertyGridCommands.cs
- DataGridViewColumn.cs
- InfoCardClaim.cs
- MenuItemBindingCollection.cs
- TdsRecordBufferSetter.cs
- WebPartDisplayModeCancelEventArgs.cs