Beispiel #1
0
        /// <summary>
        /// Creates the formatted instance name for a performance counter, providing the Application
        /// Domain friendly name for the prefix for the instance.
        /// </summary>
        /// <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param>
        /// <returns>Formatted instance name in form of "appDomainFriendlyName - nameSuffix"</returns>
        public string CreateName(string nameSuffix)
        {
            string appDomainFriendlyName = AppDomain.CurrentDomain.FriendlyName;
            PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName(appDomainFriendlyName, nameSuffix);

            return(instanceName.ToString());
        }
        public string CreateName(string nameSuffix)
        {
            string replacePattern        = "[\\\\()#/\\*]*";
            string appDomainFriendlyName = string.IsNullOrEmpty(this.applicationInstanceName) ? AppDomain.CurrentDomain.FriendlyName : this.applicationInstanceName;
            Regex  filter = new Regex(replacePattern);

            appDomainFriendlyName = filter.Replace(appDomainFriendlyName, string.Empty);
            PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName(appDomainFriendlyName, nameSuffix);

            return(instanceName.ToString());
        }
        /// <summary>
		/// Creates the formatted instance name for a performance counter, providing the Application
		/// Domain friendly name for the prefix for the instance.
		/// </summary>
		/// <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param>
		/// <returns>Formatted instance name in form of "appDomainFriendlyName - nameSuffix"</returns>
		public string CreateName(string nameSuffix)
        {
            string replacePattern = "[\\\\()#/\\*]*";
            string appDomainFriendlyName = string.IsNullOrEmpty(this.applicationInstanceName) ? AppDomain.CurrentDomain.FriendlyName : this.applicationInstanceName;

            Regex filter = new Regex(replacePattern);
            appDomainFriendlyName = filter.Replace(appDomainFriendlyName, string.Empty);

			PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName(appDomainFriendlyName, nameSuffix);
			return instanceName.ToString();        	
        }
        /// <summary>
		/// Creates the formatted instance name for a performance counter, providing the Application
		/// Domain friendly name for the prefix for the instance.
		/// </summary>
		/// <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param>
		/// <returns>Formatted instance name in form of "appDomainFriendlyName - nameSuffix"</returns>
		public string CreateName(string nameSuffix)
        {
			string appDomainFriendlyName = AppDomain.CurrentDomain.FriendlyName;
			PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName(appDomainFriendlyName, nameSuffix);
			return instanceName.ToString();        	
        }
 public void SingleCharacterPrefixAndSuffixCreateValidName()
 {
     PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName("a", "b");
     Assert.AreEqual("a - b", instanceName.ToString());
 }
 public void OverlyLongSuffixIsTruncatedToMaxLengthInGeneratedName()
 {
     PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName("a", "01234", 15, 3);
     Assert.AreEqual("a - 012", instanceName.ToString());
 }
 public void OverlyLongPrefixIsTruncatedToMaxLengthInGeneratedName()
 {
     PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName("01234", "b", 3, 15);
     Assert.AreEqual("012 - b", instanceName.ToString());
 }
 public void EmptyPrefixPrintsJustSuffixForName()
 {
     PerformanceCounterInstanceName instanceName = new PerformanceCounterInstanceName(String.Empty, "b");
     Assert.AreEqual("b", instanceName.ToString());
 }