Example #1
0
        protected string ToCountKey(OperationKey operationKey)
        {
            StringBuilder stringBuilder = new StringBuilder(string.Empty);

            stringBuilder.Append(DisplayNameAttribute.GetEnumName(operationKey.ActivityOperationType));
            stringBuilder.Append(".C[");
            if (!string.IsNullOrWhiteSpace(operationKey.Instance))
            {
                this.AppendValidChars(stringBuilder, operationKey.Instance);
            }
            stringBuilder.Append("]");
            return(stringBuilder.ToString());
        }
Example #2
0
        private string ToTotalKey(OperationKey operationKey)
        {
            StringBuilder stringBuilder = new StringBuilder(string.Empty);

            stringBuilder.Append(DisplayNameAttribute.GetEnumName(operationKey.ActivityOperationType));
            stringBuilder.Append(".T[");
            if (!string.IsNullOrWhiteSpace(operationKey.Instance))
            {
                base.AppendValidChars(stringBuilder, operationKey.Instance);
            }
            stringBuilder.Append("]");
            return(stringBuilder.ToString());
        }
        public static void RegisterMetadata(Type customMetadataType)
        {
            ExTraceGlobals.ActivityContextTracer.TraceDebug <string>(0L, "ActivityContext.RegisterMetadata - adding to the list of supported ActivityContext keys, type {0}.", customMetadataType.Name);
            if (!customMetadataType.IsSubclassOf(typeof(Enum)))
            {
                try
                {
                    throw new ArgumentException(DiagnosticsResources.ExceptionActivityContextEnumMetadataOnly, "customMetadataType");
                }
                catch (ArgumentException)
                {
                }
                return;
            }
            Array          values         = Enum.GetValues(customMetadataType);
            ListDictionary listDictionary = new ListDictionary();

            lock (ActivityContext.registeredEnumTypes)
            {
                if (!ActivityContext.registeredEnumTypes.Contains(customMetadataType) && !(customMetadataType == typeof(ActivityReadonlyMetadata)))
                {
                    for (int i = 0; i < values.Length; i++)
                    {
                        Enum   @enum = (Enum)values.GetValue(i);
                        string text  = DisplayNameAttribute.GetEnumName(@enum);
                        if (ActivityContext.stringToEnum.ContainsKey(text))
                        {
                            text = @enum.GetType().FullName + "." + @enum.ToString();
                            if (ActivityContext.stringToEnum.ContainsKey(text))
                            {
                                try
                                {
                                    throw new ActivityContextException(DiagnosticsResources.ExceptionActivityContextKeyCollision);
                                }
                                catch (ActivityContextException)
                                {
                                }
                                return;
                            }
                        }
                        listDictionary.Add(@enum, text);
                    }
                    Dictionary <Enum, Enum>   dictionary  = new Dictionary <Enum, Enum>(ActivityContext.preBoxedEnumValues);
                    Dictionary <Enum, string> dictionary2 = new Dictionary <Enum, string>(ActivityContext.enumToString);
                    Dictionary <string, Enum> dictionary3 = new Dictionary <string, Enum>(ActivityContext.stringToEnum);
                    foreach (object obj2 in listDictionary)
                    {
                        DictionaryEntry dictionaryEntry = (DictionaryEntry)obj2;
                        ExTraceGlobals.ActivityContextTracer.TraceDebug(0L, "ActivityContext.RegisterMetadata - ({0}, '{1}').", new object[]
                        {
                            dictionaryEntry.Key,
                            dictionaryEntry.Value
                        });
                        Enum enum2 = (Enum)dictionaryEntry.Key;
                        dictionary2[enum2] = (string)dictionaryEntry.Value;
                        dictionary3[(string)dictionaryEntry.Value] = enum2;
                        dictionary[enum2] = enum2;
                    }
                    ActivityContext.preBoxedEnumValues = dictionary;
                    ActivityContext.stringToEnum       = dictionary3;
                    ActivityContext.enumToString       = dictionary2;
                    ActivityContext.registeredEnumTypes.Add(customMetadataType);
                }
            }
        }