Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / InstanceNameConverter.cs / 1 / InstanceNameConverter.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Diagnostics.Design {
using System.Runtime.Serialization.Formatters;
using System.Globalization;
using System.Diagnostics;
using System;
using System.Windows.Forms.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
internal class InstanceNameConverter : TypeConverter {
///
///
///
/// Initializes a new instance of the 'InstanceNameConverter' class for the given type.
///
///
public InstanceNameConverter() {
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
if (sourceType == typeof(string)) {
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
string text = ((string)value).Trim();
return text;
}
return base.ConvertFrom(context, culture, value);
}
///
///
///
/// Gets a collection of standard values for the data type this validator is
/// designed for.
///
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
PerformanceCounter counter = (context == null) ? null : context.Instance as PerformanceCounter;
string machineName = ".";
string categoryName = String.Empty;
if (counter != null) {
machineName = counter.MachineName;
categoryName = counter.CategoryName;
}
try {
PerformanceCounterCategory cat = new PerformanceCounterCategory(categoryName, machineName);
string[] retVal =cat.GetInstanceNames();
Array.Sort(retVal, Comparer.Default);
return new StandardValuesCollection(retVal);
}
catch(Exception) {
; // do nothing
}
return null;
}
///
///
///
/// Gets a value indicating
/// whether this object
/// supports a standard set of values that can be picked
/// from a list using the specified context.
///
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
return true;
}
}
}
// 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
- SqlCacheDependencySection.cs
- ThumbButtonInfoCollection.cs
- LinkUtilities.cs
- WsdlBuildProvider.cs
- ReversePositionQuery.cs
- ComponentEvent.cs
- DataRecordInternal.cs
- AttributeCollection.cs
- ObjectMaterializedEventArgs.cs
- WindowsToolbarAsMenu.cs
- GlyphRunDrawing.cs
- MostlySingletonList.cs
- __Error.cs
- Overlapped.cs
- NavigationPropertyEmitter.cs
- TagPrefixAttribute.cs
- WpfXamlLoader.cs
- CapabilitiesUse.cs
- HelpPage.cs
- Speller.cs
- UserControlFileEditor.cs
- EntityTransaction.cs
- CharStorage.cs
- SafeNativeMethods.cs
- CacheHelper.cs
- DecoderNLS.cs
- TargetPerspective.cs
- WebPartTransformerCollection.cs
- TabRenderer.cs
- FormsAuthenticationCredentials.cs
- DataRowExtensions.cs
- baseaxisquery.cs
- EdmItemCollection.cs
- Socket.cs
- TextSearch.cs
- EventProviderClassic.cs
- XmlnsDictionary.cs
- WebBrowserPermission.cs
- CompileXomlTask.cs
- Hashtable.cs
- SuppressMergeCheckAttribute.cs
- RemotingServices.cs
- NumericUpDown.cs
- XmlObjectSerializerContext.cs
- Int64AnimationBase.cs
- LastQueryOperator.cs
- ModelPropertyCollectionImpl.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- StreamMarshaler.cs
- OrthographicCamera.cs
- MatrixCamera.cs
- HttpVersion.cs
- UnsignedPublishLicense.cs
- WebDescriptionAttribute.cs
- DateTimeOffsetStorage.cs
- FastPropertyAccessor.cs
- SoapSchemaMember.cs
- JoinQueryOperator.cs
- DateTime.cs
- BaseCAMarshaler.cs
- HtmlWindow.cs
- StaticSiteMapProvider.cs
- FlowLayout.cs
- Section.cs
- BatchWriter.cs
- SapiAttributeParser.cs
- InputLangChangeRequestEvent.cs
- ToolStripGrip.cs
- ToolCreatedEventArgs.cs
- LoadMessageLogger.cs
- RuntimeEnvironment.cs
- CustomServiceCredentials.cs
- StringUtil.cs
- PeerNameResolver.cs
- DependencyPropertyKey.cs
- TimeManager.cs
- TextCompositionEventArgs.cs
- XmlDataProvider.cs
- AsyncResult.cs
- SslStream.cs
- DomNameTable.cs
- ThemeableAttribute.cs
- WebPartAuthorizationEventArgs.cs
- CodeTypeParameterCollection.cs
- ThrowHelper.cs
- XmlSchemaAnyAttribute.cs
- LazyTextWriterCreator.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- DataGridItem.cs
- MemberExpressionHelper.cs
- TextElement.cs
- CounterCreationData.cs
- StyleSheetRefUrlEditor.cs
- PartitionedStream.cs
- SuppressMessageAttribute.cs
- BaseAddressElement.cs
- DaylightTime.cs
- XsltException.cs
- PermissionListSet.cs
- Label.cs