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
- ClientSideProviderDescription.cs
- CapabilitiesAssignment.cs
- ELinqQueryState.cs
- sapiproxy.cs
- dataSvcMapFileLoader.cs
- CapabilitiesUse.cs
- RootBuilder.cs
- DetailsViewCommandEventArgs.cs
- SQLResource.cs
- AuthStoreRoleProvider.cs
- ClientRolePrincipal.cs
- PersonalizationProvider.cs
- ReversePositionQuery.cs
- documentsequencetextview.cs
- Property.cs
- MultipleViewPattern.cs
- TimeSpanStorage.cs
- RightNameExpirationInfoPair.cs
- ShapingWorkspace.cs
- ListViewInsertionMark.cs
- ClientSession.cs
- TraceAsyncResult.cs
- TypeConverters.cs
- HtmlTableCell.cs
- BitVector32.cs
- DecimalAnimation.cs
- RoutedEventValueSerializer.cs
- TextBoxRenderer.cs
- StrokeNodeEnumerator.cs
- EventLevel.cs
- FixedSOMPageConstructor.cs
- OutOfProcStateClientManager.cs
- TextSimpleMarkerProperties.cs
- DataView.cs
- StreamUpdate.cs
- BindingValueChangedEventArgs.cs
- AsymmetricKeyExchangeDeformatter.cs
- FormView.cs
- BufferedWebEventProvider.cs
- ProbeMatchesCD1.cs
- ConfigXmlDocument.cs
- SqlBooleanizer.cs
- CustomCategoryAttribute.cs
- NameSpaceExtractor.cs
- SelectionProcessor.cs
- LinqDataSourceDisposeEventArgs.cs
- ParameterToken.cs
- TextTreeDeleteContentUndoUnit.cs
- FixedSOMGroup.cs
- CmsInterop.cs
- DecimalStorage.cs
- TypeNameHelper.cs
- DataGridToolTip.cs
- ScrollItemPatternIdentifiers.cs
- TransformerTypeCollection.cs
- TextCharacters.cs
- DataGridViewCellPaintingEventArgs.cs
- ObjectStateManagerMetadata.cs
- TrustManagerPromptUI.cs
- DeviceSpecificChoice.cs
- ComponentSerializationService.cs
- SearchForVirtualItemEventArgs.cs
- ProcessInputEventArgs.cs
- SqlProfileProvider.cs
- ReflectPropertyDescriptor.cs
- TextTreeTextElementNode.cs
- ECDsaCng.cs
- StandardCommands.cs
- DSGeneratorProblem.cs
- PixelFormat.cs
- TypedReference.cs
- CodeAttributeArgument.cs
- BitmapEffectGroup.cs
- WindowsGrip.cs
- XmlDocumentType.cs
- EventBuilder.cs
- XmlSerializationGeneratedCode.cs
- ApplicationProxyInternal.cs
- HtmlMeta.cs
- XmlTextReaderImplHelpers.cs
- TextRunTypographyProperties.cs
- ServiceReference.cs
- RuntimeCompatibilityAttribute.cs
- GetTokenRequest.cs
- GifBitmapDecoder.cs
- MimeTypeAttribute.cs
- CategoryAttribute.cs
- CheckBoxPopupAdapter.cs
- AddInControllerImpl.cs
- ShapingEngine.cs
- SizeConverter.cs
- HierarchicalDataSourceDesigner.cs
- InputMethodStateChangeEventArgs.cs
- CompleteWizardStep.cs
- DbConnectionOptions.cs
- EntityDataSourceMemberPath.cs
- EventLogPermissionEntryCollection.cs
- TextMessageEncodingBindingElement.cs
- DataTemplateSelector.cs
- RegexCaptureCollection.cs