当前位置: 首页>>代码示例>>C#>>正文


C# CounterCreationDataCollection.Contains方法代码示例

本文整理汇总了C#中System.Diagnostics.CounterCreationDataCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# CounterCreationDataCollection.Contains方法的具体用法?C# CounterCreationDataCollection.Contains怎么用?C# CounterCreationDataCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.CounterCreationDataCollection的用法示例。


在下文中一共展示了CounterCreationDataCollection.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstallPerfmonCounterCategories

        /// <summary>
        /// Install the perfmon counters
        /// </summary>
        /// <returns>true if successfully loaded else false</returns>
        public static void InstallPerfmonCounterCategories()
        {
            String categoryName = String.Empty;
            Dictionary<string, CounterCreationDataCollection> catCreationData = null;

            // Iterate through each category
            foreach (PerformanceCounterCategories pccEntry in _pccList)
            {
                try
                {
                    catCreationData = new Dictionary<string, CounterCreationDataCollection>();
                    categoryName = CounterCategory(pccEntry);
                    Logger.Log(String.Format("InstallPerfmonCounterCategories() - attempting to create custom perfmon installer for {0}\n",
                       categoryName));
                    CounterCreationDataCollection ccdc = new CounterCreationDataCollection();

                    if (_catCreationData.ContainsKey(categoryName) == false) continue;
                    // Add the counter data to the installer counters collection
                    foreach (CounterCreationData counterCreationData in _catCreationData[categoryName])
                    {
                        if (ccdc.Contains(counterCreationData) == true)
                            continue;
                        ccdc.Add(counterCreationData);

                        PerformanceCounterType perfCounterTypeBase;
                        bool needsABaseType = NeedsABaseType(counterCreationData.CounterType, out perfCounterTypeBase);

                        // Since this counter type needs a base, create it and add it to the collection
                        if (needsABaseType == true)
                        {
                            CounterCreationData counterBaseCreationData = new CounterCreationData();
                            counterBaseCreationData.CounterName = counterCreationData.CounterName + BaseSuffix;
                            counterBaseCreationData.CounterHelp = counterCreationData.CounterHelp + BaseSuffix;
                            counterBaseCreationData.CounterType = perfCounterTypeBase;
                            // Add a base counter to collection of counterCreationData previous was an average type
                            if (ccdc.Contains(counterBaseCreationData) == false)
                                ccdc.Add(counterBaseCreationData);
                        }

                        Logger.Log(String.Format("InstallPerfmonCounterCategories() - added counter {0}, category {1} of type {2}\n",
                            counterCreationData.CounterName, counterCreationData.CounterHelp, counterCreationData.CounterType));
                    }
                    catCreationData.Add(categoryName, ccdc);
                }
                catch (ArgumentNullException ane)
                {
                    Logger.Log(String.Format("InstallPerfmonCounterCategories() - Custom attribute {0} not constructed correctly.\n",
                        ane.ParamName));
                }
                catch (ArgumentException ae)
                {
                    Logger.Log(String.Format("InstallPerfmonCounterCategories() - Not able to add counter {0) to installer.\n",
                        ae.ParamName));
                }
                catch (TypeLoadException tle)
                {
                    Logger.Log(String.Format("InstallPerfmonCounterCategories() - Not able to load custom attributes because {0}.\n",
                        tle.Message));
                }
                catch (Exception ex)
                {
                    Logger.Log(String.Format("InstallPerfmonCounterCategories() - Not able to load custom attributes because {0}.\n",
                        ex.Message));
                }
            }
        }
开发者ID:odinhaus,项目名称:Suffuz,代码行数:70,代码来源:PerformanceCounter.cs


注:本文中的System.Diagnostics.CounterCreationDataCollection.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。