You are viewing a single comment's thread.

view the rest of the comments →

0
0

[–] verifex ago  (edited ago)

As an example, I am implementing an AbstractValidator<T> using CSSCRIPT using something like this:

using System;

using System.Collections.Generic;

using System.Linq;

using CSScriptLibrary;

public object CreateClass(Type typeToValidate, string rulestoLoad); public readonly string Namespaces = @"

using System;

using System.Linq;

using FluentValidation;"

public readonly string Template = @"

{0}

public class DynamicRuleValidatorFor{1} : AbstractValidator<{2}>

{{

public DynamicRuleValidatorFor{1}()
{{

    {3}
}}

}}";

var codeToLoad = string.Format(Template, Namespaces, typeToValidate.Name, typeToValidate.FullName, rulesToLoad);

return CSScript.LoadCode(codeToLoad).CreateObject("*");

}