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
- TrackingProfileSerializer.cs
- StorageSetMapping.cs
- WebPartsSection.cs
- NativeMethods.cs
- TdsParserSafeHandles.cs
- SystemWebSectionGroup.cs
- DataSvcMapFile.cs
- ResourceIDHelper.cs
- EventTrigger.cs
- CreateParams.cs
- Resources.Designer.cs
- ProfileSection.cs
- DataControlLinkButton.cs
- SkipStoryboardToFill.cs
- SQLSingle.cs
- ProgressBarBrushConverter.cs
- OutputCacheModule.cs
- BinHexEncoder.cs
- BinaryFormatterWriter.cs
- __ComObject.cs
- RequestCache.cs
- CodeParameterDeclarationExpressionCollection.cs
- ConstantCheck.cs
- ConfigXmlReader.cs
- ConfigXmlComment.cs
- TraceProvider.cs
- ProcessManager.cs
- TextDecoration.cs
- GridProviderWrapper.cs
- ObjectDataSourceStatusEventArgs.cs
- Opcode.cs
- ArraySortHelper.cs
- SqlRewriteScalarSubqueries.cs
- FontFamilyIdentifier.cs
- RelationshipNavigation.cs
- FontResourceCache.cs
- Int32CAMarshaler.cs
- SetterBaseCollection.cs
- DiagnosticTraceSchemas.cs
- MediaContextNotificationWindow.cs
- EntitySetDataBindingList.cs
- PackageStore.cs
- DataGridViewBindingCompleteEventArgs.cs
- RequiredAttributeAttribute.cs
- CollectionDataContract.cs
- SchemaNamespaceManager.cs
- Matrix.cs
- TabPage.cs
- StylusEditingBehavior.cs
- PerformanceCountersElement.cs
- OracleDateTime.cs
- XmlEventCache.cs
- ManipulationDevice.cs
- ScrollProperties.cs
- XPathNavigatorReader.cs
- HtmlAnchor.cs
- DockAndAnchorLayout.cs
- FileDialog.cs
- PenThreadWorker.cs
- Point3DAnimationUsingKeyFrames.cs
- EntitySetBase.cs
- SqlInternalConnectionSmi.cs
- ComplusEndpointConfigContainer.cs
- BitmapDownload.cs
- LogicalTreeHelper.cs
- OuterGlowBitmapEffect.cs
- BooleanAnimationUsingKeyFrames.cs
- EmptyEnumerator.cs
- ModelPropertyDescriptor.cs
- RootProfilePropertySettingsCollection.cs
- Authorization.cs
- oledbconnectionstring.cs
- DoWorkEventArgs.cs
- TransactionCache.cs
- ProxyWebPartConnectionCollection.cs
- SecurityDescriptor.cs
- TextUtf8RawTextWriter.cs
- ServiceOperation.cs
- SafeReversePInvokeHandle.cs
- HttpHeaderCollection.cs
- DecimalAnimation.cs
- sqlmetadatafactory.cs
- TextFormatterContext.cs
- MulticastNotSupportedException.cs
- DialogWindow.cs
- WebPartDisplayModeEventArgs.cs
- InvalidFilterCriteriaException.cs
- ValueTypeIndexerReference.cs
- FigureParaClient.cs
- HostingEnvironmentSection.cs
- FlowDocumentPaginator.cs
- DateTimeFormatInfo.cs
- MostlySingletonList.cs
- BamlRecords.cs
- Rfc2898DeriveBytes.cs
- PageBuildProvider.cs
- ImageMapEventArgs.cs
- RepeaterCommandEventArgs.cs
- CompilerParameters.cs
- PermissionAttributes.cs