Exemple #1
0
        private void OnProcessorInputTypeRemoved(object sender, InputTypeRegistrationEventArgs e)
        {
            var processor = (IProcessor)sender;
            var inputType = e.DataType;

            if (!typeMap.TryGetValue(inputType, out var typeProcessors))
            {
                return;
            }
            lock (typeMapListLock)
            {
                if (typeProcessors.Remove(processor))
                {
                    if (!typeProcessors.Any())
                    {
                        typeMap.TryRemove(inputType, out _);
                        InputTypeRemoved?.Invoke(this, new InputTypeRegistrationEventArgs(inputType));
                    }
                }
            }
        }
Exemple #2
0
        private void OnProcessorInputTypeAdded(object sender, InputTypeRegistrationEventArgs e)
        {
            var processor = (IProcessor)sender;
            var inputType = e.DataType;

            if (typeMap.TryAdd(inputType, new List <IProcessor>()))
            {
                InputTypeAdded?.Invoke(this, new InputTypeRegistrationEventArgs(inputType));
            }

            if (!typeMap.TryGetValue(inputType, out var typeProcessors))
            {
                throw new Exception($"Expected type map to contain '{inputType}'");
            }
            lock (typeMapListLock)
            {
                if (typeProcessors.Contains(processor))
                {
                    return;
                }
                typeProcessors.Add(processor);
            }
        }
Exemple #3
0
 private async void OnInputTypeAdded(object sender, InputTypeRegistrationEventArgs e)
 {
     await SubscribeToDataType(e.DataType);
 }
Exemple #4
0
 private async void OnInputTypeRemoved(object sender, InputTypeRegistrationEventArgs e)
 {
     await UnsubscribeFromDataType(e.DataType);
 }