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 { ////// /// 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); } ////// Initializes a new instance of the 'InstanceNameConverter' class for the given type. /// ////// /// /// 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 collection of standard values for the data type this validator is /// designed for. ////// /// /// 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.Gets a value indicating /// whether this object /// supports a standard set of values that can be picked /// from a list using the specified context. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlMethodTransformer.cs
- IsolatedStorageFilePermission.cs
- CapabilitiesSection.cs
- OutOfProcStateClientManager.cs
- KoreanCalendar.cs
- FontStyles.cs
- TableStyle.cs
- DataGridViewCellStyleConverter.cs
- InvalidOleVariantTypeException.cs
- HtmlInputPassword.cs
- BindingList.cs
- DoubleStorage.cs
- SyndicationCategory.cs
- MethodAccessException.cs
- LoadRetryAsyncResult.cs
- Addressing.cs
- DataExpression.cs
- MetadataException.cs
- Freezable.cs
- LowerCaseStringConverter.cs
- CountAggregationOperator.cs
- CounterCreationData.cs
- EntityContainer.cs
- FilterUserControlBase.cs
- MouseActionConverter.cs
- DataSourceXmlSerializer.cs
- MatrixIndependentAnimationStorage.cs
- UpdateTranslator.cs
- ListViewGroup.cs
- RawTextInputReport.cs
- AsnEncodedData.cs
- AmbientLight.cs
- BindingEntityInfo.cs
- AssemblyCache.cs
- InstanceDataCollection.cs
- ProviderMetadataCachedInformation.cs
- Point.cs
- ToolboxItemSnapLineBehavior.cs
- ContentType.cs
- TemplateBuilder.cs
- DataGridViewLayoutData.cs
- DataGridBoolColumn.cs
- DebugInfoGenerator.cs
- ActivityExecutionContext.cs
- TakeQueryOptionExpression.cs
- WebPartDescriptionCollection.cs
- WindowShowOrOpenTracker.cs
- RecipientIdentity.cs
- ItemsPanelTemplate.cs
- DataServiceSaveChangesEventArgs.cs
- PerformanceCounterPermissionEntry.cs
- PropertyGroupDescription.cs
- HierarchicalDataTemplate.cs
- NamedPipeChannelFactory.cs
- XmlNodeReader.cs
- DesignTimeType.cs
- ChangeDirector.cs
- Stream.cs
- WebRequest.cs
- ViewGenerator.cs
- SubMenuStyleCollection.cs
- QuadraticBezierSegment.cs
- ViewBase.cs
- CryptoHandle.cs
- DesignerVerbCollection.cs
- TextContainer.cs
- DrawItemEvent.cs
- StyleXamlTreeBuilder.cs
- ParallelQuery.cs
- DesignerTransactionCloseEvent.cs
- XmlElementList.cs
- NameValueSectionHandler.cs
- RequestCachingSection.cs
- SystemWebSectionGroup.cs
- SchemaObjectWriter.cs
- TextViewSelectionProcessor.cs
- ExpressionBindingCollection.cs
- ObjectStateEntry.cs
- OperandQuery.cs
- DefaultValidator.cs
- XmlSchemaGroup.cs
- RangeValueProviderWrapper.cs
- ToolTip.cs
- FixedStringLookup.cs
- ApplicationActivator.cs
- ListBase.cs
- WorkflowMarkupElementEventArgs.cs
- OleDbParameterCollection.cs
- PagesChangedEventArgs.cs
- NavigationEventArgs.cs
- LineBreak.cs
- ConfigurationStrings.cs
- TableItemStyle.cs
- ClientSection.cs
- ReadOnlyDataSourceView.cs
- DiagnosticTrace.cs
- InputLangChangeRequestEvent.cs
- ClassValidator.cs
- EntityContainerEmitter.cs
- TreeViewDesigner.cs