/// <summary> /// /// </summary> /// <param name="url"></param> /// <returns></returns> public virtual Type GetCompiledDslType(string url) { url = _storage.Normalize(url); if (_typeCache.Count == 0) { try { string[] urls = _storage.GetScriptUrls().ToArray(); if (urls != null && urls.Contains(url)) { TryRecompile(urls, CompilationMode.Compile); } } catch (Exception ex) { _typeCache["_123compile_error"] = new TypeCacheEntry { Url = ex.Message }; } } TypeCacheEntry tp; if (_typeCache.TryGetValue(url, out tp)) { return(tp.DslType); } Type t2 = TryRecompile(url, CompilationMode.Compile); return(t2); }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <returns></returns> public virtual Type GetCompiledDslType(string url) { url = _storage.Normalize(url); if (_typeCache.Count == 0) { try { string[] urls = _storage.GetScriptUrls().ToArray(); if (urls != null && urls.Contains(url)) { TryRecompile(urls, CompilationMode.Compile); } } catch (Exception ex) { _typeCache["_123compile_error"] = new TypeCacheEntry { Url = ex.Message }; Console.WriteLine("Error when compiling all urls - will try to recompile only {1}: {0}", ex, url); } } TypeCacheEntry tp; if (_typeCache.TryGetValue(url, out tp)) { return(tp.DslType); } Console.WriteLine("type not found in cache - compiling only {0}", url); Type t2 = TryRecompile(url, CompilationMode.Compile); return(t2); }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <returns></returns> public virtual Type GetCompiledDslType(string url) { url = _storage.Normalize(url); var dAll = false; bool recompile = false; lock (_typeCache) { //recompile all only when first time if (_typeCache.Count == 0 && !CompileSeparately) { try { string[] urls = _storage.GetScriptUrls().ToArray(); if (urls != null && urls.Contains(url)) { log.Warn("Attempt to recompile all scripts for url {0} (in all: {1}). ", string.Join(",", urls), url); TryRecompile(urls, CompilationMode.Compile); dAll = true; } else { log.Warn("Will not recompile all scripts for url {0} ({1}). ", url, urls); } } catch (Exception ex) { _typeCache["_123compile_error"] = new TypeCacheEntry { Url = ex.Message, CompiledDate = DateTime.Now }; log.Error("Error when compiling all urls - will try to recompile only {1}: {0}", ex, url); } } TypeCacheEntry tce; if (!_typeCache.TryGetValue(url, out tce)) { recompile = true; } if (!recompile) { recompile = CheckScriptModifications(url); } if (!recompile) { return(tce.DslType); } log.Warn("dsl type not found in cache - compiling only {0}. CACHE: {1}", url, string.Join(",", _typeCache.Keys)); if (dAll) { throw new Exception("DSL type not found in cache after recompiling all: " + url); } Type t2 = TryRecompile(url, CompilationMode.Compile); return(t2); } }