コード例 #1
0
        public IStateAction <TState> GetStateActionForData(IActionData data)
        {
            var dataType = data.GetType();

            if (!_actions.ContainsKey(dataType))
            {
                Debug.LogError($"There's no registered action for data of type {dataType}");
                return(null);
            }

            return(_actions[dataType]);
        }
コード例 #2
0
ファイル: Action.cs プロジェクト: porohkun/ScreenSlicer
        public static void Apply(this IActionData data, ISystemWindow window, ref Rectangle region)
        {
            var type = data.GetType();

            if (_methods.TryGetValue(type, out var method))
            {
                var parameters = new object[] { data, window, region };
                method.Invoke(null, parameters);
                region = (Rectangle)parameters[2];
            }
            else
            {
                throw new ArgumentException($"Not found suitable method for '{type}' type");
            }
        }