Code:
/ DotNET / DotNET / 8.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
- ToolStripItemCollection.cs
- VScrollBar.cs
- _DisconnectOverlappedAsyncResult.cs
- DataGridViewComboBoxEditingControl.cs
- TogglePatternIdentifiers.cs
- HtmlFormWrapper.cs
- FlagsAttribute.cs
- XpsFontSubsetter.cs
- baseaxisquery.cs
- OutKeywords.cs
- HeaderCollection.cs
- StyleSelector.cs
- ListDictionaryInternal.cs
- _ChunkParse.cs
- Memoizer.cs
- CharEnumerator.cs
- MemberDomainMap.cs
- BitStream.cs
- XmlSiteMapProvider.cs
- SQLMembershipProvider.cs
- DistinctQueryOperator.cs
- MemoryFailPoint.cs
- SyndicationDeserializer.cs
- SqlTransaction.cs
- HttpClientCertificate.cs
- PenCursorManager.cs
- SqlBuilder.cs
- DetailsViewInsertedEventArgs.cs
- HwndTarget.cs
- Menu.cs
- OutputCacheSettings.cs
- ByteKeyFrameCollection.cs
- assemblycache.cs
- DateTimeUtil.cs
- DataServiceRequest.cs
- XmlSchemaSubstitutionGroup.cs
- CompoundFileStorageReference.cs
- RandomNumberGenerator.cs
- ByteFacetDescriptionElement.cs
- VarRefManager.cs
- FacetDescription.cs
- TypeUtils.cs
- SqlServices.cs
- PagedDataSource.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- StringUtil.cs
- IntMinMaxAggregationOperator.cs
- MethodAccessException.cs
- FixedMaxHeap.cs
- SQLSingle.cs
- DBBindings.cs
- ConsoleKeyInfo.cs
- MenuStrip.cs
- ChannelCacheSettings.cs
- WmlCommandAdapter.cs
- DesignerWithHeader.cs
- EncryptedKeyHashIdentifierClause.cs
- MsmqEncryptionAlgorithm.cs
- SymbolMethod.cs
- FormViewUpdateEventArgs.cs
- SelfIssuedTokenFactoryCredential.cs
- XmlSchemaInfo.cs
- DataGridTable.cs
- ServiceDescriptionImporter.cs
- SoapFormatExtensions.cs
- DiscardableAttribute.cs
- Quaternion.cs
- Vector3D.cs
- SQLByte.cs
- CollectionBuilder.cs
- BindingMemberInfo.cs
- _DisconnectOverlappedAsyncResult.cs
- HttpHandler.cs
- ItemContainerGenerator.cs
- CollectionViewProxy.cs
- ObjectSet.cs
- ScriptManager.cs
- CapacityStreamGeometryContext.cs
- TableColumnCollection.cs
- HttpListenerTimeoutManager.cs
- EntityDataSourceChangedEventArgs.cs
- CodeValidator.cs
- RenderData.cs
- Separator.cs
- SamlDoNotCacheCondition.cs
- Property.cs
- WindowsScrollBarBits.cs
- ParseElement.cs
- SQLDecimal.cs
- MessageSmuggler.cs
- WmlPageAdapter.cs
- GenerateHelper.cs
- ResourcePool.cs
- InkSerializer.cs
- MetadataHelper.cs
- OutKeywords.cs
- LassoHelper.cs
- querybuilder.cs
- ReturnType.cs
- DataKey.cs