예제 #1
0
    internal void _handleInternal(IDispatchable eventToHandle)
    {
        HandlerMethodInfo handlerMethodInfo = null;

        _handlerMethods.TryGetValue(eventToHandle.GetType(), out handlerMethodInfo);
        if (handlerMethodInfo != null && eventToHandle != null)
        {
            handlerMethodInfo.Method.Invoke(handlerMethodInfo.Target, new object[] { eventToHandle });
        }
    }
예제 #2
0
파일: Rule.cs 프로젝트: mgrail/automatica
        /// <summary>
        ///  Will be called from <see cref="ValueChanged(RuleInterfaceInstance, object)"/>
        ///  Source will be set
        /// </summary>
        /// <param name="instance">The <see cref="RuleInterfaceInstance"/> instance</param>
        /// <param name="source">The source who dispatched the value (<see cref="IDispatchable"/>)</param>
        /// <param name="value">The changed value</param>
        /// <returns></returns>
        public IList <IRuleOutputChanged> ValueChanged(RuleInterfaceInstance instance, IDispatchable source, object value)
        {
            lock (_lock)
            {
                if (instance.This2RuleInterfaceTemplateNavigation.This2RuleInterfaceDirection ==
                    (long)Base.Templates.RuleInterfaceDirection.Param)
                {
                    ParamterValueChanged(instance, source, value);

                    Context.Logger.LogDebug($"RuleParameter changed {instance.This2RuleInstanceNavigation.Name} - {instance.This2RuleInterfaceTemplateNavigation.Name} from {source.GetType()}-{source.Name} value {value}");
                    return(new List <IRuleOutputChanged>());
                }
                Context.Logger.LogDebug($"RuleInput changed {instance.This2RuleInstanceNavigation.Name} - {instance.This2RuleInterfaceTemplateNavigation.Name} from {source.GetType()}-{source.Name} value {value}");

                var values = InputValueChanged(instance, source, value);

                try
                {
                    foreach (var ruleOutValue in values)
                    {
                        Context.Logger.LogDebug($"RuleOutput changed {ruleOutValue.Instance.Name} value {ruleOutValue.Value}");

                        if (!_valueDictionary.ContainsKey(ruleOutValue.Instance.RuleInterfaceInstance))
                        {
                            _valueDictionary.Add(ruleOutValue.Instance.RuleInterfaceInstance, ruleOutValue.Value);
                        }
                        else
                        {
                            _valueDictionary[ruleOutValue.Instance.RuleInterfaceInstance] = ruleOutValue.Value;
                        }
                    }
                }
                catch (Exception)
                {
                    //Ignore for the current test
                }


                return(values);
            }
        }