Code:
/ FX-1434 / FX-1434 / 1.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
- HttpListenerRequestUriBuilder.cs
- SqlVersion.cs
- UIElementCollection.cs
- TriggerAction.cs
- XmlSchemaValidator.cs
- DesignTimeVisibleAttribute.cs
- SingleTagSectionHandler.cs
- HostingEnvironmentException.cs
- IntSecurity.cs
- HttpDebugHandler.cs
- Util.cs
- SoapMessage.cs
- BasicExpressionVisitor.cs
- GetMemberBinder.cs
- FileVersionInfo.cs
- X509WindowsSecurityToken.cs
- DataServiceResponse.cs
- ScaleTransform.cs
- FixedSOMPageConstructor.cs
- EpmAttributeNameBuilder.cs
- NotCondition.cs
- ReceiveMessageRecord.cs
- ProfileService.cs
- ResourceType.cs
- Token.cs
- SchemaImporter.cs
- XmlSchemaElement.cs
- StrokeFIndices.cs
- ProxyGenerator.cs
- AnnotationComponentChooser.cs
- XMLUtil.cs
- RouteUrlExpressionBuilder.cs
- SortQuery.cs
- TreeNodeCollectionEditor.cs
- RayHitTestParameters.cs
- FileIOPermission.cs
- Material.cs
- WebRequestModuleElement.cs
- FunctionParameter.cs
- Matrix.cs
- PropertyMapper.cs
- XmlDeclaration.cs
- FixedBufferAttribute.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- HwndMouseInputProvider.cs
- SqlRowUpdatingEvent.cs
- ImageKeyConverter.cs
- XamlBuildTaskServices.cs
- LogicalTreeHelper.cs
- CornerRadius.cs
- DataGridColumnCollection.cs
- ClientTargetCollection.cs
- XmlIncludeAttribute.cs
- ColorMap.cs
- GridItemProviderWrapper.cs
- NumberSubstitution.cs
- GcHandle.cs
- PngBitmapEncoder.cs
- MouseOverProperty.cs
- SimpleBitVector32.cs
- StorageScalarPropertyMapping.cs
- CaseExpr.cs
- EntityException.cs
- BadImageFormatException.cs
- ColumnWidthChangedEvent.cs
- RelativeSource.cs
- MessageDesigner.cs
- OdbcException.cs
- XmlKeywords.cs
- DataListItemEventArgs.cs
- JapaneseLunisolarCalendar.cs
- InputScopeAttribute.cs
- DataGridViewCellPaintingEventArgs.cs
- MailDefinition.cs
- PrintingPermissionAttribute.cs
- SymmetricAlgorithm.cs
- UserControlParser.cs
- GroupLabel.cs
- StylusTip.cs
- WebServiceAttribute.cs
- TextEndOfParagraph.cs
- BridgeDataRecord.cs
- IisHelper.cs
- ComponentEditorForm.cs
- DropAnimation.xaml.cs
- SectionRecord.cs
- BindingManagerDataErrorEventArgs.cs
- SqlCachedBuffer.cs
- SparseMemoryStream.cs
- CharStorage.cs
- OutKeywords.cs
- TypedReference.cs
- SafeEventLogWriteHandle.cs
- SimpleType.cs
- HeaderedContentControl.cs
- HashMembershipCondition.cs
- XmlSchemaExternal.cs
- ConditionCollection.cs
- sqlcontext.cs
- RepeaterCommandEventArgs.cs