public ViewCompilingVisitor(DefaultViewCompilerCodeEmitter emitter, CompiledAssemblyCache compiledAssemblyCache, IBindingCompiler bindingCompiler, string className) { this.emitter = emitter; this.compiledAssemblyCache = compiledAssemblyCache; this.className = className; this.bindingCompiler = bindingCompiler; }
static CompiledAssemblyCache() { Instance = new CompiledAssemblyCache(); #if DotNetCore System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Instance.DefaultOnResolving; #else AppDomain.CurrentDomain.AssemblyResolve += Instance.TryResolveAssembly; #endif }
public virtual TypeRegistry AddImportedTypes(TypeRegistry reg, CompiledAssemblyCache compiledAssemblyCache) { if (ImportNamespaces != null) { return(reg.AddSymbols(ImportNamespaces.Select(ns => CreateTypeLoader(ns, compiledAssemblyCache)))); } else { return(reg); } }
public DefaultViewCompiler(IOptions <ViewCompilerConfiguration> config, IControlTreeResolver controlTreeResolver, IBindingCompiler bindingCompiler, Func <Validation.ControlUsageValidationVisitor> controlValidatorFactory, CompiledAssemblyCache compiledAssemblyCache) { this.config = config.Value; this.controlTreeResolver = controlTreeResolver; this.bindingCompiler = bindingCompiler; this.controlValidatorFactory = controlValidatorFactory; this.assemblyCache = compiledAssemblyCache; }
static CompiledAssemblyCache() { Instance = new CompiledAssemblyCache(); AppDomain.CurrentDomain.AssemblyResolve += Instance.TryResolveAssembly; }
private static Func <string, Expression> CreateTypeLoader(NamespaceImport import, CompiledAssemblyCache compiledAssemblyCache) { if (import.HasAlias) { return t => { if (t.Length >= import.Alias.Length && t.StartsWith(import.Alias, StringComparison.Ordinal)) { string name; if (t == import.Alias) { name = import.Namespace; } else if (t.Length > import.Alias.Length + 1 && t[import.Alias.Length] == '.') { name = import.Namespace + "." + t.Substring(import.Alias.Length + 1); } else { return null; } return TypeRegistry.CreateStatic(compiledAssemblyCache.FindType(name)); } else { return null; } } } ; else { return(t => TypeRegistry.CreateStatic(compiledAssemblyCache.FindType(import.Namespace + "." + t))); } }