Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / CounterNameConverter.cs / 1 / CounterNameConverter.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 CounterNameConverter : TypeConverter { ////// /// public CounterNameConverter() { } 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 'CounterNameConverter' 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[] instanceNames = cat.GetInstanceNames(); PerformanceCounter[] counters = null; if (instanceNames.Length == 0) counters = cat.GetCounters(); else counters = cat.GetCounters(instanceNames[0]); string[] retVal = new string[counters.Length]; for (int i = 0; i < counters.Length; i++) { retVal[i] = counters[i].CounterName; } 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
- HtmlGenericControl.cs
- ObjectDataProvider.cs
- Documentation.cs
- CharacterShapingProperties.cs
- SharedDp.cs
- _NTAuthentication.cs
- BrowsableAttribute.cs
- StreamGeometryContext.cs
- PowerStatus.cs
- NamespaceTable.cs
- StructuralCache.cs
- SpellerHighlightLayer.cs
- ShaderRenderModeValidation.cs
- DbException.cs
- SchemaType.cs
- SwitchLevelAttribute.cs
- FontUnit.cs
- AuthenticationModuleElementCollection.cs
- DecoderBestFitFallback.cs
- AnnotationMap.cs
- TemplatePagerField.cs
- RegisteredDisposeScript.cs
- MenuScrollingVisibilityConverter.cs
- TextDecoration.cs
- View.cs
- ContentValidator.cs
- ControlFilterExpression.cs
- DataGridViewImageColumn.cs
- ComponentSerializationService.cs
- HwndSourceKeyboardInputSite.cs
- PrintPreviewGraphics.cs
- ZoneMembershipCondition.cs
- FlowDocumentPageViewerAutomationPeer.cs
- BitmapDecoder.cs
- _AuthenticationState.cs
- HTTPAPI_VERSION.cs
- TableHeaderCell.cs
- DbProviderFactories.cs
- SignedInfo.cs
- ProcessRequestArgs.cs
- BufferedReadStream.cs
- FrameworkTemplate.cs
- securitymgrsite.cs
- DirectoryInfo.cs
- SessionState.cs
- DataPager.cs
- DirectoryNotFoundException.cs
- SecureConversationSecurityTokenParameters.cs
- MetafileHeaderEmf.cs
- ControlType.cs
- StandardBindingOptionalReliableSessionElement.cs
- PathData.cs
- sqlser.cs
- PageContentCollection.cs
- DictionaryTraceRecord.cs
- ImageCodecInfo.cs
- NumericUpDown.cs
- XmlDomTextWriter.cs
- CodeSnippetExpression.cs
- ThrowHelper.cs
- ClientConfigurationHost.cs
- StringDictionary.cs
- SqlBuilder.cs
- StringStorage.cs
- WeakEventManager.cs
- ColumnWidthChangedEvent.cs
- EventWaitHandle.cs
- WS2007HttpBindingElement.cs
- ConfigurationSectionHelper.cs
- IsolatedStorageFileStream.cs
- DummyDataSource.cs
- PaintEvent.cs
- ZipIOLocalFileHeader.cs
- MissingMethodException.cs
- UInt16Converter.cs
- SignedXml.cs
- XmlFormatMapping.cs
- XmlSchemaAll.cs
- ActivityBuilderHelper.cs
- ParameterToken.cs
- ConfigXmlReader.cs
- RequestCachingSection.cs
- GC.cs
- SqlNodeAnnotation.cs
- ControlBuilder.cs
- ScriptControlManager.cs
- CompilationUtil.cs
- StringWriter.cs
- NGCPageContentSerializerAsync.cs
- CanExecuteRoutedEventArgs.cs
- NavigateEvent.cs
- RenderData.cs
- LicenseException.cs
- Workspace.cs
- TableLayout.cs
- NamedPipeConnectionPoolSettings.cs
- GifBitmapDecoder.cs
- ExpressionParser.cs
- SmtpAuthenticationManager.cs
- StateBag.cs