Пример #1
0
        public FlowObservation Get(AreaTypeName name)
        {
            if (!TryGet(name, out var observation))
            {
                throw new KeyNotFoundException($"This set does not contain the specified name: {name}");
            }

            return(observation);
        }
Пример #2
0
        public T Get(AreaTypeName name)
        {
            if (!TryGet(name, out var type))
            {
                throw new KeyNotFoundException($"This set does not contain the specified name: {name}");
            }

            return(type);
        }
Пример #3
0
        public FlowType GetFlow(AreaTypeName name)
        {
            if (!TryGetFlow(name, out var type))
            {
                throw new KeyNotFoundException($"This map does not contain a flow with the specified name: {name}");
            }

            return(type);
        }
Пример #4
0
 AreaTypeInfo(
     Type declaredType,
     AreaTypeName name,
     bool isEvent,
     bool isTopic,
     bool isQuery)
 {
     DeclaredType = declaredType;
     Name         = name;
     IsEvent      = isEvent;
     IsTopic      = isTopic;
     IsQuery      = isQuery;
 }
Пример #5
0
        public bool TryGetFlow(AreaTypeName name, out FlowType type)
        {
            if (Topics.TryGet(name, out var topic))
            {
                type = topic;
            }
            else if (Queries.TryGet(name, out var query))
            {
                type = query;
            }
            else
            {
                type = null;
            }

            return(type != null);
        }
Пример #6
0
        static AreaTypeInfo TryFrom <TAssignable>(Type type, bool isEvent = false, bool isTopic = false, bool isQuery = false)
        {
            if (!typeof(TAssignable).IsAssignableFrom(type))
            {
                return(null);
            }

            var currentType = type;
            var currentName = type.Name;

            while (currentType.IsNested)
            {
                currentType = currentType.DeclaringType;
                currentName = $"{currentType.Name}.{currentName}";
            }

            return(new AreaTypeInfo(type, AreaTypeName.From(currentName), isEvent, isTopic, isQuery));
        }
Пример #7
0
 public bool TryGet(AreaTypeName name, out T type) =>
 _byName.TryGetValue(name, out type);
Пример #8
0
 public bool Contains(AreaTypeName name) =>
 _byName.ContainsKey(name);
Пример #9
0
 public T this[AreaTypeName name] => Get(name);
Пример #10
0
 public bool TryGet(AreaTypeName name, out FlowObservation observation) =>
 _byName.TryGetValue(name, out observation);
Пример #11
0
 public FlowObservation this[AreaTypeName name] => _byName[name];