public bool Validate(object o, Type type, string customSourceValidationCode) { string baseClass = " public class CustomValidation" + " {" + " public bool Validate(object o)" + " {" + " if (o == null)" + " ValidationErrors.Add(LambdaHelper<Order>.GetPropertyName(x => x.Services), \"Order.Services is a mandatory field.\");" + " if (!(o is Order))" + " ValidationErrors.Add(LambdaHelper<Order>.GetPropertyName(x => x.Services), \"Order.Services is a mandatory field.\");" + customSourceValidationCode + " return ValidationErrors.Count > 0;" + " }" + " public SerializableDictionary<string, string> ValidationErrors { get; set; }" + " }"; string className = "CustomValidation"; string methodName = "Validate"; string propertyName = "ValidationErrors"; var referencedAssemblies = new[] { "Common.Lib.Utility", "ANDP.Lib.Domain.Models" }; DynamicCodeService.CompileSourceCodeDom(customSourceValidationCode, referencedAssemblies); var result = (bool)DynamicCodeService.ExecuteMethodFromAssembly(className, methodName, null); ValidationErrors = (SerializableDictionary <string, string>)DynamicCodeService.RetrievePropertyValueFromAssembly(className, propertyName); return(result); }
public DynamicCodeServiceTests() { _MockLogService = new Mock <ILogService>(); SUT = new DynamicCodeService(_MockLogService.Object); }
public DetailsModel(DynamicCodeService dynamicCodeService) { _DynamicCodeService = dynamicCodeService; }