// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var coreBootstrapper = new CoreBootstrapper(); services.AddSingleton <IFunctionsProvider, FunctionsProvider>(); services.AddSingleton <IScriptsProvider, ScriptsProvider>(); services.AddSingleton <IAutocompleteProvider, AutocompleteProvider>(isp => coreBootstrapper.Create <AutocompleteProvider>()); services.AddSingleton <IExpressionsEvaluator, ExpressionsEvaluator>(isp => coreBootstrapper.Create <ExpressionsEvaluator>()); services.AddSingleton <IScriptEvaluator, ScriptEvaluator>(isp => coreBootstrapper.Create <ScriptEvaluator>()); services.AddSingleton <IModeDeterminer, ModeDeterminer>(isp => coreBootstrapper.Create <ModeDeterminer>()); services.AddSingleton <IChartFactory>(isp => RuntimeObjectFactory.CreateInstance <IChartFactory>("Charting")); services.AddCors(); // Add framework services. services.AddMvc(); // Register the Swagger generator, defining one or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Computator.NET.Web API", Version = "v1" }); }); }
public static IntPtr RuntimeCacheLookup(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult) { return(TypeLoaderExports.RuntimeCacheLookupInCache(context, signature, factory, contextObject, out auxResult)); }
private static unsafe Entry CacheMiss(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject = null) { IntPtr result = IntPtr.Zero, auxResult = IntPtr.Zero; bool previouslyCached = false; // // Try to find the entry in the previous version of the cache that is kept alive by weak reference // if (s_previousCache.IsAllocated) { Entry[] previousCache = (Entry[])s_previousCache.Target; if (previousCache != null) { Entry previousEntry = LookupInCache(previousCache, context, signature); if (previousEntry != null) { result = previousEntry.Result; auxResult = previousEntry.AuxResult; previouslyCached = true; } } } // // Call into the type loader to compute the target // if (!previouslyCached) { result = factory(context, signature, contextObject, ref auxResult); } // // Update the cache under the lock // if (s_lock == null) { Interlocked.CompareExchange(ref s_lock, new Lock(), null); } s_lock.Acquire(); try { // Avoid duplicate entries Entry existingEntry = LookupInCache(s_cache, context, signature); if (existingEntry != null) { return(existingEntry); } // Resize cache as necessary Entry[] cache = ResizeCacheForNewEntryAsNecessary(); int key = ((context.GetHashCode() >> 4) ^ signature.GetHashCode()) & (cache.Length - 1); Entry newEntry = new Entry() { Context = context, Signature = signature, Result = result, AuxResult = auxResult, Next = cache[key] }; cache[key] = newEntry; return(newEntry); } finally { s_lock.Release(); } }
internal static IntPtr RuntimeCacheLookupInCache(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult) { Entry entry = LookupInCache(s_cache, context, signature); if (entry == null) { entry = CacheMiss(context, signature, factory, contextObject); } auxResult = entry.AuxResult; return(entry.Result); }