コード例 #1
0
        /// <summary>
        /// Adds the <typeparamref name="TDelegate"/> delegate
        /// to the <see cref="FunctionCollection{T}"/> with the
        /// function name, taken from real method name.</summary>
        /// <typeparam name="TDelegate">Delegate type.</typeparam>
        /// <param name="target">
        /// <typeparamref name="TDelegate"/> instance to add.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="target"/> is null.</exception>
        /// <exception cref="ArgumentException">
        /// <typeparamref name="TDelegate"/>
        /// is not delegate type.<br/>-or-<br/>
        /// <paramref name="target"/> is not valid delegate
        /// to be added to the <see cref="FunctionCollection{T}"/>.
        /// <br/>-or-<br/><see cref="FunctionInfo{T}"/> with the
        /// same name and same arguments count already exist
        /// in the collection (overload impossible).</exception>
        public void Add <TDelegate>(TDelegate target)
        {
            var delType = typeof(TDelegate);

            if (!typeof(Delegate).IsAssignableFrom(delType))
            {
                throw new ArgumentException();
            }

            AddFunc(FunctionFactory <T>
                    .FromDelegate((Delegate)(object)target, true));
        }
コード例 #2
0
        /// <summary>
        /// Adds the <typeparamref name="TDelegate"/> delegate
        /// to the <see cref="FunctionCollection{T}"/>
        /// with the specified function name.</summary>
        /// <typeparam name="TDelegate">Delegate type.</typeparam>
        /// <param name="name">Function group name.</param>
        /// <param name="target">
        /// <typeparamref name="TDelegate"/> instance to add.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="target"/> is null.</exception>
        /// <exception cref="ArgumentException">
        /// <typeparamref name="TDelegate"/>
        /// is not delegate type.<br/>-or-<br/>
        /// <paramref name="target"/> is not valid delegate
        /// to be added to the <see cref="FunctionCollection{T}"/>.
        /// <br/>-or-<br/><see cref="FunctionInfo{T}"/> with the
        /// same name and same arguments count already exist
        /// in the collection (overload impossible).</exception>
        public void AddDel <TDelegate>(string name, TDelegate target)
        {
            Type type = typeof(TDelegate);

            if (!typeof(Delegate).IsAssignableFrom(type))
            {
                throw new ArgumentException();
            }

            Validator.CheckVisible(type);

            AddFunc(name, FunctionFactory <T>
                    .FromDelegate((Delegate)(object)target, true));
        }
コード例 #3
0
 /// <summary>
 /// Adds the <see cref="EvalFuncN{T}"/> delegate
 /// to the <see cref="FunctionCollection{T}"/> with the
 /// function name, taken from real method name.</summary>
 /// <param name="target">
 /// <see cref="EvalFuncN{T}"/> instance to add.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="target"/> is null.</exception>
 /// <exception cref="ArgumentException">
 /// <paramref name="target"/> is not valid delegate
 /// to be added to the <see cref="FunctionCollection{T}"/>.
 /// <br/>-or-<br/><see cref="FunctionInfo{T}"/> with the
 /// same name and same arguments count already exist
 /// in the collection (overload impossible).</exception>
 /// <remarks>Not available on .NET CF 2.0 because
 /// it's impossible to resolve method name.</remarks>
 public void Add(EvalFuncN <T> target)
 {
     AddFunc(FunctionFactory <T>
             .FromDelegate(target, true));
 }
コード例 #4
0
 /// <summary>
 /// Adds the <see cref="EvalFuncN{T}"/> delegate
 /// to the <see cref="FunctionCollection{T}"/>
 /// with the specified function name.</summary>
 /// <param name="name">Function group name.</param>
 /// <param name="target">
 /// <see cref="EvalFuncN{T}"/> instance to add.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="target"/> is null.</exception>
 /// <exception cref="ArgumentException">
 /// <paramref name="target"/> is not valid delegate
 /// to be added to the <see cref="FunctionCollection{T}"/>.
 /// <br/>-or-<br/><see cref="FunctionInfo{T}"/> with the
 /// same name and same arguments count already exist
 /// in the collection (overload impossible).</exception>
 public void Add(string name, EvalFuncN <T> target)
 {
     AddFunc(name, FunctionFactory <T>
             .FromDelegate(target, true));
 }