コード例 #1
0
 protected void RegisterInputType(string dataType)
 {
     lock (inputTypeLock)
     {
         if (inputTypes.Contains(dataType))
         {
             return;
         }
         inputTypes.Add(dataType);
     }
     InputTypeAdded?.Invoke(this, new InputTypeRegistrationEventArgs(dataType));
 }
コード例 #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);
            }
        }