Esempio n. 1
0
        private static List <RegisterCommandInfo> getRegisterCommandInfos()
        {
            Dictionary <string, RegisterCommandInfo> dictionary = new Dictionary <string, RegisterCommandInfo>(StringComparer.InvariantCultureIgnoreCase);

            foreach (CommandComponents components in HystrixCommandBase.CommandComponentsCollection.Values)
            {
                RegisterCommandInfo info2;
                CommandInfo         commandInfo = components.CommandInfo;
                dictionary.TryGetValue(commandInfo.CommandKey, out info2);
                if (info2 == null)
                {
                    info2 = new RegisterCommandInfo {
                        Key          = commandInfo.CommandKey,
                        Domain       = commandInfo.Domain,
                        GroupKey     = commandInfo.GroupKey,
                        InstanceKeys = new List <string>(),
                        Type         = commandInfo.Type
                    };
                    dictionary[commandInfo.CommandKey] = info2;
                }
                if (commandInfo.InstanceKey != null)
                {
                    info2.InstanceKeys.Add(commandInfo.InstanceKey);
                }
            }
            return(dictionary.Values.ToList <RegisterCommandInfo>());
        }
        private static List <RegisterCommandInfo> getRegisterCommandInfos()
        {
            Dictionary <String, RegisterCommandInfo> registerCommandInfoMap = new Dictionary <string, RegisterCommandInfo>(StringComparer.InvariantCultureIgnoreCase);

            foreach (CommandComponents commandComponents in HystrixCommandBase.CommandComponentsCollection.Values)
            {
                CommandInfo         commandInfo = commandComponents.CommandInfo;
                RegisterCommandInfo registerCommandInfo;
                registerCommandInfoMap.TryGetValue(commandInfo.CommandKey, out registerCommandInfo);
                if (registerCommandInfo == null)
                {
                    registerCommandInfo = new RegisterCommandInfo()
                    {
                        Key          = commandInfo.CommandKey,
                        Domain       = commandInfo.Domain,
                        GroupKey     = commandInfo.GroupKey,
                        InstanceKeys = new List <string>(),
                        Type         = commandInfo.Type
                    };
                    registerCommandInfoMap[commandInfo.CommandKey] = registerCommandInfo;
                }

                if (commandInfo.InstanceKey != null)
                {
                    registerCommandInfo.InstanceKeys.Add(commandInfo.InstanceKey);
                }
            }

            return(registerCommandInfoMap.Values.ToList());
        }