Esempio n. 1
0
 /// <summary>
 /// Add specific <see cref="Action"/>s to the bindings, using the method's Name as the name for each. Paths not supported
 /// </summary>
 /// <param name="actions"></param>
 public void BindActions(params Action[] actions)
 {
     foreach (var action in actions)
     {
         BindingHelpers.CreateBindFunction(bindItems, action.Method.Name, action, false, "", "");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Add specific <see cref="Delegate"/>s to the bindings using the method Name as the name. Paths not supported
 /// </summary>
 /// <param name="name"></param>
 /// <param name="del"></param>
 /// <param name="documentation"></param>
 /// <param name="example"></param>
 public void BindDelegates(params Delegate[] dels)
 {
     foreach (var del in dels)
     {
         BindingHelpers.CreateBindFunction(bindItems, del.Method.Name, del, false, "", "");
     }
 }
Esempio n. 3
0
        private void RegisterObjectFuncs(object target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            Type type = target.GetType();

            MethodInfo[] mis = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (var mi in mis)
            {
                var attr = (LunarBindFunctionAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindFunctionAttribute));
                if (attr != null)
                {
                    var    documentation = (LunarBindDocumentationAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindDocumentationAttribute));
                    var    example       = (LunarBindExampleAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindExampleAttribute));
                    var    del           = BindingHelpers.CreateDelegate(mi, target);
                    string name          = attr.Name ?? mi.Name;
                    BindingHelpers.CreateBindFunction(bindItems, name, del, attr.AutoYield, documentation?.Data ?? "", example?.Data ?? "");
                }
            }
        }
Esempio n. 4
0
        private void RegisterTypeFuncs(Type type, string prefix = null)
        {
            if (prefix != null)
            {
                prefix = prefix.Trim('.', ' ');
            }
            MethodInfo[] mis = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (var mi in mis)
            {
                var attr = (LunarBindFunctionAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindFunctionAttribute));
                if (attr != null)
                {
                    var prefixAttrib  = (LunarBindPrefixAttribute)type.GetCustomAttribute(typeof(LunarBindPrefixAttribute));
                    var documentation = (LunarBindDocumentationAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindDocumentationAttribute));
                    var example       = (LunarBindExampleAttribute)Attribute.GetCustomAttribute(mi, typeof(LunarBindExampleAttribute));
                    var del           = BindingHelpers.CreateDelegate(mi);
                    //string name = (prefix != null ? prefix + "." : "") + (attr.Name ?? mi.Name);
                    string name = $"{(prefixAttrib?.Prefix != null ? prefixAttrib.Prefix + "." : "")}{(prefix != null ? prefix + "." : "")}{(attr.Name ?? mi.Name)}";

                    BindingHelpers.CreateBindFunction(bindItems, name, del, attr.AutoYield, documentation?.Data ?? "", example?.Data ?? "");
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Add a specific <see cref="Delegate"/> to the bindings using its Name as the name
 /// </summary>
 /// <param name="del"></param>
 /// <param name="documentation"></param>
 /// <param name="example"></param>
 public void BindDelegate(Delegate del, string documentation = "", string example = "")
 {
     BindingHelpers.CreateBindFunction(bindItems, del.Method.Name, del, false, documentation ?? "", example ?? "");
 }
Esempio n. 6
0
 public void AddDelegate(string name, Delegate del, string documentation = "", string example = "")
 {
     BindingHelpers.CreateBindFunction(bindItems, name, del, false, documentation ?? "", example ?? "");
 }
Esempio n. 7
0
 /// <summary>
 /// Add a specific <see cref="Action"/> to the bindings, using the method's Name as the name
 /// </summary>
 /// <param name="action"></param>
 /// <param name="documentation"></param>
 /// <param name="example"></param>
 public void BindAction(Action action, string documentation = "", string example = "")
 {
     BindingHelpers.CreateBindFunction(bindItems, action.Method.Name, action, false, documentation ?? "", example ?? "");
 }
Esempio n. 8
0
 /// <summary>
 /// Add a specific <see cref="Action"/> to the bindings.
 /// </summary>
 /// <param name="path">The path to bind to. Can contain "."</param>
 /// <param name="action"></param>
 /// <param name="documentation"></param>
 /// <param name="example"></param>
 public void BindAction(string path, Action action, string documentation = "", string example = "")
 {
     BindingHelpers.CreateBindFunction(bindItems, path, action, false, documentation ?? "", example ?? "");
 }
 public static void AddAction(string name, Action action, string documentation = "", string example = "")
 {
     BindingHelpers.CreateBindFunction(bindItems, name, action, false, documentation ?? "", example ?? "");
 }