mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
update
This commit is contained in:
parent
e03aaed55b
commit
a23a49163e
@ -33,16 +33,16 @@ namespace FreeSql.Extensions.LazyLoading
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
public static Assembly CompileCode(string cscode)
|
||||||
public static Assembly CompileCode(string cscode) {
|
{
|
||||||
|
|
||||||
var files = Directory.GetFiles(Directory.GetParent(Type.GetType("IFreeSql, FreeSql").Assembly.Location).FullName);
|
var files = Directory.GetFiles(Directory.GetParent(Type.GetType("IFreeSql, FreeSql").Assembly.Location).FullName);
|
||||||
using (var compiler = CodeDomProvider.CreateProvider("cs")) {
|
using (var compiler = CodeDomProvider.CreateProvider("cs"))
|
||||||
|
{
|
||||||
var objCompilerParameters = new CompilerParameters();
|
var objCompilerParameters = new CompilerParameters();
|
||||||
objCompilerParameters.ReferencedAssemblies.Add("System.dll");
|
objCompilerParameters.ReferencedAssemblies.Add("System.dll");
|
||||||
objCompilerParameters.ReferencedAssemblies.Add("System.Core.dll");
|
objCompilerParameters.ReferencedAssemblies.Add("System.Core.dll");
|
||||||
objCompilerParameters.ReferencedAssemblies.Add("FreeSql.dll");
|
objCompilerParameters.ReferencedAssemblies.Add("FreeSql.dll");
|
||||||
foreach (var dll in files)
|
foreach (var dll in files)
|
||||||
{
|
{
|
||||||
if (!dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) &&
|
if (!dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) &&
|
||||||
@ -69,16 +69,16 @@ namespace FreeSql.Extensions.LazyLoading
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
objCompilerParameters.GenerateExecutable = false;
|
objCompilerParameters.GenerateExecutable = false;
|
||||||
objCompilerParameters.GenerateInMemory = true;
|
objCompilerParameters.GenerateInMemory = true;
|
||||||
|
|
||||||
CompilerResults cr = compiler.CompileAssemblyFromSource(objCompilerParameters, cscode);
|
CompilerResults cr = compiler.CompileAssemblyFromSource(objCompilerParameters, cscode);
|
||||||
|
|
||||||
if (cr.Errors.Count > 0)
|
if (cr.Errors.Count > 0)
|
||||||
throw new Exception(cr.Errors[0].ErrorText);
|
throw new Exception(cr.Errors[0].ErrorText);
|
||||||
|
|
||||||
return cr.CompiledAssembly;
|
return cr.CompiledAssembly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user