public OscriptApplicationModelProvider(ApplicationInstance appObject, IApplicationRuntime framework, IScriptsProvider sourceProvider) { _fw = framework; _app = appObject; _scriptsProvider = sourceProvider; _controllersMethodOffset = ScriptedController.GetOwnMethodsRelectionOffset(); }
public void Configure(IServiceProvider services) { // в режиме тестирования app-instance может быть null Application = services.GetService <ApplicationInstance>(); ScriptsProvider = services.GetRequiredService <IFileProvider>(); Runtime = services.GetRequiredService <IApplicationRuntime>(); }
public AuthorizationModule(LoadedModule module, IFileProvider filesystem, IApplicationRuntime runtime) : base(module) { _filesystem = filesystem; _runtime = runtime; }
public OscriptApplicationModelProvider(ApplicationInstance appObject, IApplicationRuntime framework, IFileProvider sourceProvider, IAuthorizationPolicyProvider authPolicyProvider, ILoggerFactory loggerFactory) : this(appObject, framework, sourceProvider, authPolicyProvider) { _logger = loggerFactory.CreateLogger(GetType()); }
public static void StopDebugCurrentThread(this IApplicationRuntime runtime) { if (!DebugEnabled(runtime)) { return; } runtime.Engine.DebugController.DetachFromThread(); }
public ScriptedMiddlewareActivator(RequestDelegate next, IFileProvider scripts, IApplicationRuntime runtime, string scriptName) { _next = next; _runtime = runtime; var codeSrc = new FileInfoCodeSource(scripts.GetFileInfo(scriptName)); var image = ScriptedMiddleware.CompileModule(runtime.Engine.GetCompilerService(), codeSrc); _module = new LoadedModule(image); }
public static void DebugCurrentThread(this IApplicationRuntime runtime) { if (!DebugEnabled(runtime)) { return; } var machine = MachineInstance.Current; machine.SetDebugMode(runtime.Engine.DebugController.BreakpointManager); runtime.Engine.DebugController.AttachToThread(); }
public static AuthorizationModule CreateInstance(ICodeSource codeSource, IApplicationRuntime runtime, IFileProvider filesystem) { var compiler = runtime.Engine.GetCompilerService(); for (int i = 0; i < _ownMethods.Count; i++) { compiler.DefineMethod(_ownMethods.GetMethodInfo(i)); } var moduleImage = compiler.Compile(codeSource); var module = runtime.Engine.LoadModuleImage(moduleImage); return(new AuthorizationModule(module, filesystem, runtime)); }
internal IList <DataTemplate> CreateDataTemplatesForViewModelsInAssembly(Assembly assembly, IApplicationRuntime application) { var viewModelTypes = assembly.GetExportedTypes().Where(this.TypeRespectsViewModelConvention).ToList(); var viewTypes = assembly.GetExportedTypes().Where(this.TypeRespectsViewConvention).ToList(); var viewModelTypesWithoutDataTemplate = viewModelTypes.Where(type => !this.HasDataTemplateResourceForType(type, application)).ToList(); if (!viewModelTypesWithoutDataTemplate.Any()) { return(new List <DataTemplate>()); } return(this.CreateDataTemplatesFor(viewModelTypesWithoutDataTemplate, viewTypes)); }
public static ApplicationInstance Create(ICodeSource src, IApplicationRuntime webApp) { var compiler = webApp.Engine.GetCompilerService(); for (int i = 0; i < OwnMethods.Count; i++) { compiler.DefineMethod(OwnMethods.GetMethodInfo(i)); } var bc = compiler.CreateModule(src); var app = new ApplicationInstance(webApp.Engine.LoadModuleImage(bc)); webApp.Engine.InitializeSDO(app); return(app); }
internal void RegisterDataTemplates(IApplicationRuntime application) { var dataTemplateAggregator = new ViewDataTemplateAggregator(); var stopWatch = new Stopwatch(); stopWatch.Start(); var dataTemplateDictionary = dataTemplateAggregator.CreateDataTemplateDictionaryForViewModelsInAssembly(this.GetType().GetTypeInfo().Assembly); stopWatch.Stop(); DataTemplateInitializerLogger.DebugFormat("DataTemplates initialized in {0} ms.", stopWatch.ElapsedMilliseconds); if (dataTemplateDictionary.Count > 0) { application.AddResource(dataTemplateDictionary); } }
private void AppendScriptedHandlers(IApplicationRuntime runtime, IFileProvider filesystem) { var authFile = filesystem.GetFileInfo("auth.os"); if (!authFile.Exists || authFile.IsDirectory) { return; } runtime.Environment.LoadMemory(MachineInstance.Current); var codeSource = new FileInfoCodeSource(authFile); var registrator = AuthorizationModule.CreateInstance(codeSource, runtime, filesystem); registrator.OnRegistration(_handlers); }
public static ApplicationInstance Create(ICodeSource src, IApplicationRuntime webApp) { var compiler = webApp.Engine.GetCompilerService(); for (int i = 0; i < OwnMethods.Count; i++) { compiler.DefineMethod(OwnMethods.GetMethodInfo(i)); } var bc = compiler.Compile(src); var app = new ApplicationInstance(new LoadedModule(bc)); var machine = MachineInstance.Current; webApp.Environment.LoadMemory(machine); webApp.Engine.InitializeSDO(app); return(app); }
public OscriptApplicationModelProvider(ApplicationInstance appObject, IApplicationRuntime framework, IFileProvider sourceProvider, IAuthorizationPolicyProvider authPolicyProvider) { _fw = framework; _app = appObject; _scriptsProvider = sourceProvider; _policyProvider = authPolicyProvider; _classAttribResolver = new ClassAttributeResolver(); if (!_fw.Engine.DirectiveResolvers.Any(x => x is ClassAttributeResolver)) { _fw.Engine.DirectiveResolvers.Add(_classAttribResolver); } FillDefaultMappers(); }
public OscriptApplicationModelProvider(ApplicationInstance appObject, IApplicationRuntime framework, IFileProvider sourceProvider, IAuthorizationPolicyProvider authPolicyProvider) { _fw = framework; _app = appObject; _scriptsProvider = sourceProvider; _controllersMethodOffset = ScriptedController.GetOwnMethodsRelectionOffset(); _policyProvider = authPolicyProvider; _classAttribResolver = new ClassAttributeResolver(); if (_fw.Engine.DirectiveResolver is DirectiveMultiResolver resolvers) { if (!resolvers.Any(x => x is ClassAttributeResolver)) { resolvers.Add(_classAttribResolver); } } }
public WebGlobalContext(IHostApplication host, ICodeSource entryScript, IApplicationRuntime webEng) { var sys = new SystemGlobalContext(); sys.ApplicationHost = host; sys.CodeSource = entryScript; if (webEng != null) { sys.EngineInstance = webEng.Engine; } _osGlobal = new RCIRedirector(sys); _osGlobal.PublishProperty("Символы", null); _osGlobal.PublishProperty("Chars", null); _osGlobal.PublishProperty("ФайловыеПотоки", null); _osGlobal.PublishProperty("FileStreams", null); _osGlobal.PublishMethod("ОсвободитьОбъект", "FreeObject"); _osGlobal.PublishMethod("ВыполнитьСборкуМусора", "RunGarbageCollection"); _osGlobal.PublishMethod("ЗапуститьПриложение", "RunApp"); _osGlobal.PublishMethod("СоздатьПроцесс", "CreateProcess"); _osGlobal.PublishMethod("НайтиПроцессПоИдентификатору", "FindProcessById"); _osGlobal.PublishMethod("НайтиПроцессыПоИмени", "FindProcessesByName"); _osGlobal.PublishMethod("КраткоеПредставлениеОшибки", "BriefErrorDescription"); _osGlobal.PublishMethod("КаталогПрограммы", "ProgramDirectory"); _osGlobal.PublishMethod("ПодробноеПредставлениеОшибки", "DetailErrorDescription"); _osGlobal.PublishMethod("ТекущаяДата", "CurrentDate"); _osGlobal.PublishMethod("ТекущаяУниверсальнаяДатаВМиллисекундах", "CurrentUniversalDateInMilliseconds"); _osGlobal.PublishMethod("ЗначениеЗаполнено", "IsValueFilled"); _osGlobal.PublishMethod("ЗаполнитьЗначенияСвойств", "FillPropertyValues"); _osGlobal.PublishMethod("ПолучитьCOMОбъект", "GetCOMObject"); _osGlobal.PublishMethod("Приостановить", "Sleep"); _osGlobal.PublishMethod("ПодключитьВнешнююКомпоненту", "AttachAddIn"); _osGlobal.PublishMethod("ЗагрузитьСценарий", "LoadScript"); _osGlobal.PublishMethod("ЗагрузитьСценарийИзСтроки", "LoadScriptFromString"); _osGlobal.PublishMethod("ПодключитьСценарий", "AttachScript"); _osGlobal.PublishMethod("Сообщить", "Message"); _osGlobal.PublishMethod("СтартовыйСценарий", "StartupScript"); sys.InitInstance(); }
private IDirectiveResolver CaptureStdResolverAdHoc(IApplicationRuntime runtime, string root, string[] additionals) { var asm = typeof(SystemGlobalContext).Assembly; var resolverType = asm.GetType("ScriptEngine.HostedScript.LibraryResolver", true); var args = new object[] { runtime.Engine, runtime.Environment }; var ctor = resolverType.GetConstructor( BindingFlags.Instance | BindingFlags.Public, null, args.Select(x => x.GetType()).ToArray(), null); var resolver = ctor.Invoke(args); resolverType.GetProperty("LibraryRoot")?.SetValue(resolver, root); if (additionals != null) { resolverType.GetProperty("SearchDirectories")?.SetValue(resolver, additionals.ToList()); } return((IDirectiveResolver)resolver); }
public AppStarter(IScriptsProvider scripts, IApplicationRuntime webEng, IConfigurationRoot config) { _scripts = scripts; _webEng = webEng; var configSection = config.GetSection("OneScript"); var libRoot = configSection?["lib.system"]; if (libRoot != null) { var binFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var additionals = configSection.GetSection("lib.additional")? .AsEnumerable() .Where(x => x.Value != null) .Select(x => x.Value.Replace("$appBinary", binFolder)) .ToArray(); libRoot = libRoot.Replace("$appBinary", binFolder); _webEng.Engine.DirectiveResolver = new LibraryResolverAdHoc(webEng, libRoot, additionals); } }
public AppStarter(IFileProvider scripts, IApplicationRuntime webEng, IConfiguration config, ILogger <ApplicationInstance> appLog) { _scripts = scripts; _webEng = webEng; _logger = appLog; var configSection = config?.GetSection("OneScript"); var libRoot = configSection?["lib.system"]; if (libRoot != null) { var binFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var additionals = configSection.GetSection("lib.additional")? .AsEnumerable() .Where(x => x.Value != null) .Select(x => x.Value.Replace("$appBinary", binFolder)) .ToArray(); libRoot = libRoot.Replace("$appBinary", binFolder); InitializeDirectiveResolver(_webEng.Engine, _webEng.Environment, libRoot, additionals); } }
public Startup(IApplicationRuntime moryxRuntime) { _moryxRuntime = moryxRuntime; }
/// <summary> /// Конструктор посредника /// </summary> /// <param name="next">Следующий обработчик в конвейере</param> /// <param name="module">Скомпилированный модуль посредника</param> public ScriptedMiddleware(RequestDelegate next, LoadedModule module, IApplicationRuntime runtime) : base(module, true) { _next = next; _runtime = runtime; InitOwnData(); }
public ScriptedControllerActivator(IApplicationRuntime app) { _engine = app.Engine; }
public static void AddMoryxFacades(this IServiceCollection serviceCollection, IApplicationRuntime runtime) { var facadeCollector = runtime.GlobalContainer.Resolve <IFacadeCollector>(); var facades = facadeCollector.Facades; foreach (var facade in facades) { // Register facade for all its interfaces foreach (var facadeApi in facade.GetType().GetInterfaces()) { serviceCollection.AddSingleton(facadeApi, facade); } } }
public OneScriptAuthorizationHandlerProvider(IEnumerable <IAuthorizationHandler> defaultHandlers, IFileProvider filesystem, IApplicationRuntime runtime) { _handlers = new List <IAuthorizationHandler>(defaultHandlers); AppendScriptedHandlers(runtime, filesystem); }
private object TryFindResource(Type associatedType, IApplicationRuntime application) { var key = new DataTemplateKey(associatedType); return(application.TryFindResource(key)); }
private bool HasDataTemplateResourceForType(Type type, IApplicationRuntime application) { return(this.TryFindResource(type, application) != null); }
public ScriptedControllerActivator(IApplicationRuntime app, ApplicationDbContext dbContext) { _runtime = app; _dbContext = dbContext; }
public ScriptedControllerActivator(IApplicationRuntime app) : this(app, null) { }
public static ScriptedAuthorizationHandler CreateInstance(FileInfoCodeSource codeSource, IApplicationRuntime runtime) { var compiler = runtime.Engine.GetCompilerService(); var moduleImage = compiler.Compile(codeSource); var module = runtime.Engine.LoadModuleImage(moduleImage); return(new ScriptedAuthorizationHandler(module)); }
public NavigationHandler(IApplicationRuntime applicationRuntime, INavigationTargetProvider navigationTargetProvider) { this._applicationRuntime = applicationRuntime; this._navigationTargetProvider = navigationTargetProvider; }