public IndexModule(IPbApiClient pbApiClient, IEntryPoint entryPoint, IConnectToBilling billingConnector) { Get["/"] = parameters => { var token = Context.AuthorizationHeaderToken(); var metaData = pbApiClient.Get<ApiMetaData>(token, "getUserMetaData"); return Response.AsJson(metaData); }; Post["/action/{action}"] = parameters => { var token = Context.AuthorizationHeaderToken(); var packageResponse = pbApiClient.Get<Package>(token, "package/" + parameters.action); var package = Mapper.DynamicMap<IPackage>(packageResponse); var vehicle = this.Bind<Vechicle>(); var request = new LicensePlateNumberRequest(package, new User(), new Context(), vehicle, new AggregationInformation()); var responses = entryPoint.GetResponsesFromLace(request); var packageIdentifier = new PackageIdentifier(packageResponse.Id, new VersionIdentifier(1)); var requestIdentifier = new RequestIdentifier(Guid.NewGuid(), SystemIdentifier.CreateApi()); var userIdentifier = new UserIdentifier(((IEntity)Context.CurrentUser).Id); var transactionContext = new TransactionContext(Guid.NewGuid(), userIdentifier, requestIdentifier); var createTransaction = new CreateTransaction(packageIdentifier, transactionContext); billingConnector.CreateTransaction(createTransaction); return Response.AsJson(responses.First().Response); }; }
public static void DefineEntryPoint(IEntryPoint e) { var settings = new { PackageName = Path.GetFileNameWithoutExtension(typeof(Program).Assembly.Location) + ".jar", ProjectName = typeof(Program).Name, CompilandNamespace0 = typeof(Program).Namespace.Replace(".", "/"), CompilandNamespace1 = typeof(Program).Namespace, CompilandType = typeof(Program).Name, CompilandFullName = typeof(Program).Namespace + "." + typeof(Program).Name, }; using (var w = new StringWriter()) { w.WriteLine(":: settings for current project modified at " + DateTime.Now); WriteSettings(w, settings); e[SettingsFileName] = w.ToString(); } e["release/META-INF/MANIFEST.MF"] = "Main-Class: " + settings.CompilandFullName + Environment.NewLine + "Created-By: jsc.sf.net"; }
public when_sending_property_request_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new PropertyRequestBuilder().ForPropertySources(); _entryPoint = new EntryPointService(_bus); }
public when_sending_company_request_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new CompanyRequestBuilder().ForLightstoneCompany(); _entryPoint = new EntryPointService(_bus); }
public when_sending_director_request_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new DirectorRequestBuilder().ForLightstoneDirector(); _entryPoint = new EntryPointService(_bus); }
public static void DefineEntryPoint(IEntryPoint e) { e["java/WEB-INF/web.xml"] = @"<?xml version='1.0' encoding='ISO-8859-1'?> <web-app xmlns='http://java.sun.com/xml/ns/javaee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd' version='2.5'> <display-name>{ProjectName}</display-name> <servlet> <servlet-name>{ServletName}</servlet-name> <servlet-class>{ServletNamespace}.{ServletName}</servlet-class> </servlet> <servlet-mapping> <servlet-name>{ServletName}</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> " .Replace("{ProjectName}", Path.GetFileNameWithoutExtension(typeof(HelloAppEngineServlet).Assembly.Location)) .Replace("{ServletName}", typeof(HelloAppEngineServlet).Name) .Replace("{ServletNamespace}", typeof(HelloAppEngineServlet).Namespace) ; }
public static void DefineEntryPoint(IEntryPoint e) { CreatePHPIndexPage(e, Server.Application.Filename, Server.Application.Application_Entrypoint); e[typeof(ApplicationApplet).Name + ".htm"] = new XElement("body", new XAttribute("style", "margin: 0;"), ToElementWithAttributes("applet", new AppletElementInfo { code = typeof(ApplicationApplet).FullName, codebase = "bin", archive = typeof(ApplicationApplet).Name + "Package.jar", width = ApplicationApplet.DefaultWidth, height = ApplicationApplet.DefaultHeight, mayscript = "true" } /*, ToParameters( new { foo = "unused", bar = "unused" } ).ToArray()*/ ) ).ToString(); }
//private readonly IAdvancedBus _bus; public when_getting_meta_data_for_vehicle_search() { //_bus = BusFactory.WorkflowBus(); _entryPoint = new MetadataEntryPointService(); _request = new LicensePlateRequestBuilder().ForAllSources(); }
private static void CreatePHPIndexPage(IEntryPoint e, string file_name, Action entryfunction) { { var a = new StringBuilder(); a.AppendLine("<?"); foreach (var u in SharedHelper.LocalModulesOf(Assembly.GetExecutingAssembly(), ScriptType.PHP)) { a.AppendLine("require_once '" + u + ".php';"); } a.AppendLine(entryfunction.Method.Name + "();"); a.AppendLine("?>"); e[file_name] = a.ToString(); } { var w = new StringBuilder(); SharedHelper.LoadReferencedAssemblies(Assembly.GetExecutingAssembly(), true).Where( a => a.GetCustomAttributes(typeof(ScriptTypeFilterAttribute), false).Cast<ScriptTypeFilterAttribute>().Any(k => k.Type == ScriptType.JavaScript) ).Select(k => new FileInfo(k.Location).Name).ForEach( src => w.AppendLine("<script type='text/javascript' src='" + src + ".js'></script>") ); e[file_name + ".js"] = w.ToString(); } }
/// <summary> /// Simulates the entry point. /// </summary> /// <param name="settings">The driver settings.</param> /// <param name="entryPoint">The entry point.</param> /// <param name="parseResult">The command-line parsing result.</param> /// <param name="simulator">The simulator to use.</param> /// <returns>The exit code.</returns> internal static async Task <int> Simulate( DriverSettings settings, IEntryPoint <TIn, TOut> entryPoint, ParseResult parseResult, string simulator) { if (simulator == settings.ResourcesEstimatorName) { var resourcesEstimator = new ResourcesEstimator(); await resourcesEstimator.Run <TCallable, TIn, TOut>(entryPoint.CreateArgument(parseResult)); Console.WriteLine(resourcesEstimator.ToTSV()); } else { var(isCustom, createSimulator) = simulator == settings.QuantumSimulatorName ? (false, () => new QuantumSimulator()) : simulator == settings.ToffoliSimulatorName ? (false, new Func <IOperationFactory>(() => new ToffoliSimulator())) : (true, entryPoint.CreateDefaultCustomSimulator); if (isCustom && simulator != entryPoint.DefaultSimulatorName) { DisplayCustomSimulatorError(simulator); return(1); } await RunSimulator(entryPoint, parseResult, createSimulator); } return(0); }
/// <summary> /// Simulates the entry point. /// </summary> /// <param name="settings">The driver settings.</param> /// <param name="entryPoint">The entry point.</param> /// <param name="parseResult">The command-line parsing result.</param> /// <param name="simulator">The simulator to use.</param> /// <returns>The exit code.</returns> internal static async Task <int> Simulate( DriverSettings settings, IEntryPoint <TIn, TOut> entryPoint, ParseResult parseResult, string simulator) { if (simulator == settings.ResourcesEstimatorName) { // Force the explicit load of the QSharp.Core assembly so that the ResourcesEstimator // can discover it dynamically at runtime and override the defined callables. var coreAssemblyName = (from aName in entryPoint.GetType().Assembly.GetReferencedAssemblies() where aName.Name == "Microsoft.Quantum.QSharp.Core" select aName).First(); var coreAssembly = Assembly.Load(coreAssemblyName.FullName); var resourcesEstimator = new ResourcesEstimator(coreAssembly); await resourcesEstimator.Run <TCallable, TIn, TOut>(entryPoint.CreateArgument(parseResult)); Console.WriteLine(resourcesEstimator.ToTSV()); } else { var(isCustom, createSimulator) = simulator == settings.QuantumSimulatorName ? (false, () => new QuantumSimulator()) : simulator == settings.ToffoliSimulatorName ? (false, new Func <IOperationFactory>(() => new ToffoliSimulator())) : (true, entryPoint.CreateDefaultCustomSimulator); if (isCustom && simulator != entryPoint.DefaultSimulatorName) { DisplayCustomSimulatorError(simulator); return(1); } await RunSimulator(entryPoint, parseResult, createSimulator); } return(0); }
//private readonly IAdvancedBus _bus; public when_getting_meta_data_for_company_search() { //_bus = BusFactory.WorkflowBus(); _entryPoint = new MetadataEntryPointService(); _request = new CompanyRequestBuilder().ForLightstoneCompany(); }
/// <summary> /// Submits a job to Azure Quantum. /// </summary> /// <param name="machine">The quantum machine target.</param> /// <param name="entryPoint">The program entry point.</param> /// <param name="input">The program input.</param> /// <param name="settings">The submission settings.</param> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TOut">The output type.</typeparam> /// <returns>The exit code.</returns> private static async Task <int> SubmitJob <TIn, TOut>( IQuantumMachine machine, IEntryPoint <TIn, TOut> entryPoint, TIn input, AzureSettings settings) { try { var job = await machine.SubmitAsync(entryPoint.Info, input, new SubmissionContext { FriendlyName = settings.JobName, Shots = settings.Shots }); DisplayJob(job, settings.Output); return(0); } catch (AzureQuantumException ex) { DisplayError( "Something went wrong when submitting the program to the Azure Quantum service.", ex.Message); return(1); } catch (QuantumProcessorTranslationException ex) { DisplayError( "Something went wrong when performing translation to the intermediate representation used by the " + "target quantum machine.", ex.Message); return(1); } }
//# http://www.amenco.com/golivein24//tips/dynamic_content/03_apache_alias.html //# Alias for all php test sites //Alias /jsc/AvalonExampleGallery "C:\work\jsc.svn\examples\php\AvalonExampleGallery.Server\bin\Debug\web" //<Directory "C:\work\jsc.svn\examples\php\AvalonExampleGallery.Server\bin\Debug\web"> // Options Indexes FollowSymLinks ExecCGI // AllowOverride All // Order allow,deny // Allow from all //</Directory> public static void DefineEntryPoint(IEntryPoint e) { CreatePHPIndexPage(e, php.OrcasPHPScriptApplicationBackend.Filename, php.OrcasPHPScriptApplicationBackend.WebPageEntry); // http://www.javascriptkit.com/howto/htaccess6.shtml e[".htaccess"] = "AddType application/x-ms-xbap xbap" + Environment.NewLine + "DirectoryIndex " + php.OrcasPHPScriptApplicationBackend.Filename; }
/// <summary> /// Validates the program for the quantum machine target. /// </summary> /// <param name="machine">The quantum machine target.</param> /// <param name="entryPoint">The program entry point.</param> /// <param name="input">The program input.</param> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TOut">The output type.</typeparam> /// <returns>The exit code.</returns> private static int Validate <TIn, TOut>(IQuantumMachine machine, IEntryPoint <TIn, TOut> entryPoint, TIn input) { var(isValid, message) = machine.Validate(entryPoint.Info, input); Console.WriteLine(isValid ? "✔️ The program is valid!" : "❌ The program is invalid."); if (!string.IsNullOrWhiteSpace(message)) { Console.WriteLine(); Console.WriteLine(message); } return(isValid ? 0 : 1); }
private void LoadAndConfigureModule(Stream stream) { var part = new AssemblyPart(); var assembly = part.Load(stream); _actualEntryPoint = (IEntryPoint)Activator.CreateInstance( assembly.GetExportedTypes().First( x => typeof(IEntryPoint).IsAssignableFrom(x)) ); ServiceLocator.Current.GetInstance<IAssemblySource>() .Add(assembly); }
public EntryPointDefinitions(ref AssemblyDefinition assDef, IEntryPoint entryPoint) { try { m_assemblyDef = assDef; m_typeDef = m_assemblyDef.MainModule.GetType(entryPoint.TypeName); m_methodDef = m_typeDef.Methods.First(x => x.Name == entryPoint.MethodName); m_entryPointValid = true; } catch (Exception) { if (m_assemblyDef != null) { Dispose(true); } m_entryPointValid = false; } }
/// <summary> /// Creates a new driver for the entry point. /// </summary> /// <param name="settings">The driver settings.</param> /// <param name="entryPoint">The entry point.</param> public Driver(DriverSettings settings, IEntryPoint <TIn, TOut> entryPoint) { this.settings = settings; this.entryPoint = entryPoint; SimulatorOption = new OptionInfo <string>( settings.SimulatorOptionAliases, entryPoint.DefaultSimulatorName, "The name of the simulator to use.", suggestions: new[] { settings.QuantumSimulatorName, settings.ToffoliSimulatorName, settings.ResourcesEstimatorName, entryPoint.DefaultSimulatorName }); }
private static void CreatePHPIndexPage(IEntryPoint e, string file_name, Action entryfunction) { var a = new StringBuilder(); a.AppendLine("<?"); foreach (var u in SharedHelper.LocalModulesOf(Assembly.GetExecutingAssembly(), ScriptType.PHP)) { a.AppendLine("require_once '" + u + ".php';"); } a.AppendLine(entryfunction.Method.Name + "();"); a.AppendLine("?>"); e[file_name] = a.ToString(); }
public static void DefineEntryPoint(IEntryPoint e) { var settings = new SettingsInfo { ProjectName = PrimaryAppletSettings.Alias, CompilandNamespace0 = typeof(PrimaryApplet).Namespace.Replace(".", "/"), CompilandNamespace1 = typeof(PrimaryApplet).Namespace, AppletWebPage = PrimaryAppletSettings.Alias + ".htm", CompilandType = typeof(PrimaryApplet).Name, CompilandFullName = typeof(PrimaryApplet).Namespace + "." + typeof(PrimaryApplet).Name, PackageName = typeof(PrimaryApplet).Name + "Package.jar", }; using (var w = new StringWriter()) { w.WriteLine(":: settings for current project modified at " + DateTime.Now); WriteSettings(w, settings); e[SettingsFileName] = w.ToString(); } e[settings.AppletWebPage] = new XElement("body", new XAttribute("style", "margin: 0;"), ToElementWithAttributes("applet", new AppletElementInfo { code = settings.CompilandFullName, codebase = "bin", archive = settings.PackageName, width = PrimaryAppletSettings.DefaultWidth, height = PrimaryAppletSettings.DefaultHeight, mayscript = "true" } /*, ToParameters( new { foo = "unused", bar = "unused" } ).ToArray()*/ ) ).ToString(); }
public static void DefineEntryPoint(IEntryPoint e) { var settings = new SettingsInfo { ProjectName = typeof(PrimaryApplet).Name, CompilandNamespace0 = typeof(PrimaryApplet).Namespace.Replace(".", "/"), CompilandNamespace1 = typeof(PrimaryApplet).Namespace, AppletWebPage = typeof(PrimaryApplet).Name + ".htm", CompilandType = typeof(PrimaryApplet).Name, CompilandFullName = typeof(PrimaryApplet).Namespace + "." + typeof(PrimaryApplet).Name, PackageName = typeof(PrimaryApplet).Name + "Package.jar", }; using (var w = new StringWriter()) { w.WriteLine(":: settings for current project modified at " + DateTime.Now); WriteSettings(w, settings); e[SettingsFileName] = w.ToString(); } e[settings.AppletWebPage] = new XElement("body", new XAttribute("style", "margin: 0;"), ToElementWithAttributes("applet", new AppletElementInfo { code = settings.CompilandFullName, codebase = "bin", archive = settings.PackageName, width = PrimaryApplet.DefaultWidth, height = PrimaryApplet.DefaultHeight, mayscript = "true" } /*, ToParameters( * new { * foo = "unused", * bar = "unused" * } * ).ToArray()*/ ) ).ToString(); }
public void Startup(IEntryPoint entryPoint) { if (Ctx != null) { throw new UnexpectedElfRuntimeException(VM, "This thread is already started"); } else { Ctx = new RuntimeContext(); Ctx.Bind(VM); Ctx.CallStack.Push(new NativeCallContext(entryPoint.CodePoint, entryPoint.This, entryPoint.Args)); VM.Threads.Add(this); EntryPoint = entryPoint; ExecutionResult = new ElfVoid(); Status = ThreadStatus.Running; } }
/// <summary> /// Creates a new driver for the entry point. /// </summary> /// <param name="entryPoint">The entry point.</param> public Driver(IEntryPoint <TIn, TOut> entryPoint) { this.entryPoint = entryPoint; SimulatorOption = new OptionInfo <string>( new[] { "--" + CommandLineArguments.SimulatorOption.Item1, "-" + CommandLineArguments.SimulatorOption.Item2 }, entryPoint.DefaultSimulator, "The name of the simulator to use.", suggestions: new[] { AssemblyConstants.QuantumSimulator, AssemblyConstants.ToffoliSimulator, AssemblyConstants.ResourcesEstimator, entryPoint.DefaultSimulator }); }
public void SetUp() { var codebase = Path.GetDirectoryName(GetType().Assembly.Location); var possiblePlugins = Directory.GetFiles(codebase, "*.dll"); possiblePlugins.ForEach(file => { try { var asmBytes = File.ReadAllBytes(file); AppDomain.CurrentDomain.Load(asmBytes); } catch {/*ignore load failures*/} }); var elfCode = ResourceHelper.ReadFromResource("Elf.Playground.Staple.Universal.elf"); _vm = new VirtualMachine(); _toyLog = new StringBuilder(); _vm.Context["ToyLog"] = _toyLog; _vm.Load(elfCode); _ep = _vm.CreateEntryPoint("Script", "Main"); }
/// <summary> /// Check whether the game assembly has been already patched. /// </summary> /// <returns>True if injected, false otherwise</returns> internal bool IsInjected(AssemblyDefinition assembly, IEntryPoint sourcePoint, IEntryPoint targetPoint) { TypeDefinition type = assembly.MainModule.GetType(targetPoint.TypeName); if ((type == null) || !type.IsClass) { throw new EntryPointNotFoundException("Invalid entry point type"); } MethodDefinition methodDefinition = type.Methods.FirstOrDefault(meth => meth.Name == targetPoint.MethodName); if ((methodDefinition == null) || !methodDefinition.HasBody) { throw new EntryPointNotFoundException("Invalid entry point method"); } Instruction [] instructions = methodDefinition.Body.Instructions.Where(instr => instr.OpCode == OpCodes.Call).ToArray(); return(instructions.FirstOrDefault(instr => instr.Operand.ToString().Contains(sourcePoint.ToString())) != null); }
private static void CreatePHPIndexPage(IEntryPoint e, string file_name, Action entryfunction) { var w = new StringBuilder(); w.AppendLine("<?"); foreach (var kk in SharedHelper.LoadReferencedAssemblies(typeof(Application).Assembly, true)) { var k = Path.GetFileName(kk.Location); Console.WriteLine("adding " + k); w.AppendLine("require_once '" + k + ".php';"); } w.AppendLine(entryfunction.Method.Name + "();"); w.AppendLine("?>"); e[file_name] = w.ToString(); }
private static void CreatePHPIndexPage(IEntryPoint e, string file_name, string entryfunction) { var w = new StringBuilder(); w.AppendLine("<?"); foreach (var kk in SharedHelper.LoadReferencedAssemblies(typeof(OrcasPHPScriptApplicationBackend).Assembly, true)) { var k = Path.GetFileName(kk.Location); Console.WriteLine("adding " + k); w.AppendLine("require_once '" + k + ".php';"); } w.AppendLine(entryfunction + "();"); w.AppendLine("?>"); e[file_name] = w.ToString(); }
/// <summary> /// Runs the entry point on a simulator and displays its return value. /// </summary> /// <param name="entryPoint">The entry point.</param> /// <param name="parseResult">The command-line parsing result.</param> /// <param name="createSimulator">A function that creates an instance of the simulator to use.</param> private static async Task RunSimulator( IEntryPoint <TIn, TOut> entryPoint, ParseResult parseResult, Func <IOperationFactory> createSimulator) { var simulator = createSimulator(); try { var value = await simulator.Run <TCallable, TIn, TOut>(entryPoint.CreateArgument(parseResult)); if (!(value is QVoid)) { Console.WriteLine(value); } } finally { if (simulator is IDisposable disposable) { disposable.Dispose(); } } }
public static void DefineEntryPoint(IEntryPoint e) { Console.WriteLine("DefineEntryPoint"); var Target = typeof(Cafebabe2); var aid = new AIDAttribute.Info(Target); var settings = new XSettings { AppletAID = aid.AppletAID, PackageAID = aid.PackageAID, ProjectName = typeof(Cafebabe2).Name, CompilandNamespace0 = typeof(Cafebabe2).Namespace.Replace(".", "/"), CompilandNamespace1 = typeof(Cafebabe2).Namespace, CompilandType = typeof(Cafebabe2).Name, CompilandFullName = typeof(Cafebabe2).Namespace + "." + typeof(Cafebabe2).Name, }; using (var w = new StringWriter()) { w.WriteLine(":: settings for current project modified at " + DateTime.Now); WriteSettings(w, settings); e["web/" + SettingsFileName] = w.ToString(); } // C:\util\java_card_kit-2_2_1\doc\en\guides // cJDC_Users_Guide.pdf //e["release/META-INF/MANIFEST.MF"] = // "Main-Class: " + settings.CompilandFullName + Environment.NewLine + // "Created-By: jsc.sf.net"; }
public static void DefineEntryPoint(IEntryPoint e) { Console.WriteLine("DefineEntryPoint"); var Target = typeof(Cafebabe); var aid = new AIDAttribute.Info(Target); var settings = new XSettings { AppletAID = aid.AppletAID, PackageAID = aid.PackageAID, ProjectName = typeof(Cafebabe).Name, CompilandNamespace0 = typeof(Cafebabe).Namespace.Replace(".", "/"), CompilandNamespace1 = typeof(Cafebabe).Namespace, CompilandType = typeof(Cafebabe).Name, CompilandFullName = typeof(Cafebabe).Namespace + "." + typeof(Cafebabe).Name, }; using (var w = new StringWriter()) { w.WriteLine(":: settings for current project modified at " + DateTime.Now); WriteSettings(w, settings); e["web/" + SettingsFileName] = w.ToString(); } // C:\util\java_card_kit-2_2_1\doc\en\guides // cJDC_Users_Guide.pdf //e["release/META-INF/MANIFEST.MF"] = // "Main-Class: " + settings.CompilandFullName + Environment.NewLine + // "Created-By: jsc.sf.net"; }
/// <summary> /// Creates a new driver for the entry point. /// </summary> /// <param name="settings">The driver settings.</param> /// <param name="entryPoint">The entry point.</param> public Driver(DriverSettings settings, IEntryPoint <TIn, TOut> entryPoint) { this.settings = settings; this.entryPoint = entryPoint; SimulatorOption = new OptionInfo <string>( settings.SimulatorOptionAliases, entryPoint.DefaultSimulatorName, "The name of the simulator to use.", suggestions: new[] { settings.QuantumSimulatorName, settings.ToffoliSimulatorName, settings.ResourcesEstimatorName, entryPoint.DefaultSimulatorName }); var targetAliases = ImmutableList.Create("--target"); const string targetDescription = "The target device ID."; TargetOption = string.IsNullOrWhiteSpace(entryPoint.DefaultExecutionTarget) ? new OptionInfo <string?>(targetAliases, targetDescription) : new OptionInfo <string?>(targetAliases, entryPoint.DefaultExecutionTarget, targetDescription); }
/// <summary> /// Submits the entry point to Azure Quantum. /// </summary> /// <param name="entryPoint">The entry point.</param> /// <param name="parseResult">The command-line parsing result.</param> /// <param name="settings">The submission settings.</param> /// <typeparam name="TIn">The entry point's argument type.</typeparam> /// <typeparam name="TOut">The entry point's return type.</typeparam> /// <returns>The exit code.</returns> internal static async Task <int> Submit <TIn, TOut>( IEntryPoint <TIn, TOut> entryPoint, ParseResult parseResult, AzureSettings settings) { if (settings.Verbose) { Console.WriteLine(settings); Console.WriteLine(); } var machine = CreateMachine(settings); if (machine is null) { DisplayWithColor(ConsoleColor.Red, Console.Error, $"The target '{settings.Target}' was not recognized."); return(1); } var input = entryPoint.CreateArgument(parseResult); return(settings.DryRun ? Validate(machine, entryPoint, input) : await SubmitJob(machine, entryPoint, input, settings)); }
public PersonsController(IEntryPoint entry) { _entry = entry; }
public static void DefineEntryPoint(IEntryPoint e) { e["java/WEB-INF/web.xml"] = typeof(TidyDocsServlet).Assembly.ToServletConfiguration(); }
public PackageModule(IPublishStorableCommands publisher, IRepository<Domain.Entities.Packages.Read.Package> readRepo, INEventStoreRepository<Package> writeRepo, IRepository<State> stateRepo, IEntryPoint entryPoint, IAdvancedBus eBus, IUserManagementApiClient userManagementApi, IBillingApiClient billingApiClient, IPublishIntegrationMessages integration) { Get[PackageBuilderApi.PackageRoutes.RequestIndex.ApiRoute] = _ => { return _.showAll ? Response.AsJson( from p1 in readRepo where p1.Version == (from p2 in readRepo where p2.PackageId == p1.PackageId && !p2.IsDeleted select p2.Version).Max() select p1) : Response.AsJson(readRepo.Where(x => !x.IsDeleted)); }; Get[PackageBuilderApi.PackageRoutes.RequestLookup.ApiRoute] = parameters => { var filter = ((string)Context.Request.Query["q_word[]"].Value + "").Replace(",", " "); var pageIndex = 0; var pageSize = 0; int.TryParse(Context.Request.Query["page_num"].Value, out pageIndex); int.TryParse(Context.Request.Query["per_page"].Value, out pageSize); var industries = ((string)parameters.industryIds.Value + "").Split(',').Select(x => !string.IsNullOrEmpty(x) ? new Guid(x) : new Guid()); var publishedPackages = from p1 in readRepo where p1.Version == (from p2 in readRepo where p2.PackageId == p1.PackageId select p2.Version).Max() && p1.State.Name == StateName.Published && p1.Industries.Any(ind => industries.Contains(ind.Id)) && (p1.Name + "").Trim().ToLower().StartsWith(filter) select p1; var packages = new PagedList<Domain.Entities.Packages.Read.Package>(publishedPackages, pageIndex - 1, pageSize, x => !x.IsDeleted); return Response.AsJson( new { result = packages, cnt_whole = packages.RecordsFiltered }); }; Get[PackageBuilderApi.PackageRoutes.RequestUpdate.ApiRoute] = parameters => Response.AsJson( new { Response = new[] { Mapper.Map<IPackage, PackageDto>(writeRepo.GetById(parameters.id)) } }); Post[PackageBuilderApi.PackageRoutes.Execute.ApiRoute] = parameters => { var apiRequest = this.Bind<ApiRequestDto>(); this.Info(() => StringExtensions.FormatWith("Package Execute Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); this.Info(() => StringExtensions.FormatWith("Package Read Initialized, TimeStamp: {0}", DateTime.UtcNow)); var package = writeRepo.GetById(apiRequest.PackageId, true); this.Info(() => StringExtensions.FormatWith("Package Read Completed, TimeStamp: {0}", DateTime.UtcNow)); if (package == null) { this.Error(() => StringExtensions.FormatWith("Package not found:", apiRequest.PackageId)); throw new LightstoneAutoException("Package could not be found"); } this.Info(() => StringExtensions.FormatWith("PackageBuilder Auth to UserManagement Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var token = Context.Request.Headers.Authorization.Split(' ')[1]; var accountNumber = userManagementApi.Get(token, "/CustomerClient/{id}", new[] { new KeyValuePair<string, string>("id", apiRequest.CustomerClientId.ToString()) }, null); this.Info(() => StringExtensions.FormatWith("PackageBuilder Auth to UserManagement Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var responses = ((Package)package).Execute(entryPoint, apiRequest.UserId, Context.CurrentUser.UserName, Context.CurrentUser.UserName, apiRequest.RequestId, accountNumber, apiRequest.ContractId, apiRequest.ContractVersion, apiRequest.DeviceType, apiRequest.FromIpAddress, "", apiRequest.SystemType, apiRequest.RequestFields, (double)package.CostOfSale, (double)package.RecommendedSalePrice, apiRequest.HasConsent); // Filter responses for cleaner api payload this.Info(() => StringExtensions.FormatWith("Package Response Filter Cleanup Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var filteredResponse = new List<IProvideResponseDataProvider> { new ResponseMeta(apiRequest.RequestId, responses.ResponseState()) }; filteredResponse.AddRange(Mapper.Map<IEnumerable<IDataProvider>, IEnumerable<IProvideResponseDataProvider>>(responses)); this.Info(() => StringExtensions.FormatWith("Package Response Filter Cleanup Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); integration.SendToBus(new PackageResponseMessage(package.Id, apiRequest.UserId, apiRequest.ContractId, accountNumber, filteredResponse.Any() ? filteredResponse.AsJsonString() : string.Empty, apiRequest.RequestId, Context != null ? Context.CurrentUser.UserName : "******")); this.Info(() => StringExtensions.FormatWith("Package Execute Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); return filteredResponse; }; Post[PackageBuilderApi.PackageRoutes.CommitRequest.ApiRoute] = _ => { var apiRequest = this.Bind<ApiCommitRequestDto>(); var token = Context.Request.Headers.Authorization.Split(' ')[1]; var request = billingApiClient.Get(token, "/Transactions/Request/{requestId}", new[] { new KeyValuePair<string, string>("requestId", apiRequest.RequestId.ToString()) } ,null); if (request.Contains("error")) return request; // RabbitMQ new TransactionBus(eBus).SendDynamic(Mapper.Map(apiRequest, new TransactionRequestMessage())); this.Info(() => StringExtensions.FormatWith("Updated TransactionRequest UserState: {0}", apiRequest.UserState)); if (apiRequest.UserState == ApiCommitRequestUserState.Cancelled) return Response.AsJson(new { Success = "Request successfully cancelled by user" }); if (apiRequest.UserState == ApiCommitRequestUserState.VehicleNotProvided) return Response.AsJson(new { Success = "Request successfully marked as VehicleNotProvided by user" }); this.Info(() => StringExtensions.FormatWith("Package ExecuteWithCarId Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); this.Info(() => StringExtensions.FormatWith("Package Read Initialized, TimeStamp: {0}", DateTime.UtcNow)); var package = writeRepo.GetById(apiRequest.PackageId, true); this.Info(() => StringExtensions.FormatWith("Package Read Completed, TimeStamp: {0}", DateTime.UtcNow)); if (package == null) { this.Error(() => StringExtensions.FormatWith("Package not found:", apiRequest.PackageId)); throw new LightstoneAutoException("Package could not be found"); } this.Info(() => StringExtensions.FormatWith("PackageBuilder Auth to UserManagement Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var accountNumber = userManagementApi.Get(token, "/CustomerClient/{id}", new[] { new KeyValuePair<string, string>("id", apiRequest.CustomerClientId.ToString()) }, null); this.Info(() => StringExtensions.FormatWith("PackageBuilder Auth to UserManagement Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var responses = ((Package)package).ExecuteWithCarId(entryPoint, apiRequest.UserId, Context.CurrentUser.UserName, Context.CurrentUser.UserName, apiRequest.RequestId, accountNumber, apiRequest.ContractId, apiRequest.ContractVersion, apiRequest.DeviceType, apiRequest.FromIpAddress, "", apiRequest.SystemType, apiRequest.RequestFields, (double)package.CostOfSale, (double)package.RecommendedSalePrice, apiRequest.HasConsent); // Filter responses for cleaner api payload this.Info(() => StringExtensions.FormatWith("Package Response Filter Cleanup Initialized for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); var filteredResponse = new List<IProvideResponseDataProvider> { new ResponseMeta(apiRequest.RequestId, responses.ResponseState()) }; filteredResponse.AddRange(Mapper.Map<IEnumerable<IDataProvider>, IEnumerable<IProvideResponseDataProvider>>(responses)); this.Info(() => StringExtensions.FormatWith("Package Response Filter Cleanup Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); integration.SendToBus(new PackageResponseMessage(package.Id, apiRequest.UserId, apiRequest.ContractId, accountNumber, filteredResponse.Any() ? filteredResponse.AsJsonString() : string.Empty, apiRequest.RequestId, Context != null ? Context.CurrentUser.UserName : "******")); this.Info(() => StringExtensions.FormatWith("Package ExecuteWithCarId Completed for {0}, TimeStamp: {1}", apiRequest.RequestId, DateTime.UtcNow)); return filteredResponse; }; Post[PackageBuilderApi.PackageRoutes.ProcessCreate.ApiRoute] = parameters => { var dto = this.Bind<PackageDto>(); dto.Id = dto.Id == new Guid() ? Guid.NewGuid() : dto.Id; // Required for acceptance tests where we specify the Id var dProviders = Mapper.Map<IEnumerable<DataProviderDto>, IEnumerable<DataProviderOverride>>(dto.DataProviders); publisher.Publish(new CreatePackage(dto.Id, dto.Name, dto.Description, dto.CostOfSale, dto.RecommendedSalePrice, dto.Notes, dto.PackageEventType, Mapper.Map<PackageDto, IEnumerable<Industry>>(dto), dto.State, dto.Owner, DateTime.UtcNow, null, dProviders)); ////RabbitMQ var metaEntity = Mapper.Map(dto, new PackageMessage()); var advancedBus = new TransactionBus(eBus); advancedBus.SendDynamic(metaEntity); return Response.AsJson(new { msg = "Success" }); }; Put[PackageBuilderApi.PackageRoutes.ProcessUpdate.ApiRoute] = parameters => { var dto = this.Bind<PackageDto>(); var dProviders = Mapper.Map<IEnumerable<DataProviderDto>, IEnumerable<DataProviderOverride>>(dto.DataProviders); publisher.Publish(new UpdatePackage(parameters.id, dto.Name, dto.Description, dto.CostOfSale, dto.RecommendedSalePrice, dto.Notes, dto.PackageEventType, Mapper.Map<PackageDto, IEnumerable<Industry>>(dto), dto.State, dto.Version, dto.Owner, dto.CreatedDate, DateTime.UtcNow, dProviders)); ////RabbitMQ var metaEntity = Mapper.Map(dto, new PackageMessage()); var advancedBus = new TransactionBus(eBus); advancedBus.SendDynamic(metaEntity); return Response.AsJson(new { msg = "Success, " + parameters.id + " edited" }); }; Put["/Packages/Clone/{id}/{cloneName}"] = parameters => { var packageToClone = Mapper.Map<IPackage, PackageDto>(writeRepo.GetById(parameters.id)); var dataProvidersToClone = Mapper.Map<IEnumerable<DataProviderDto>, IEnumerable<DataProviderOverride>>( packageToClone.DataProviders); var stateResolve = stateRepo.Where(x => x.Alias == "Draft") .Select(y => new State(y.Id, y.Name, y.Alias)); publisher.Publish(new CreatePackage(Guid.NewGuid(), parameters.cloneName, packageToClone.Description, packageToClone.CostOfSale, packageToClone.RecommendedSalePrice, packageToClone.Notes, packageToClone.PackageEventType, packageToClone.Industries, stateResolve.FirstOrDefault(), packageToClone.Owner, DateTime.UtcNow, null, dataProvidersToClone)); return Response.AsJson( new { msg = "Success, Package with ID: " + parameters.id + " has been cloned to package '" + parameters.cloneName + "'" }); }; Delete[PackageBuilderApi.PackageRoutes.ProcessDelete.ApiRoute] = parameters => { this.RequiresAnyClaim(new[] { RoleType.Admin.ToString(), RoleType.ProductManager.ToString(), RoleType.Support.ToString() }); publisher.Publish(new DeletePackage(new Guid(parameters.id))); return Response.AsJson(new { msg = "Success, " + parameters.id + " deleted" }); }; }
public DataStoreDesktopTask(IEntryPoint entryPoint, IDataStoreContextFactory <IDesktopContext> dataStoreContextFactory) { _entryPoint = entryPoint; _dataStoreContextFactory = dataStoreContextFactory; }
public when_sending_carid_and_year_only_to_entry_point() { _command = BusFactory.WorkflowBus(); _request = new CarIdRequestBuilder().ForAllCarIdSources(); _entryPoint = new EntryPointService(_command); }
/// <summary> /// Init, and runs the game /// </summary> /// <param name="entry"></param> /// <param name="noWindow"></param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="NullReferenceException"></exception> public static void Init(IEntryPoint entry, bool noWindow = false) { //Make sure the entry isn't null, or that there is no game name if (entry == null) { throw new ArgumentNullException(nameof(entry), "Entry cannot be null!"); } if (string.IsNullOrWhiteSpace(entry.GetGameName())) { throw new NullReferenceException("Game name cannot be null!"); } //Initiate the logger first Logger.Init(); Profiler.BeginSession("Startup", "VoltstroEngineProfile-Startup.json"); Application app = null; ProfilerTimer.Profile(() => { //Setup render RenderingAPI.Create(); //Set game name, since we load all our game related files from that path //So if the game requests for a texture, we load it from the game's bin parent directory, allowing for multiple games, but all using the same copy of the engine //E.G: // - Engine Stuff (Launcher/VoltstroEngine.dll) // - | // - Sandbox // - - Textures/ GameName = entry.GetGameName(); if (!noWindow) { //Init our forms system EtoFormsSystem.Init(); //Create the app Logger.Info("Creating {@GameName}'s application...", GameName); app = entry.CreateApplication(); if (app == null) { throw new NullReferenceException("The app cannot be null!"); } //Init the render Renderer.Init(); } else { //Init the render Renderer.Init(); } }); Profiler.EndSession(); //Run the main loop if (!noWindow) { Profiler.BeginSession("Runtime", "VoltstroEngineProfile-Runtime.json"); { ProfilerTimer.Profile("Game Loop", () => { app.Run(); }); } Profiler.EndSession(); } //Shutdown stuff Profiler.BeginSession("Shutdown", "VoltstroEngineProfile-Shutdown.json"); { ProfilerTimer.Profile("Shutdown", () => { Application.Shutdown(); Renderer.Shutdown(); EtoFormsSystem.Shutdown(); }); Logger.Shutdown(); } Profiler.EndSession(); }
public static void DefineEntryPoint(IEntryPoint e) { CreatePHPIndexPage(e, php.OrcasPHPScriptApplicationBackend.Filename, php.OrcasPHPScriptApplicationBackend.Entrypoint); }
public OutputHelper(IEntryPoint entryPoint) { _entryPoint = entryPoint; _app = entryPoint.App; }
public when_sending_vin12_license_plate_to_entry_point_service() { _command = BusFactory.WorkflowBus(); _request = new LicensePlateRequestBuilder().ForLightstoneVin12LicensePlate(); _entryPoint = new EntryPointService(_command); }
public when_lace_entry_point_get_response() { _entryPoint = new FakeEntryPoint(); _request = new[] {new LicensePlateNumberAllDataProvidersRequest()}; }
public when_sending_consumer_specifications_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new ConsumerRequestBuilder().ForSpecifications(); _entryPoint = new EntryPointService(_bus); }
public static void DefineEntryPoint(IEntryPoint e) { CreatePHPIndexPage(e, Application.Filename, Application.Application_Entrypoint); }
public List<IDataProvider> ExecuteWithCarId(IEntryPoint entryPoint, Guid userId, string userName, string firstName, Guid requestId, string accountNumber, Guid contractId, long contractVersion, DeviceTypes fromDevice, string fromIpAddress, string osVersion, SystemType system, IEnumerable<RequestFieldDto> requestFieldsDtos, double packageCostPrice, double packageRecommendedPrice, bool hasConsent) { this.Info(() => "Form LACE Request Initialized for {0}, TimeStamp: {1}".FormatWith(requestId, DateTime.UtcNow)); var request = FormLaceRequest(userId, userName, firstName, requestId, accountNumber, contractId, contractVersion, fromDevice, fromIpAddress, osVersion, system, requestFieldsDtos, packageCostPrice, packageRecommendedPrice, hasConsent); this.Info(() => "Form LACE Request Completed for {0}, TimeStamp: {1}".FormatWith(requestId, DateTime.UtcNow)); if (request == null) throw new LightstoneAutoException(string.Format("Request cannot be built to Contract with Id {0}", contractId)); this.Info(() => "EntryPoint Get LACE Response Initialized for {0}, TimeStamp: {1}".FormatWith(requestId, DateTime.UtcNow)); var responses = entryPoint.GetResponsesForCarId(new[] {request}); this.Info(() => "EntryPoint Get LACE Response Completed for {0}, TimeStamp: {1}".FormatWith(requestId, DateTime.UtcNow)); return MapLaceResponses(responses, requestId).ToList(); }
public WrappedService(IEntryPoint app) { this.application = app; }
private DataStoreDesktopTask NewTask(IEntryPoint entryPoint = null, IDataStoreContextFactory <IDesktopContext> dataStoreContextFactory = null) { return(new DataStoreDesktopTask( entryPoint ?? Mock.Of <IEntryPoint>(), dataStoreContextFactory ?? Mock.Of <IDataStoreContextFactory <IDesktopContext> >())); }
public static void Main(string[] args) { //Do our command line parsing first CommandLine.ParseArguments(args); //Create our Eto.Forms app, so we can show message boxes //We shut this down before we run the engine Platform.AllowReinitialize = true; Application app = new Application(); //Now to get the game's entry point IEntryPoint entryPoint = null; string dllPath = Path.GetFullPath($"{CommandLine.GameName}/bin/{CommandLine.GameName}.dll"); try { //Load the game assembly AssemblyLoad assemblyLoad = new AssemblyLoad(); Assembly gameDll = assemblyLoad.LoadAssembly(Path.GetFullPath($"{CommandLine.GameName}/bin"), $"{CommandLine.GameName}.dll"); //Find a class the inherits from IEntryPoint so that we can create the game foreach (Type type in gameDll.GetTypes().Where(x => x.IsPublic && x.IsClass)) //Needs to be public { if (!typeof(IEntryPoint).IsAssignableFrom(type)) { continue; } if (!(Activator.CreateInstance(type) is IEntryPoint point)) { continue; } entryPoint = point; break; } } catch (FileNotFoundException ex) //The DLL wasn't found { Debug.Assert(false, $"The game DLL for '{CommandLine.GameName}' wasn't found in '{dllPath}'!\n{ex}"); #if !DEBUG Eto.Forms.MessageBox.Show($"The game DLL for '{CommandLine.GameName}' wasn't found in '{dllPath}'!", "Engine Error", Eto.Forms.MessageBoxButtons.OK, Eto.Forms.MessageBoxType.Error); app.Dispose(); Environment.Exit(0); #endif } catch (Exception ex) //Some other error { Debug.Assert(false, $"An unknown error occured while preparing the game for launching!\n{ex}"); #if !DEBUG Eto.Forms.MessageBox.Show($"An unknown error occured while preparing the game for launching!", "Engine Error", Eto.Forms.MessageBoxButtons.OK, Eto.Forms.MessageBoxType.Error); app.Dispose(); Environment.Exit(0); #endif } //The entry point wasn't found Debug.Assert(entryPoint != null, "The game DLL doesn't contain an entry point!"); #if !DEBUG if (entryPoint == null) { Eto.Forms.MessageBox.Show("The game DLL didn't contain an entry point!", "Engine Error", Eto.Forms.MessageBoxButtons.OK, Eto.Forms.MessageBoxType.Error); app.Dispose(); Environment.Exit(0); return; } #endif //Dispose of the Eto.Forms app app.Quit(); app.Dispose(); //Tell the engine to init, and use the game entry point. //This is were we actually start to render and run the game. try { Engine.Init(entryPoint); } catch (Exception ex) { if (Logger.IsLoggerInitialized) { Logger.Error("An error occured: {@Exception}", ex); } //If the logger isn't initialized, then the only option we got to log the error is to dump it into console, as we disposed of Eto.Forms Application earlier //and can't create message boxes with out it else { Console.WriteLine(ex.ToString()); } } }
public when_sending_request_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new LicensePlateRequestBuilder().ForAllSources(); _entryPoint = new EntryPointService(_bus); }
public when_sending_pcubed_ezscore_request_to_lace_entry_point() { _bus = BusFactory.WorkflowBus(); _request = new PCubedRequestBuilder().ForEzScore(); _entryPoint = new EntryPointService(_bus); }