private void btnCompiler_Click(object sender, EventArgs e) { CodeCompilerWraper csWrapper = new CSharpCompilerWraper(); csWrapper.FrameworkVersion = FrameworkVersion.Version20; csWrapper.CustomeAssemblies = null; csWrapper.Compile(txtCode.Text, new CompilerOutputDelegate(HandleCompilerOutput)); }
private void btnDebug_Click(object sender, EventArgs e) { ScriptCode code = new ScriptCode(); code.SourceCode = txtCode.Text; code.StartUpList.Add(new StartUpInfo() { ClassName = "ConsoleApplication1.Program", MethordName = "Test", order = 0, MethordParameters = new object[] { this }, Instance = this, }); CodeCompilerWraper csWrapper = new CSharpCompilerWraper(); csWrapper.FrameworkVersion = FrameworkVersion.Version20; csWrapper.CustomeAssemblies = null; csWrapper.Run(code, new CompilerOutputDelegate(HandleCompilerOutput)); }
public static void InitElementChildren(Type elementType, object element, List<Tuple<ChildElementAttribute, PropertyInfo>> childElementProperties) { StringBuilder sb = new StringBuilder(); foreach (var item in childElementProperties.Where(row => row.Item1.ChildCategory == ChildCategory.ChildrenColection).OrderBy(row => row.Item1.Order)) { sb.AppendFormat(itemFormat, item.Item2.Name).AppendLine(); } Element elementInstance = element as Element; elementInstance.Items = null; elementInstance.ItemTypes = null; List<Element> elementList = new List<Element>(); foreach (var item in childElementProperties.Where(row => row.Item1.ChildCategory == ChildCategory.ChildrenList || row.Item1.ChildCategory == ChildCategory.ChildrenColection)) { object o = item.Item2.GetValue(element, null); if (o != null) { IEnumerable<Element> elements = o as IEnumerable<Element>; if (elements != null && elements.Count() > 0) { foreach (Element tempelement in elements) { //++??????????? // tempelement.PrepareChildrenElements(); } if (item.Item1.ChildCategory == ChildCategory.ChildrenColection) { elementList.AddRange(elements); } } } } if (elementList.Count > 0) { elementInstance.Items = elementList.ToArray(); elementInstance.ItemTypes = elementList.Select(row => row.ElementType).ToArray(); } string code = string.Format(format, elementType.Name, sb.ToString()); CSharpCompilerWraper codeWrapper = new CSharpCompilerWraper(); codeWrapper.FrameworkVersion = FrameworkVersion.Version20; codeWrapper.CustomeAssemblies = null; ScriptCode scriptCode = new ScriptCode(); scriptCode.SourceCode = code; scriptCode.StartUpList.Add(new StartUpInfo() { ClassName = "Justin.BI.DBLibrary.Compiler.MondrianCompiler", Instance = element, MethordName = "InitChildren", order = 0, MethordParameters = new object[] { element } }); // codeWrapper.Run(scriptCode, null); }