Example #1
0
        public static void InvokeReadDataSourceSkill(
            this Type targetType,
            object target,
            Type resType,
            Action <Type, object> writeInput = null,
            Action <Type, object> readResult = null)
        {
            var methodArgs = new[] { typeof(Input <>).MakeGenericType(resType) };
            var method     = targetType.GetMethod(nameof(Skill <object> .Read), methodArgs);

            if (method == null)
            {
                throw new InvalidOperationException("target type does not implement skill");
            }

            SkillsExtensions.InvokeSkill(
                target: target,
                skillType: typeof(Skill <>),
                inputType: typeof(Input <>),
                resultType: typeof(Result <>),
                genTypeArg: resType,
                skillInvokeMethod: method,
                writeInput: writeInput,
                readResult: readResult);
        }
Example #2
0
        public static void InvokeStopSkill(
            this Type targetType,
            object target,
            Action <Type, object> writeInput = null,
            Action <Type, object> readResult = null)
        {
            var methodArgs = new[] { typeof(Input) };
            var method     = targetType.GetMethod(nameof(Skill.Stop), methodArgs);

            if (method == null)
            {
                throw new InvalidOperationException("target type does not implement skill");
            }

            SkillsExtensions.InvokeSkill(
                target: target,
                skillType: typeof(Skill),
                inputType: typeof(Input),
                resultType: typeof(Result),
                skillInvokeMethod: method,
                writeInput: writeInput,
                readResult: readResult);
        }