public void AddsAPluginByNameWithVersion() { var program = new Program(new FakeApplicationEnvironment()); program.ParseArguments(new string[] { "--plugin-name", "[email protected]", "--plugin-name", "PluginB" }); Assert.True(program.PluginNames.Any(z => z.Key == "PluginA" && z.Value == "1.0.0")); }
///<summary>Inserts one Program into the database. Provides option to use the existing priKey.</summary> internal static long Insert(Program program,bool useExistingPK) { if(!useExistingPK && PrefC.RandomKeys) { program.ProgramNum=ReplicationServers.GetKey("program","ProgramNum"); } string command="INSERT INTO program ("; if(useExistingPK || PrefC.RandomKeys) { command+="ProgramNum,"; } command+="ProgName,ProgDesc,Enabled,Path,CommandLine,Note,PluginDllName) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(program.ProgramNum)+","; } command+= "'"+POut.String(program.ProgName)+"'," +"'"+POut.String(program.ProgDesc)+"'," + POut.Bool (program.Enabled)+"," +"'"+POut.String(program.Path)+"'," +"'"+POut.String(program.CommandLine)+"'," +"'"+POut.String(program.Note)+"'," +"'"+POut.String(program.PluginDllName)+"')"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { program.ProgramNum=Db.NonQ(command,true); } return program.ProgramNum; }
public void AddsPlugins() { var program = new Program(new FakeApplicationEnvironment()); program.ParseArguments(new string[] { "--plugins", "/a/b/c/d" }); Assert.Contains("/a/b/c/d", program.PluginPaths); }
public void GivenAnItemWithTheNameAQualityAndASellInOf(string name, int quality, int sellIn) { _program = new Program() { Items = new List<Item> { new Item { Name = name, SellIn = sellIn, Quality = quality } } }; }
///<summary>Inserts one Program into the database. Returns the new priKey.</summary> internal static long Insert(Program program) { if(DataConnection.DBtype==DatabaseType.Oracle) { program.ProgramNum=DbHelper.GetNextOracleKey("program","ProgramNum"); int loopcount=0; while(loopcount<100){ try { return Insert(program,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ program.ProgramNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(program,false); } }
public void GivenAnItemWithQualityOf(int quality) { _program = new Program() { Items = new List<Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 10, Quality = quality } } }; }
public void GivenAnItemWithASellInOf(int sellin) { _program = new Program() { Items = new List<Item> { new Item { Name = "+5 Dexterity Vest", SellIn = sellin, Quality = 5 } } }; }
public void Auto_Syncada_Inv_Mktg_Request() { Program prog = new Program(); int result = prog.Addition(10, 10); int actual = 20; Assert.AreEqual<int>(result, actual); }
/// <summary> /// Initialise the editor. /// </summary> /// <param name="terrainEditorProgram">The terrain editor effect to clone. In the default content, this is stored as "Terracotta/TerrainEditorEffect".</param> /// <param name="terrain">The terrain to edit.</param> public TerrainEditor(PlanarTerrainBlock block) { this.terrainBlock = block; var builder = ShaderBuilder.CreateFromAssemblyResource("Glare.Graphics.Shaders.TerrainEditor.glsl"); Program = new Program( builder.VertexShader("Common", "Vertex"), builder.FragmentShader("Common", "Fragment")); Program.Uniforms["TerrainSize"].Set(Terrain.BlockSize); Program.Uniforms["InverseTerrainSize"].Set(1.0 / Terrain.BlockSize); Rng = new Random(); byte[] permutations = new byte[PerlinSize]; for (int i = 0; i < permutations.Length; i++) permutations[i] = (byte)i; for (int i = 0; i < permutations.Length; i++) Extensions.Swap(ref permutations[i], ref permutations[Rng.Next(permutations.Length)]); CreatePerlinPermutationTexture(permutations); CreatePerlinGradientTexture(permutations); CreateTemporaryTexture(); //LoadRandomPerlinTransform(); PerlinTransform = Matrix4d.Identity; }
void OnApplicationStartup(object sender, StartupEventArgs e) { DispatcherUnhandledException += App_DispatcherUnhandledException; Program program = null; if (e.Args.Length >= 1) { try { program = Program.Load(e.Args[0]); } catch (Exception ex) { CommonExceptionHandlers.HandleException(null, ex); } } if (program == null) { program = new Program(); } AppState.Program = program; var bootstrapper = new Bootstrapper(); bootstrapper.Run(); }
public ProjectFile_v2 VisitProgram(Program program) { var dtSerializer = new DataTypeSerializer(); return new DecompilerInput_v2 { Address = program.Image != null ? program.Image.BaseAddress.ToString() : null, Filename = program.Filename, UserProcedures = program.UserProcedures .Select(de => { de.Value.Address = de.Key.ToString(); return de.Value; }) .ToList(), UserCalls = program.UserCalls .Select(uc => uc.Value) .ToList(), UserGlobalData = program.UserGlobalData .Select(de => new GlobalDataItem_v2 { Address = de.Key.ToString(), DataType = de.Value.DataType, Name = string.Format("g_{0:X}", de.Key.ToLinear()) }) .ToList(), DisassemblyFilename = program.DisassemblyFilename, IntermediateFilename = program.IntermediateFilename, OutputFilename = program.OutputFilename, TypesFilename = program.TypesFilename, GlobalsFilename = program.GlobalsFilename, OnLoadedScript = program.OnLoadedScript, Options = new ProgramOptions_v2 { HeuristicScanning = program.Options.HeuristicScanning, } }; }
protected override void SolveInstance(IGH_DataAccess DA) { string name = null; GH_RobotSystem robotSystem = null; var initCommandsGH = new List<GH_Command>(); var targetsA = new List<GH_Target>(); var targetsB = new List<GH_Target>(); var multiFileIndices = new List<int>(); double stepSize = 1; if (!DA.GetData(0, ref name)) { return; } if (!DA.GetData(1, ref robotSystem)) { return; } if (!DA.GetDataList(2, targetsA)) { return; } DA.GetDataList(3, targetsB); DA.GetDataList(4, initCommandsGH); DA.GetDataList(5, multiFileIndices); if (!DA.GetData(6, ref stepSize)) { return; } var initCommands = initCommandsGH.Count > 0 ? new Robots.Commands.Group(initCommandsGH.Select(x => x.Value)) : null; var targets = new List<IEnumerable<Target>>(); targets.Add(targetsA.Select(x => x.Value)); if (targetsB.Count > 0) targets.Add(targetsB.Select(x => x.Value)); var program = new Program(name, robotSystem.Value, targets, initCommands, multiFileIndices, stepSize); DA.SetData(0, new GH_Program(program)); if (program.Code != null) { var path = DA.ParameterTargetPath(2); var structure = new GH_Structure<GH_String>(); for (int i = 0; i < program.Code.Count; i++) { var tempPath = path.AppendElement(i); for (int j = 0; j < program.Code[i].Count; j++) { structure.AppendRange(program.Code[i][j].Select(x => new GH_String(x)), tempPath.AppendElement(j)); } } DA.SetDataTree(1, structure); } DA.SetData(2, program.Duration); if (program.Warnings.Count > 0) { DA.SetDataList(3, program.Warnings); this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Warnings in program"); } if (program.Errors.Count > 0) { DA.SetDataList(4, program.Errors); this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Errors in program"); } }
public void Cleanup() { DataBoss = null; Context.Dispose(); Context = null; Connection.Dispose(); Connection = null; }
public ConcurrentHoudini(int taskId, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.txt") { Contract.Assert(taskId >= 0); this.program = program; this.cexTraceFile = cexTraceFile; this.taskID = taskId; Initialize(program, stats); }
public static void Main(string[] args) { Gnome.Program program = new Program("collection-properties", "0.10.0", Modules.UI, args); Store store = Store.GetStore(); if(args.Length < 1) { Console.WriteLine("Usage: ColPropViewer [collectionID]"); Console.WriteLine(" where collectionID is:"); foreach(ShallowNode sn in store) { Collection col = store.GetCollectionByID(sn.ID); Console.WriteLine("{0} : {1}", col.Name, col.ID); } } else { Collection col = store.GetCollectionByID(args[0]); if(col != null) { CollectionProperties cp = new CollectionProperties(); cp.Collection = col; cp.Closed += new EventHandler(on_cp_closed); cp.Show(); program.Run(); } } }
public ProjectFile_v3 VisitProgram(Program program) { var dtSerializer = new DataTypeSerializer(); return new DecompilerInput_v3 { Filename = program.Filename, User = new UserData_v3 { Procedures = program.User.Procedures .Select(de => { de.Value.Address = de.Key.ToString(); return de.Value; }) .ToList(), Processor = SerializeProcessorOptions(program.User, program.Architecture), PlatformOptions = SerializePlatformOptions(program.User, program.Platform), LoadAddress = program.User.LoadAddress != null ? program.User.LoadAddress.ToString() : null, Calls = program.User.Calls .Select(uc => uc.Value) .ToList(), GlobalData = program.User.Globals .Select(de => new GlobalDataItem_v2 { Address = de.Key.ToString(), DataType = de.Value.DataType, Name = string.Format("g_{0:X}", de.Key.ToLinear()) }) .ToList(), OnLoadedScript = program.User.OnLoadedScript, Heuristics = program.User.Heuristics.Select(h => new Heuristic_v3 { Name = h }).ToList(), }, DisassemblyFilename = program.DisassemblyFilename, IntermediateFilename = program.IntermediateFilename, OutputFilename = program.OutputFilename, TypesFilename = program.TypesFilename, GlobalsFilename = program.GlobalsFilename, }; }
public void SubtractionTest() { Program prog = new Program(); int result = prog.Subtraction(100, 10); int actual = 90; Assert.AreEqual<int>(result, actual); }
public static void GetAppFromDirectory(string path, List<Program> list) { try { foreach (string file in Directory.GetFiles(path)) { if (UserSetting.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o))) { Program p = new Program(file); list.Add(p); } } foreach (var subDirectory in Directory.GetDirectories(path)) { GetAppFromDirectory(subDirectory, list); } } catch (UnauthorizedAccessException e) { Console.WriteLine(string.Format("Can't access to directory {0}", path)); } catch (DirectoryNotFoundException e) { Console.WriteLine(string.Format("Directory {0} doesn't exist", path)); } catch (PathTooLongException e) { Console.WriteLine(string.Format("File path too long: {0}", e.Message)); } }
public static void SaveBinaries(Program program, string fileName) { ErrorCode errorCode; var numDevices = Cl.GetProgramInfo(program, ProgramInfo.NumDevices, out errorCode).CastTo<int>(); errorCode.Check("GetProgramInfo(ProgramInfo.NumDevices)"); var devices = Cl.GetProgramInfo(program, ProgramInfo.Devices, out errorCode).CastToArray<Device>(numDevices); errorCode.Check("GetProgramInfo(ProgramInfo.Devices)"); var binarySizes = Cl.GetProgramInfo(program, ProgramInfo.BinarySizes, out errorCode).CastToArray<int>(numDevices); errorCode.Check("GetProgramInfo(ProgramInfo.BinarySizes)"); var bufferArray = new InfoBufferArray(binarySizes.Select(bs => new InfoBuffer((IntPtr) bs)).ToArray()); IntPtr _; errorCode = Cl.GetProgramInfo(program, ProgramInfo.Binaries, bufferArray.Size, bufferArray, out _); errorCode.Check("GetProgramInfo(ProgramInfo.Binaries)"); var baseFileName = Path.GetFileNameWithoutExtension(fileName); var extension = Path.GetExtension(fileName); foreach (var index in Enumerable.Range(0, numDevices)) { var deviceName = Cl.GetDeviceInfo(devices[index], DeviceInfo.Name, out errorCode).ToString(); errorCode.Check("GetDeviceInfo(DeviceInfo.Name)"); var binary = bufferArray[index].CastToArray<byte>(binarySizes[index]); string deviceSpecificFileName = $"{baseFileName}_device{index}_{deviceName}{extension}"; File.WriteAllBytes(deviceSpecificFileName, binary); Console.WriteLine($"Wrote {binary.Length} bytes to {deviceSpecificFileName}"); } }
private void Application_Startup(object sender, StartupEventArgs e) { DispatcherUnhandledException += App_DispatcherUnhandledException; Program program = null; if (e.Args.Length >= 1) { try { program = Program.Load(e.Args[0]); } catch (Exception ex) { CommonExceptionHandlers.HandleException(null, ex); } } if (program == null) { program = new Program(); } AppState.Program = program; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); }
public MainWindowViewModel() { Pokemons = new ReadOnlyObservableCollection<SniperInfoModel>(GlobalVariables.PokemonsInternal); SettingsComand = new ActionCommand(ShowSettings); StartStopCommand = new ActionCommand(Startstop); DebugComand = new ActionCommand(ShowDebug); Settings.Default.DebugOutput = "Debug stuff in here!"; //var poke = new SniperInfo { // Id = PokemonId.Missingno, // Latitude = 45.99999, // Longitude = 66.6677, // ExpirationTimestamp = DateTime.Now //}; //var y = new SniperInfoModel { // Info = poke, // Icon = new BitmapImage(new Uri(Path.Combine(iconPath, $"{(int) poke.Id}.png"))) //}; //GlobalVariables.PokemonsInternal.Add(y); GlobalSettings.Output = new Output(); Program p = new Program(); Thread a = new Thread(p.Start) { IsBackground = true}; //Start(); p a.Start(); }
public static void Send(Program.AppMessage msg, int lParam, bool bWaitWithTimeout) { if(!KeePassLib.Native.NativeLib.IsUnix()) // Windows { if(bWaitWithTimeout) { IntPtr pResult = new IntPtr(0); NativeMethods.SendMessageTimeout((IntPtr)NativeMethods.HWND_BROADCAST, Program.ApplicationMessage, (IntPtr)msg, (IntPtr)lParam, NativeMethods.SMTO_ABORTIFHUNG, 5000, ref pResult); } else NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, Program.ApplicationMessage, (IntPtr)msg, (IntPtr)lParam); } else // Unix { if(m_chClient == null) { m_chClient = new IpcClientChannel(); ChannelServices.RegisterChannel(m_chClient, false); } try { IpcBroadcastSingleton ipc = (Activator.GetObject(typeof( IpcBroadcastSingleton), "ipc://" + GetPortName() + "/" + IpcObjectName) as IpcBroadcastSingleton); if(ipc != null) ipc.Call((int)msg, lParam); } catch(Exception) { } // Server might not exist } }
public override void Do(Program instance, IEnumerable<string> input) { if (input.Count() == 0) { foreach (var item in instance.Commands) { Console.WriteLine(item.Key); foreach (var l in item.Value.Description) Console.WriteLine("\t" + l); } } else { string cmd = input.First(); Command c = instance.GetCommand(cmd); if (c == null) Console.WriteLine("Unknown command \"" + cmd + "\""); else { Console.WriteLine(c.Keyword); foreach (var l in c.DetailedHelp) Console.WriteLine("\t" + l); } } }
public ConcurrentHoudini(int id, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.bpl") { Contract.Assert(id >= 0); this.id = id; this.program = program; this.cexTraceFile = cexTraceFile; if (CommandLineOptions.Clo.Trace) Console.WriteLine("Collecting existential constants..."); this.houdiniConstants = CollectExistentialConstants(); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Building call graph..."); this.callGraph = Program.BuildCallGraph(program); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Number of implementations = {0}", callGraph.Nodes.Count); if (CommandLineOptions.Clo.HoudiniUseCrossDependencies) { if (CommandLineOptions.Clo.Trace) Console.WriteLine("Computing procedure cross dependencies ..."); this.crossDependencies = new CrossDependencies(this.houdiniConstants); this.crossDependencies.Visit(program); } Inline(); this.vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List<Checker>()); this.proverInterface = ProverInterface.CreateProver(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, CommandLineOptions.Clo.ProverKillTime, id); vcgenFailures = new HashSet<Implementation>(); Dictionary<Implementation, HoudiniSession> houdiniSessions = new Dictionary<Implementation, HoudiniSession>(); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Beginning VC generation for Houdini..."); foreach (Implementation impl in callGraph.Nodes) { try { if (CommandLineOptions.Clo.Trace) Console.WriteLine("Generating VC for {0}", impl.Name); HoudiniSession session = new HoudiniSession(this, vcgen, proverInterface, program, impl, stats, taskID: id); houdiniSessions.Add(impl, session); } catch (VCGenException) { if (CommandLineOptions.Clo.Trace) Console.WriteLine("VC generation failed"); vcgenFailures.Add(impl); } } this.houdiniSessions = new ReadOnlyDictionary<Implementation, HoudiniSession>(houdiniSessions); if (CommandLineOptions.Clo.ExplainHoudini) { // Print results of ExplainHoudini to a dotty file explainHoudiniDottyFile = new StreamWriter("explainHoudini.dot"); explainHoudiniDottyFile.WriteLine("digraph explainHoudini {"); foreach (var constant in houdiniConstants) explainHoudiniDottyFile.WriteLine("{0} [ label = \"{0}\" color=black ];", constant.Name); explainHoudiniDottyFile.WriteLine("TimeOut [label = \"TimeOut\" color=red ];"); } }
protected override bool RunCore(Program program, IList<string> arguments) { Console.WriteLine("The following commands are available:"); Console.WriteLine(); foreach (var command in program.Commands.OrderBy(c => c.Name)) Console.WriteLine($"{command.Name} {command.Help}"); return true; }
public static void Main(string[] args) { Gnome.Program program = new Program("slogger", "0.10.0", Modules.UI, args); GtkSlogger slogger = new GtkSlogger(); slogger.ShowAll(); program.Run(); }
public void ParseFile(Program.Program program, string filename) { var ext = Path.GetExtension(filename).Substring(1); if (!m_internals.ContainsKey(ext)) throw new Exception("Unknown file type"); m_internals[ext].Parse(program, filename); }
public void TestIncrementMemoryValue() { var objBrainmessInterpreter = new Program { tapememory = new short[Constant.MemoryLength] }; objBrainmessInterpreter.IncrementMemoryValue(); Assert.AreEqual(1, objBrainmessInterpreter.tapememory[objBrainmessInterpreter.ptrMemory]); }
public static void Main(string[] args) { Gnome.Program program = new Program("contact-browser", "0.10.0", Modules.UI, args); ContactBrowser cb = new ContactBrowser(); cb.AddrBookClosed += new EventHandler(on_cb_closed); cb.ShowAll(); program.Run(); }
public static void Main(string[] args) { Gnome.Program program = new Program("pobox-viewer", "0.10.0", Modules.UI, args); POBoxViewer poBox = new POBoxViewer(); poBox.ViewerClosed += new EventHandler(on_po_closed); poBox.ShowAll(); program.Run(); }