public static object InstantiateDelegate(string className, IList <FieldDeclaration> fieldDeclarations) { object @object = ReflectUtil.Instantiate(className); ApplyFieldDeclaration(fieldDeclarations, @object); return(@object); }
// Activity Behavior public override void Execute(IActivityExecution execution) { var scope = Context.CommandContext.Scope; var type = ReflectUtil.LoadClass(_className); object clazz; if (scope.IsRegistered(type)) { clazz = scope.Resolve(type); } else { clazz = ReflectUtil.Instantiate(_className); } if (type != null) { //execution.SetVariableLocal(_className,clazz); MethodInfo m = ReflectUtil.GetMethod(type, _methodName); if (m == null) { throw Log.MissingClassException(_className); } PerformExecution(execution, m, clazz); return; } throw Log.MissingClassException(_className); }
protected internal virtual bool DoValidate(object submittedValue, IFormFieldValidatorContext validatorContext) { IFormFieldValidator validator; if (!ReferenceEquals(Clazz, null)) { // resolve validator using Fully Qualified Classname var validatorObject = ReflectUtil.Instantiate(Clazz); if (validatorObject is IFormFieldValidator) { validator = (IFormFieldValidator)validatorObject; } else { throw new ProcessEngineException("Validator class '" + Clazz + "' is not an instance of " + typeof(IFormFieldValidator).FullName); } } else { //resolve validator using expression var validatorObject = DelegateExpression.GetValue(validatorContext.Execution); if (validatorObject is IFormFieldValidator) { validator = (IFormFieldValidator)validatorObject; } else { throw new ProcessEngineException("Validator expression '" + DelegateExpression + "' does not resolve to instance of " + typeof(IFormFieldValidator).FullName); } } var invocation = new FormFieldValidatorInvocation(validator, submittedValue, validatorContext); try { Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(invocation); } catch (System.Exception e) { throw new ProcessEngineException(e); } //return invocation.InvocationResult.Value; return(true); }