Beispiel #1
0
        /// <summary>
        /// Gets a 'code as data' method
        /// </summary>
        /// <param name="type"></param>
        /// <param name="scriptMethod">Name of condition or action in the form "class.method"</param>
        /// <returns>Method + metadata</returns>
        public MethodMapping GetMethod(ScriptEntityType type, string scriptMethod)
        {
            MethodRegistry methods;

            switch (type)
            {
            case ScriptEntityType.Action:
                methods = Actions;
                break;

            case ScriptEntityType.Condition:
                methods = Conditions;
                break;

            default:
                throw new Exception($"Unknown {nameof(ScriptClass)} - {nameof(GetMethod)}");
            }

            MethodMapping mapping;

            if (!methods.TryGetValue(scriptMethod, out mapping))
            {
                throw new Exception($"Missing {type} {scriptMethod}");
            }

            return(mapping);
        }
 public ScriptMethodAttribute(ScriptEntityType type, string name)
 {
     this.Type = type;
     this.Name = name;
 }