コード例 #1
0
        public void BuildFunc(string paramName, Type paramType)
        {
            if (_targetFuncObj == null)
            {
                string className    = "ChoClass_{0}".FormatString(ChoIntRandom.Next(1, int.MaxValue));
                string codeFragment = String.Join(" ", _statements);
                string statement    = null;
                switch (_language)
                {
                case ChoCodeProviderLanguage.VB:
                    statement = String.Format("Public Class {1} {0} Public Function Execute({3} As {4}) as Object {0} {2} {0} End Function {0} End Class", Environment.NewLine, className, codeFragment, paramName, paramType);
                    break;

                default:
                    statement = String.Format("public class {0} {{ public object Execute({3} {2}) {{ {1}; }} }}", className, codeFragment, paramName, paramType);
                    break;
                }
                _targetFuncObj = Activator.CreateInstance(CreateType(className, codeFragment, statement));
            }
        }
コード例 #2
0
        public object ExecuteFunc(params object[] args)
        {
            if (_targetFunc == null)
            {
                string className    = "ChoClass_{0}".FormatString(ChoIntRandom.Next(1, int.MaxValue));
                string codeFragment = String.Join(" ", _statements);
                string statement    = null;
                switch (_language)
                {
                case ChoCodeProviderLanguage.VB:
                    statement = String.Format("Public Class {1} {0} Public Function Execute(args As Object()) as Object {0} {2} {0} End Function {0} End Class", Environment.NewLine, className, codeFragment);
                    break;

                default:
                    statement = String.Format("public class {0} {{ public object Execute(object[] args) {{ {1}; }} }}", className, codeFragment);
                    break;
                }
                _targetFunc = Activator.CreateInstance(CreateType(className, codeFragment, statement));
            }
            return(_targetFunc.Execute(args));
        }
コード例 #3
0
        public void ExecuteAction(params object[] args)
        {
            if (_targetAction == null)
            {
                string className    = "ChoClass_{0}".FormatString(ChoIntRandom.Next());
                string codeFragment = String.Join(" ", _statements);
                string statement    = null;
                switch (_language)
                {
                case ChoCodeProviderLanguage.VB:
                    statement = String.Format("Public Class {1} {0} Public Sub Execute(args As Object()) {0} {2} {0} End Sub {0} End Class", Environment.NewLine, className, codeFragment);
                    break;

                default:
                    statement = String.Format("public class {0} {{ public void Execute(object[] args) {{ {1}; }} }}", className, codeFragment);
                    break;
                }
                _targetAction = Activator.CreateInstance(CreateType(className, codeFragment, statement));
            }
            _targetAction.Execute(args);
        }
コード例 #4
0
 public override object NextValue()
 {
     return(ChoIntRandom.Next(_minValue, _maxValue));
 }