public static void Main() { Print s = new Print(toConsole); Print v = new Print(toFile); display(s, "Hello World"); display(v, "Hello World"); }
private void AddToShoppingCart(object sender, RoutedEventArgs e) { if (PrintTypeComboBox.SelectedItem != null) { PrintBase item; switch (PrintTypeComboBox.SelectedIndex) { case 0: item = new Print(CurrentPhoto.Source as BitmapSource); break; case 1: item = new GreetingCard(CurrentPhoto.Source as BitmapSource); break; case 2: item = new SShirt(CurrentPhoto.Source as BitmapSource); break; default: return; } ShoppingCart.Add(item); ShoppingCartListBox.ScrollIntoView(item); ShoppingCartListBox.SelectedItem = item; if (false == CheckoutButton.IsEnabled) CheckoutButton.IsEnabled = true; if (false == RemoveButton.IsEnabled) RemoveButton.IsEnabled = true; } }
public void Print_DecodesOperand() { // Arrange var printer = new Print(); var stack = new Mock<IStack>(); stack.Setup(s => s.Pop()) .Returns(1234); var decoder = new Mock<IDecoder>(); decoder.Setup(d => d.Decode(It.IsAny<UInt64>())) .Returns(new Instruction { Operand = 12345 }); var context = new ExecutionContext { Stack = stack.Object, Decoder = decoder.Object }; // Act printer.Execute(context, null); // Verify decoder.Verify(d => d.Decode(1234), Times.Once); }
public void WriteLine() { StringWriter writer = new StringWriter(); Print print = new Print(writer); var result = print.Call(null, new object[] { "hello" }); Assert.IsNull(result); writer.Close(); Assert.AreEqual("hello\r\n", writer.ToString()); }
public void WriteEmptyLine() { StringWriter writer = new StringWriter(); Print print = new Print(writer); var result = print.Call(null, null); Assert.IsNull(result); writer.Close(); Assert.AreEqual("\r\n", writer.ToString()); }
public void RaiseIfTwoArguments() { StringWriter writer = new StringWriter(); Print print = new Print(writer); var result = print.Call(null, new object[] { "hello", "world" }); Assert.IsNull(result); writer.Close(); Assert.AreEqual("hello\r\nworld\r\n", writer.ToString()); }
public void EvaluatePrintCommand() { Context context = new Context(); StringWriter writer = new StringWriter(); Print print = new Print(writer); context.SetValue("print", print); EvaluateCommands("print('Hello, world');", context); writer.Close(); Assert.AreEqual("Hello, world\r\n", writer.ToString()); }
public static void Main(string[] args) { Table env = new Table(); Symbol k; object v; k = Lua.Symbol.Intern("print"); v = new Print(); env[k] = v; k = Lua.Symbol.Intern("setmetatable"); v = new SetMetatable(); env[k] = v; k = Lua.Symbol.Intern("pairs"); v = new Pairs(); env[k] = v; Lua.Symbol s = Lua.Symbol.Intern("tonumber"); k = s; v = new ToNumber(); env[k] = v; k = Lua.Symbol.Intern("os"); Table os = new Table(); v = os; env[k] = v; k = Lua.Symbol.Intern("clock"); v = new Clock(); os[k] = v; k = Lua.Symbol.Intern("io"); Table io = new Table(); v = io; env[k] = v; k = Lua.Symbol.Intern("write"); v = new Write(); io[k] = v; k = Lua.Symbol.Intern("math"); Table math = new Table(); v = math; env[k] = v; k = Lua.Symbol.Intern("floor"); v = new Floor(); math[k] = v; Closure c = (Closure)Assembly.LoadFrom(args[0] + ".dll"). GetType(args[0] + ".function1").GetConstructor(new Type[0]). Invoke(new object[0]); c.Env = env; c.InvokeS(); for(int i = 0; i <= System.GC.MaxGeneration; i++) Console.WriteLine(System.GC.CollectionCount(i)); }
public static void Main(string[] args) { Table env = new Table(); Symbol k; object v; k = Lua.Symbol.Intern("print"); v = new Print(); env[k] = v; k = Lua.Symbol.Intern("setmetatable"); v = new SetMetatable(); env[k] = v; k = Lua.Symbol.Intern("pairs"); v = new Pairs(); env[k] = v; Lua.Symbol s = Lua.Symbol.Intern("tonumber"); k = s; v = new ToNumber(); env[k] = v; k = Lua.Symbol.Intern("os"); Table os = new Table(); v = os; env[k] = v; k = Lua.Symbol.Intern("clock"); v = new Clock(); os[k] = v; k = Lua.Symbol.Intern("io"); Table io = new Table(); v = io; env[k] = v; k = Lua.Symbol.Intern("write"); v = new Write(); io[k] = v; k = Lua.Symbol.Intern("math"); Table math = new Table(); v = math; env[k] = v; k = Lua.Symbol.Intern("floor"); v = new Floor(); math[k] = v; function1 f = new function1(); f.Env = env; f.InvokeS(); for(int i = 0; i <= System.GC.MaxGeneration; i++) Console.WriteLine(System.GC.CollectionCount(i)); }
public Database() { patientList = new List<Patient>(); doctorList = new List<Doctor>(); hospitalList = new List<Hospital>(); recordList = new List<Record>(); patientService = new PatientService(patientList); hospitalService = new HospitalService(hospitalList); doctorService = new DoctorService(doctorList); diagnosisRecord = new DiagnosisRecord(recordList, patientList, doctorList, hospitalList); viewRecord = new ViewRecord(); print = message => Console.WriteLine(message); print = delegate(string message) { }; clear = () => Console.Clear(); }
public void ExecuteCallExpression() { StringWriter writer = new StringWriter(); Print print = new Print(writer); Context context = new Context(); IList<ICommand> commandlist = new List<ICommand>(); CallExpression callexpr = new CallExpression(new ConstantExpression(print), new IExpression[] { new ConstantExpression("Hello, World") }); object result = callexpr.Evaluate(context); Assert.IsNull(result); writer.Close(); Assert.AreEqual("Hello, World\r\n", writer.ToString()); }
static void Main(string[] args) { Print p = new Print(Console.WriteLine); long sumOfSquares = 0; long SquareOfSum = 0; long SquareOfSum2=0; long difference=0; long NaturalNumbersLimit=100; for(long num=1;num<=NaturalNumbersLimit;num++) { sumOfSquares += num * num; SquareOfSum += num; } p("The Sum Of the Squares of the First "+NaturalNumbersLimit+" Natuarl Numbers is:"); p(sumOfSquares.ToString()); p(""); Console.WriteLine(sumOfSquares); Console.WriteLine(); Console.WriteLine(SquareOfSum2); Console.WriteLine(); Console.WriteLine(difference); p("Square of the Sum Of the first "+NaturalNumbersLimit+" Natural nNumbers is"); SquareOfSum2 = SquareOfSum * SquareOfSum; p(SquareOfSum2.ToString()); p(""); difference=SquareOfSum2-sumOfSquares; p("The Difference between the sum of the squares of the first " + NaturalNumbersLimit + " Natural Numbers and Square of the sum is"); p(""); p(SquareOfSum2 + "-" + sumOfSquares + "=" + difference); p(""); p(difference.ToString()); p(""); }
public static void Test_CalculatePrintDateNumber_02(Print print, string directory, Date date) { int printNumber = print.GetPrintNumber(date); if (printNumber <= 0) printNumber = 1; Date date2 = date; if (print.Frequency != PrintFrequency.Daily) { //date2 = print.GetPrintDate(printNumber); DateType dateType; print.GetPrintDate(printNumber, out date2, out dateType); } int nb = 0; switch (print.Frequency) { case PrintFrequency.Daily: nb = 365 * 2; break; case PrintFrequency.Weekly: nb = 52 * 2; break; case PrintFrequency.EveryTwoWeek: nb = 26 * 2; break; case PrintFrequency.Monthly: nb = 12 * 2; break; case PrintFrequency.Bimonthly: nb = 6 * 2; break; case PrintFrequency.Quarterly: nb = 3 * 2; break; } Test_CalculatePrintNumber_01(print, directory, date2, nb); if (print.Frequency != PrintFrequency.Daily) Test_CalculatePrintDate_01(print, directory, printNumber, nb); }
public LogPair(Print m, string l) { Method = m; Log = l; }
public CustomPrintWidget(PrintOperation print_operation) : base(2, 4, false) { this.print_operation = print_operation; preview_image = new Gtk.Image(); Attach(preview_image, 0, 2, 0, 1); Frame page_frame = new Frame(Catalog.GetString("Page Setup")); VBox page_box = new VBox(); Label current_settings = new Label(); if (FSpot.Core.Global.PageSetup != null) { current_settings.Text = String.Format(Catalog.GetString("Paper Size: {0} x {1} mm"), Math.Round(print_operation.DefaultPageSetup.GetPaperWidth(Unit.Mm), 1), Math.Round(print_operation.DefaultPageSetup.GetPaperHeight(Unit.Mm), 1)); } else { current_settings.Text = String.Format(Catalog.GetString("Paper Size: {0} x {1} mm"), "...", "..."); } page_box.PackStart(current_settings, false, false, 0); Button page_setup_btn = new Button(Catalog.GetString("Set Page Size and Orientation")); page_setup_btn.Clicked += delegate { this.print_operation.DefaultPageSetup = Print.RunPageSetupDialog(null, print_operation.DefaultPageSetup, this.print_operation.PrintSettings); current_settings.Text = String.Format(Catalog.GetString("Paper Size: {0} x {1} mm"), Math.Round(print_operation.DefaultPageSetup.GetPaperWidth(Unit.Mm), 1), Math.Round(print_operation.DefaultPageSetup.GetPaperHeight(Unit.Mm), 1)); }; page_box.PackStart(page_setup_btn, false, false, 0); page_frame.Add(page_box); Attach(page_frame, 1, 2, 3, 4); Frame ppp_frame = new Frame(Catalog.GetString("Photos per page")); Table ppp_tbl = new Table(2, 7, false); ppp_tbl.Attach(ppp1 = new RadioButton("1"), 0, 1, 1, 2); ppp_tbl.Attach(ppp2 = new RadioButton(ppp1, "2"), 0, 1, 2, 3); ppp_tbl.Attach(ppp4 = new RadioButton(ppp1, "2 x 2"), 0, 1, 3, 4); ppp_tbl.Attach(ppp9 = new RadioButton(ppp1, "3 x 3"), 0, 1, 4, 5); ppp_tbl.Attach(ppp20 = new RadioButton(ppp1, "4 x 5"), 0, 1, 5, 6); ppp_tbl.Attach(ppp30 = new RadioButton(ppp1, "5 x 6"), 0, 1, 6, 7); ppp_tbl.Attach(repeat = new CheckButton(Catalog.GetString("Repeat")), 1, 2, 2, 3); ppp_tbl.Attach(crop_marks = new CheckButton(Catalog.GetString("Print cut marks")), 1, 2, 3, 4); // crop_marks.Toggled += TriggerChanged; ppp_frame.Child = ppp_tbl; Attach(ppp_frame, 0, 1, 1, 2); Frame layout_frame = new Frame(Catalog.GetString("Photos layout")); VBox layout_vbox = new VBox(); layout_vbox.PackStart(fullpage = new CheckButton(Catalog.GetString("Full Page (no margin)")), false, false, 0); HBox hb = new HBox(); // Note for translators: "Zoom" is a Fit Mode hb.PackStart(zoom = new RadioButton(Catalog.GetString("Zoom")), false, false, 0); hb.PackStart(fill = new RadioButton(zoom, Catalog.GetString("Fill")), false, false, 0); hb.PackStart(scaled = new RadioButton(zoom, Catalog.GetString("Scaled")), false, false, 0); zoom.Toggled += TriggerChanged; fill.Toggled += TriggerChanged; scaled.Toggled += TriggerChanged; layout_vbox.PackStart(hb, false, false, 0); layout_vbox.PackStart(white_border = new CheckButton(Catalog.GetString("White borders")), false, false, 0); white_border.Toggled += TriggerChanged; layout_frame.Child = layout_vbox; Attach(layout_frame, 1, 2, 1, 2); Frame cmt_frame = new Frame(Catalog.GetString("Custom Text")); cmt_frame.Child = custom_text = new Entry(); Attach(cmt_frame, 1, 2, 2, 3); Frame detail_frame = new Frame(Catalog.GetString("Photos infos")); VBox detail_vbox = new VBox(); detail_vbox.PackStart(print_filename = new CheckButton(Catalog.GetString("Print file name")), false, false, 0); detail_vbox.PackStart(print_date = new CheckButton(Catalog.GetString("Print photo date")), false, false, 0); detail_vbox.PackStart(print_time = new CheckButton(Catalog.GetString("Print photo time")), false, false, 0); detail_vbox.PackStart(print_tags = new CheckButton(Catalog.GetString("Print photo tags")), false, false, 0); detail_vbox.PackStart(print_comments = new CheckButton(Catalog.GetString("Print photo comment")), false, false, 0); detail_frame.Child = detail_vbox; Attach(detail_frame, 0, 1, 2, 4); TriggerChanged(this, null); }
static void TestDelegate( Print function, string s) { function(s); }
public void printByPathButton() { Print.PrintTextureByPath(inputField.text.Trim(), copies, printerName); //Print.PrintTextureByPath("D:/pic.jpg", copies, printerName); }
public override int Format(char[] to, int ofs, ref FormatComponents components) { return(Print.Dec2w2(to, ofs, components.month)); }
public void Visit(Print print) { print.Exp.Accept(this); Raise<TypeCheckException>.If(print.Exp.Type != _intType && print.Exp.Type != _boolType); }
public override int Format(char[] to, int ofs, ref FormatComponents components) { return(Print.sign(to, ofs, components.sign)); }
public override int Format(char[] to, int ofs, ref FormatComponents components) { return(Print.Dec4w4(to, ofs, components.year)); }
public override int Format(char[] to, int ofs, ref FormatComponents components) => Print.Str(to, ofs, chars);
private Stmt ParseStmt() { Stmt result = null; if (this.index == this.tokens.Count) { ParsingError("expected statement, got EOF"); } // <stmt> := print <expr> // <expr> := <string> // | <int> // | <arith_expr> // | <ident> if (this.tokens[this.index].Equals(languageSetting["End"])) { this.index++; } else if (this.tokens[this.index].Equals(languageSetting["Start"])) { this.index++; return(ParseStmt()); } else if (this.tokens[this.index].Equals(languageSetting["Print"])) { this.index++; Print print = new Print(); print.Expr = this.ParseExpr(); result = print; } else if (this.tokens[this.index] == Scanner.Call) { VoidMethodCall vmc = new VoidMethodCall(); vmc.Expr = this.ParseExpr(); result = vmc; } else if (this.tokens[this.index].Equals(languageSetting["VariableDeclaration"])) { this.index++; DeclareVar declareVar = new DeclareVar(); if (this.index < this.tokens.Count && this.tokens[this.index] is string) { declareVar.Ident = (string)this.tokens[this.index]; } else { ParsingError("expected variable name after 'var'"); } this.index++; if (this.index == this.tokens.Count || this.tokens[this.index] != Scanner.Equal) { ParsingError("expected = after 'var ident'"); } this.index++; declareVar.Expr = this.ParseExpr(); result = declareVar; } else if (this.tokens[this.index].Equals(languageSetting["if"])) { this.index++; IfCondition ifCon = new IfCondition(); ifCon.BooleanExp = this.ParseExpr(); if (!this.tokens[++this.index].Equals(languageSetting["Start"])) { ParsingError("Start Expected"); } ifCon.Body = this.ParseStmt(); if (!this.tokens[this.index++].Equals(languageSetting["End"])) { ParsingError("End Expected"); } result = ifCon; } else if (this.tokens[this.index].Equals(languageSetting["while"])) { this.index++; WhileLoop whileLoop = new WhileLoop(); whileLoop.BooleanExp = this.ParseExpr(); if (!this.tokens[++this.index].Equals(languageSetting["Start"])) { ParsingError("Start Expected"); } whileLoop.Body = this.ParseStmt(); if (!this.tokens[this.index++].Equals(languageSetting["End"])) { ParsingError("End Expected"); } result = whileLoop; } else if (this.tokens[this.index].Equals("read_int")) { this.index++; ReadInt readInt = new ReadInt(); if (this.index < this.tokens.Count && this.tokens[this.index] is string) { readInt.Ident = (string)this.tokens[this.index++]; result = readInt; } else { ParsingError("expected variable name after 'read_int'"); } } else if (this.tokens[this.index].Equals("for")) { this.index++; ForLoop forLoop = new ForLoop(); if (this.index < this.tokens.Count && this.tokens[this.index] is string) { forLoop.Ident = (string)this.tokens[this.index]; } else { ParsingError("expected identifier after 'for'"); } this.index++; if (this.index == this.tokens.Count || this.tokens[this.index] != Scanner.Equal) { ParsingError("for missing '='"); } this.index++; forLoop.From = this.ParseSingleExpression(); if (this.index == this.tokens.Count || !this.tokens[this.index].Equals("to")) { ParsingError("expected 'to' after for"); } this.index++; forLoop.To = this.ParseSingleExpression(); if (this.index == this.tokens.Count || !this.tokens[this.index].Equals("do")) { ParsingError("expected 'do' after from expression in for loop"); } this.index++; forLoop.Body = this.ParseStmt(); result = forLoop; if (this.index == this.tokens.Count || !this.tokens[this.index].Equals("end")) { ParsingError("unterminated 'for' loop body"); } this.index++; } else if (this.tokens[this.index] is string) { // assignment Assign assign = new Assign(); assign.Ident = (string)this.tokens[this.index++]; if (this.index == this.tokens.Count || this.tokens[this.index] != Scanner.Equal) { ParsingError("expected '='"); } this.index++; assign.Expr = this.ParseExpr(); result = assign; } else { ParsingError("parse error at token " + this.index + ": " + this.tokens[this.index]); } if (this.index < this.tokens.Count && this.tokens[this.index] == Scanner.Semi) { this.index++; if (this.index < this.tokens.Count && !this.tokens[this.index].Equals(languageSetting["End"])) { Sequence sequence = new Sequence(); sequence.First = result; sequence.Second = this.ParseStmt(); result = sequence; } } return(result); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); try { LogService = new Log(); PrintService = new Print(LogService); LogService.Write(""); PrintService.Log("App Start", Print.EMode.info); PrintService.NewLine(); FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() != DialogResult.OK) { return; } string basePath = dialog.SelectedPath; string workspacePath = $"{basePath}\\src"; PrintService.Write("Project Folder: ", Print.EMode.info); PrintService.WriteLine(basePath, Print.EMode.message); if (!Directory.Exists(workspacePath)) { throw new Exception($"src folder not found"); } if (!File.Exists($"{workspacePath}\\package.json")) { throw new Exception($"package.json not found"); } JObject packageJson = JsonConvert.DeserializeObject <JObject>(File.ReadAllText($"{workspacePath}\\package.json")); string projectName = packageJson["name"].ToString(); string projectVersion = packageJson["version"].ToString(); string projectDescription = packageJson["description"].ToString(); PrintService.Write("Project Name: ", Print.EMode.info); PrintService.WriteLine(projectName, Print.EMode.message); PrintService.Write("Project Version: ", Print.EMode.info); PrintService.WriteLine(projectVersion, Print.EMode.message); PrintService.NewLine(); PrintService.Write("Please Input New Verson: ", Print.EMode.question); string projectNewVersion = Console.ReadLine(); PrintService.NewLine(); List <string> paths = new List <string>() { $"{workspacePath}\\package.json", $"{workspacePath}\\package-lock.json" }; for (int i = 0; i < paths.Count; i++) { if (File.Exists(paths[i])) { string path = Path.GetFileName(paths[i]); JObject input = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(paths[i])); if (input["name"] != null) { input["name"] = projectName; } if (input["version"] != null) { input["version"] = projectNewVersion; } File.WriteAllText(paths[i], JsonConvert.SerializeObject(input, Formatting.Indented) + "\n"); PrintService.WriteLine($"Update \"{path}\" Success", Print.EMode.success); } } PrintService.NewLine(); using (Process process = new Process()) { process.StartInfo.FileName = "cmd.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.Start(); string root = Directory.GetDirectoryRoot(basePath); process.StandardInput.WriteLine(root.Replace("\\", "")); Thread.Sleep(10); process.StandardInput.WriteLine($"cd {workspacePath}"); Thread.Sleep(10); process.StandardInput.WriteLine("git add package.json"); Thread.Sleep(10); process.StandardInput.WriteLine("git add package-lock.json"); Thread.Sleep(10); process.StandardInput.WriteLine($"git commit -m \"v{projectNewVersion}\""); Thread.Sleep(10); PrintService.WriteLine($"Git Commit Success", Print.EMode.success); Thread.Sleep(10); if (File.Exists($"{workspacePath}\\public\\change.log")) { File.Delete($"{workspacePath}\\public\\change.log"); } string count = "5000"; process.StandardInput.WriteLine($"git log --date=format:\"%Y/%m/%d %H:%M:%S\" --pretty=format:\"%cd -> author: %<(10,trunc)%an, message: %s\" > \".\\public\\change.log\" -{count}"); while (!File.Exists($"{workspacePath}\\public\\change.log")) { Thread.Sleep(10); } process.StandardInput.WriteLine($"git add public\\change.log"); process.StandardInput.WriteLine($"git commit --amend --no-edit"); Thread.Sleep(10); process.StandardInput.WriteLine($"exit"); process.WaitForExit(); PrintService.WriteLine($"Git Log Export Success", Print.EMode.success); } PrintService.NewLine(); } catch (Exception ex) { ex = ExceptionHelper.GetReal(ex); PrintService.Log($"App Error, {ex.Message}", Print.EMode.error); } finally { PrintService.Log("App End", Print.EMode.info); Console.ReadKey(); Environment.Exit(0); } }
private Houdini.HoudiniOutcome ScheduleEnginesInParallel(Pipeline pipeline) { Houdini.HoudiniOutcome outcome = null; CancellationTokenSource tokenSource = new CancellationTokenSource(); List <Task> underApproximatingTasks = new List <Task>(); List <Task> overApproximatingTasks = new List <Task>(); // Schedule the under-approximating engines first foreach (Engine engine in pipeline.GetEngines()) { if (!(engine is VanillaHoudini)) { if (engine is DynamicAnalysis) { DynamicAnalysis dynamicEngine = (DynamicAnalysis)engine; underApproximatingTasks.Add(Task.Factory.StartNew( () => { dynamicEngine.Start(getFreshProgram(true, false)); }, tokenSource.Token)); } else { SMTEngine smtEngine = (SMTEngine)engine; underApproximatingTasks.Add(Task.Factory.StartNew( () => { smtEngine.Start(getFreshProgram(true, true), ref outcome); }, tokenSource.Token)); } } } if (pipeline.runHoudini) { // We set a barrier on the under-approximating engines if a Houdini delay // is specified or no sliding is selected if (pipeline.GetHoudiniEngine().Delay > 0) { Print.VerboseMessage("Waiting at barrier until Houdini delay has elapsed or all under-approximating engines have finished"); Task.WaitAll(underApproximatingTasks.ToArray(), pipeline.GetHoudiniEngine().Delay * 1000); } else if (pipeline.GetHoudiniEngine().SlidingSeconds > 0) { Print.VerboseMessage("Waiting at barrier until all under-approximating engines have finished"); Task.WaitAll(underApproximatingTasks.ToArray()); } // Schedule the vanilla Houdini engine overApproximatingTasks.Add(Task.Factory.StartNew( () => { pipeline.GetHoudiniEngine().Start(getFreshProgram(true, true), ref outcome); }, tokenSource.Token)); // Schedule Houdinis every x seconds until the number of new Houdini instances exceeds the limit if (pipeline.GetHoudiniEngine().SlidingSeconds > 0) { int numOfRefuted = Houdini.ConcurrentHoudini.RefutedSharedAnnotations.Count; int newHoudinis = 0; bool runningHoudinis; do { // Wait before launching new Houdini instances Thread.Sleep(pipeline.GetHoudiniEngine().SlidingSeconds * 1000); // Only launch a fresh Houdini if the candidate invariant set has changed if (Houdini.ConcurrentHoudini.RefutedSharedAnnotations.Count > numOfRefuted) { numOfRefuted = Houdini.ConcurrentHoudini.RefutedSharedAnnotations.Count; VanillaHoudini newHoudiniEngine = new VanillaHoudini(pipeline.GetNextSMTEngineID(), pipeline.GetHoudiniEngine().Solver, pipeline.GetHoudiniEngine().ErrorLimit); pipeline.AddEngine(newHoudiniEngine); Print.VerboseMessage("Scheduling another Houdini instance"); overApproximatingTasks.Add(Task.Factory.StartNew( () => { newHoudiniEngine.Start(getFreshProgram(true, true), ref outcome); tokenSource.Cancel(false); }, tokenSource.Token)); ++newHoudinis; } // Are any Houdinis still running? runningHoudinis = false; foreach (Task task in overApproximatingTasks) { if (task.Status.Equals(TaskStatus.Running)) { runningHoudinis = true; } } } while (newHoudinis < pipeline.GetHoudiniEngine().SlidingLimit&& runningHoudinis); } try { Task.WaitAny(overApproximatingTasks.ToArray(), tokenSource.Token); tokenSource.Cancel(false); } catch (OperationCanceledException e) { Console.WriteLine("Unexpected exception: " + e); throw; } } else { Task.WaitAll(underApproximatingTasks.ToArray()); } return(outcome); }
public override int Format(char[] to, int ofs, ref FormatComponents components) { return(Print.Str(to, ofs, Months.Months3[components.month], 3)); }
public void EvaluateSimpleIfCommandWithElse() { Context context = new Context(); StringWriter writer = new StringWriter(); Print print = new Print(writer); context.SetValue("print", print); context.SetValue("a", 0); EvaluateCommands("if (a == 1) print('Hello'); else print('Hello, world');", context); writer.Close(); Assert.AreEqual("Hello, world\r\n", writer.ToString()); }
public override int Format(char[] to, int ofs, ref FormatComponents components) => Print.Dec2(to, ofs, components.minute);
public static void Test_CalculatePrintDate_01(Print print, string directory, int printNumber, int nb) { string traceFile = zPath.Combine(directory, @"Print\CalculatePrintDateNumber", string.Format("Print_{0}_Date.txt", print.Name)); Trace.WriteLine("print {0} frequency {1} calculate date from number {2} nb {3} trace file \"{4}\"", print.Name, print.Frequency, printNumber, nb, zPath.GetFileName(traceFile)); //Trace.CurrentTrace.DisableBaseLog(); Trace.CurrentTrace.DisableViewer = true; //Trace.CurrentTrace.AddTraceFile(traceFile, LogOptions.RazLogFile); Trace.CurrentTrace.AddOnWrite("Test_CalculatePrintDate_01", WriteToFile.Create(traceFile, FileOption.RazFile).Write); try { Trace.WriteLine("print {0} frequency {1} calculate date from number {2} nb {3}", print.Name, print.Frequency, printNumber, nb); Trace.WriteLine(); for (int i = 0; i < nb; i++) { PrintIssue issue = print.NewPrintIssue(printNumber); Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, printNumber); printNumber++; } } finally { //Trace.CurrentTrace.EnableBaseLog(); //Trace.CurrentTrace.RemoveTraceFile(traceFile); Trace.CurrentTrace.RemoveOnWrite("Test_CalculatePrintDate_01"); Trace.CurrentTrace.DisableViewer = false; } }
public override int Format(char[] to, int ofs, ref FormatComponents components) => Print.Dec2w2(to, ofs, components.second);
public static void PrintHelper(Print delegateFunc, int numToPrint) { delegateFunc(numToPrint); }
public override int Format(char[] to, int ofs, ref FormatComponents components) => Print.Dec1(to, ofs, components.nanosecond / 100000000);
bool reset(List <string> opt) { var stg = new HighwaySettings(4000, 8, 10000); var iH = new Dictionary <string, IMemoryHighway>(); iH.Add("mh", new HeapHighway(stg, 4000)); iH.Add("nh", new MarshalHighway(stg, 4000)); iH.Add("mmf", new MappedHighway(stg, 4000)); foreach (var kp in iH) { var hwName = kp.Value.GetType().Name; var F = new List <MemoryFragment>(); if (opt.Contains(kp.Key)) { var hw = kp.Value; using (hw) { F.Add(hw.AllocFragment(500)); F.Add(hw.AllocFragment(500)); F.Add(hw.AllocFragment(500)); hw.AllocFragment(1000); // lost F.Add(hw.AllocFragment(500)); F.Add(hw.AllocFragment(1000)); foreach (var f in F) { f.Dispose(); } var af = hw.GetTotalActiveFragments(); if (af == 1) { Print.AsInnerInfo("{0} has {1} non disposed fragments", hwName, af); af = hw.GetTotalActiveFragments(); if (af != 1) { Passed = false; FailureMessage = string.Format("{0}: expected one ghost fragment, found {1}.", hwName, af); return(false); } Print.Trace("Forcing reset.. ", ConsoleColor.Magenta, hwName, af); var lane0 = hw[0]; lane0.Force(false, true); af = hw.GetTotalActiveFragments(); if (af != 0) { Passed = false; FailureMessage = string.Format("{0}: expected 0 ghost fragments after forcing a reset, found {1}.", hwName, af); return(false); } else { Print.Trace("{0} has {1} allocations and offset {2}", ConsoleColor.Green, hwName, lane0.Allocations, lane0.Offset); } } else { Passed = false; FailureMessage = string.Format("{0}: the active fragments count is wrong, should be 1.", hwName); return(false); } Print.Trace(hw.FullTrace(), 2, true, ConsoleColor.Cyan, ConsoleColor.Black); } } } return(true); }
protected void btnPrint_Click(object sender, ImageClickEventArgs e) { DataTable dt = new DataTable(); dt = Session[clsConstant.SESS_TABLE] as DataTable; Print excel = new Print(); List <clsPrintObject> objPrint = new List <clsPrintObject>(); clsPrintObject clsPrint = null; List <Flags> flag = new List <Flags>(); Flags testFlag = null; if (ddlLoanNo.SelectedIndex != 0) { testFlag = new Flags(); testFlag.key = "Loan No"; testFlag.value = ddlLoanNo.SelectedItem.Text; flag.Add(testFlag); } if (txtAdvertisementDateFrom.Text != "") { testFlag = new Flags(); testFlag.key = "Advertisement Date (From)"; testFlag.value = txtAdvertisementDateFrom.Text; flag.Add(testFlag); } if (txtEstimatedAmountFrom.Text != "") { testFlag = new Flags(); testFlag.key = "Advertisement Date (From)"; testFlag.value = txtEstimatedAmountFrom.Text; flag.Add(testFlag); } if (txtEstimatedAmountTo.Text != "") { testFlag = new Flags(); testFlag.key = "Advertisement Date (To)"; testFlag.value = txtEstimatedAmountTo.Text; flag.Add(testFlag); } string[] header = new string[] { "LoanNumber", "vsAgencyName", "vsProjectName", "VendorGroupName", "dtAdvertisement", "dtSubmission", "iAmount", "dtAdvertisementSent", "DocSentStatus" }; try { string[] datacolumn = new string[grdAdvertisementDetails.Columns.Count - 1]; int counter = 0; for (int iLoop = 1; iLoop <= header.Length + 1; iLoop++) { if (grdAdvertisementDetails.Columns[iLoop].Visible != false) { if (grdAdvertisementDetails.Columns[iLoop].HeaderText.Equals("Send Email")) { continue; } clsPrint = new clsPrintObject(header[counter], grdAdvertisementDetails.Columns[iLoop].HeaderText.Replace("<br />", "")); clsPrint.HeaderStyle = "style='font-weight:bold;width:80%;'"; clsPrint.FooterStyle = "style='font-weight:bold;'"; switch (clsPrint.ColumnName) { case "dtAdvertisement": clsPrint.Format = ""; clsPrint.ItemStyle = "text-align: Center;width: 53px"; break; case "iAmount": clsPrint.Format = ""; clsPrint.ItemStyle = "text-align: right;width: 53px"; break; } objPrint.Add(clsPrint); counter++; } } excel.TableStyle = "style:'width:100%;font-size:10pt;'"; excel.FlagValues = flag; excel.TableHeader = "Advertisement Details"; Session[clsConstant.SESS_PRINTVALUE] = (string)excel.GenerateHTMLString(dt, objPrint); AddPrintScript(); } catch (Exception ex) { logger.Error(ex); } }
public static void AllocAndWait(this IMemoryHighway hw, AllocTestArgs args) { var rdm = new Random(); var hwType = hw.GetType().Name; var inParallel = args.InParallel > 0 ? args.InParallel : Environment.ProcessorCount; var T = new Task[inParallel]; var part = args.Count / inParallel; var rem = args.Count % inParallel; var dispCounter = new CountdownEvent(args.Count); for (int i = 0; i < inParallel; i++) { T[i] = Task.Run(async() => { // [!] Do not try catch // Someone must process the remainder var subCount = rem > 0 ? part + Interlocked.Exchange(ref rem, 0) : part; for (int j = 0; j < subCount; j++) { var size = args.RandomizeLength ? rdm.Next(1, args.Size) : args.Size; var allocDelayMS = args.RandomizeAllocDelay && args.AllocDelayMS > 0 ? rdm.Next(0, args.AllocDelayMS) : args.AllocDelayMS; var dispDelayMS = args.RandomizeFragDisposal ? rdm.Next(0, args.FragmentDisposeAfterMS) : args.FragmentDisposeAfterMS; if (allocDelayMS > 0) { await Task.Delay(allocDelayMS); } var frag = hw.AllocFragment(size, args.AllocTries); if (frag == null) { "failed to allocate a fragment. The Highway is full.".AsInfo(ConsoleColor.DarkMagenta); dispCounter.Signal(); continue; } if (args.Trace > 0) { Print.Trace("alloc {0,8} bytes on {1} thread: {2} ", ConsoleColor.Magenta, size, hwType, Thread.CurrentThread.ManagedThreadId); } var t = Task.Run(async() => { if (dispDelayMS > 0) { await Task.Delay(dispDelayMS); } if (args.Trace > 0) { Print.Trace("free {0,8} bytes on {1} thread: {2} ", ConsoleColor.Green, frag.Length, hwType, Thread.CurrentThread.ManagedThreadId); } frag.Dispose(); dispCounter.Signal(); }); } }); } Task.WaitAll(T); if (args.AwaitFragmentDisposal) { dispCounter.Wait(); } }
protected void btnPrint_Click(object sender, ImageClickEventArgs e) { try { dt = new DataTable(); dt = Session[clsConstant.SESS_TABLE] as DataTable; Print excel = new Print(); List <clsPrintObject> objPrint = new List <clsPrintObject>(); clsPrintObject clsPrint = null; List <Flags> flag = new List <Flags>(); Flags testFlag = new Flags(); flag.Add(testFlag); if (drpLoanNumber.SelectedIndex > 0) { Flags loanFlag = new Flags(); loanFlag.key = "<br/>Loan Number "; loanFlag.value = drpLoanNumber.SelectedItem.Text; flag.Add(loanFlag); } string[] header = new string[] { "vsLoanNumber", "vsLoanName", "Sector", "dtApprovalDate", "dtClosingDate", "dtRevisedClosingDate", }; string[] datacolumn = new string[grdProjectPerformanceGroupCDetail.Columns.Count - 2]; int counter = 0; for (int iLoop = 1; iLoop <= header.Length; iLoop++) { if (grdProjectPerformanceGroupCDetail.Columns[iLoop].Visible != false) { clsPrint = new clsPrintObject(header[counter], grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br />", "")); //if (grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br />", "").ToString().Equals("Flag") || grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br/>", "").ToString().Equals("Last Flag")) // clsPrint.FlagColumnName = true; //if (grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br/>", "").ToString().Equals("Approval") // || grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br/>", "").ToString().Equals("Closing") // || grdProjectPerformanceGroupCDetail.Columns[iLoop].HeaderText.Replace("<br/>", "").ToString().Equals("Revised Closing") // ) //{ // clsPrint.headerGroup = true; //} //clsPrint.mGroupSize = "5"; //clsPrint.mGroupHeadName = "Date"; //clsPrint.HeaderStyle = "style='font-weight:bold;width:80%;'"; //clsPrint.FooterStyle = "style='font-weight:bold;'"; switch (clsPrint.ColumnName) { case "vsLoanName": clsPrint.ItemStyle = "text-align: Left;width: 400px;"; break; case "dtApprovalDate": clsPrint.Format = "{0:dd MMM yyyy}"; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; case "dtSigningDate": clsPrint.Format = "{0:dd MMM yyyy}"; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; case "dtEffectivenessDate": clsPrint.Format = "{0:dd MMM yyyy}"; //clsPrint.Format = "{0:d}"; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; case "dtClosingDate": clsPrint.Format = "{0:dd MMM yyyy}"; clsPrint.ItemStyle = "'text-align: center;width: 66px;"; break; case "dtRevisedClosingDate": clsPrint.Format = "{0:dd MMM yyyy}"; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; case "camount": clsPrint.Format = ""; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; case "cCancelAmount": clsPrint.Format = ""; clsPrint.ItemStyle = "text-align: center;width: 66px;"; break; } objPrint.Add(clsPrint); counter++; } } string abbr = ""; //"<b>Abbrivation Used:</b><i> Rev: Revised,Mths: Months, C-M: Current to Mid,Rt: Rate, Adtnl: Additional, Impl: Implementation</i>"; string footer = ""; //"<i style='font-size:xx-small'><b></b><i>" + abbr + "<br/>"; excel.TableStyle = "style:'width:100%;'"; excel.FlagValues = flag; // excel.TableHeader = "Completion Delay"; excel.TableHeader = "Loan Under Financial Closure "; excel.TableFooter = footer; Session[clsConstant.SESS_PRINTVALUE] = (string)excel.GenerateHTMLString(dt, objPrint); AddPrintScript(); } catch (Exception ex) { logger.Error(ex); } }
static void Main(string[] args) { var a = new Print(); a.SomeText(); }
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) { Print.GetInstance().PrintReceipt(_itemList, received_money.Text, e, _sale.Barcode); }
private Stmt ParseStmt() { Stmt resultado; if (this.indice == this.tokens.Count) { throw new System.Exception("se esperaban sentencias, se llego al final del archivo"); } // <stmt> := print <expr> // <expr> := <string> // | <int> // | <arith_expr> // | <ident> if (this.tokens[this.indice].Equals("print")) { this.indice++; Print print = new Print(); print.Expr = this.ParseExpr(); resultado = print; } else if (this.tokens[this.indice].Equals("var")) { this.indice++; DeclareVar declareVar = new DeclareVar(); if (this.indice < this.tokens.Count && this.tokens[this.indice] is string) { declareVar.Ident = (string)this.tokens[this.indice]; } else { throw new System.Exception("Se esperaba nombre de variable despues de 'var'"); } this.indice++; if (this.indice == this.tokens.Count || this.tokens[this.indice] != Scanner.Igual) { throw new System.Exception("se esperaba = despues de 'var ident'"); } this.indice++; declareVar.Expr = this.ParseExpr(); resultado = declareVar; } else if (this.tokens[this.indice].Equals("read_int")) { this.indice++; ReadInt readInt = new ReadInt(); if (this.indice < this.tokens.Count && this.tokens[this.indice] is string) { readInt.Ident = (string)this.tokens[this.indice++]; resultado = readInt; } else { throw new System.Exception("Se esperaba el nombre de la variable 'read_int'"); } } //******************* else if (this.tokens[this.indice].Equals("if")) { this.indice++; mcIf mcif = new mcIf(); Expr temp = ParseExpr(); if (this.tokens[this.indice] == Scanner.Eq || this.tokens[this.indice] == Scanner.Neq || this.tokens[this.indice] == Scanner.Gt || this.tokens[this.indice] == Scanner.Gte || this.tokens[this.indice] == Scanner.Lt || this.tokens[this.indice] == Scanner.Lte) { CompExpr compExpr = new CompExpr(); compExpr.Left = temp; object op = this.tokens[this.indice++]; if (op == Scanner.Eq) compExpr.Op = CompOp.Eq; else if (op == Scanner.Neq) compExpr.Op = CompOp.Neq; else if (op == Scanner.Gt) compExpr.Op = CompOp.Gt; else if (op == Scanner.Gte) compExpr.Op = CompOp.Gte; else if (op == Scanner.Lt) compExpr.Op = CompOp.Lt; else if (op == Scanner.Lte) compExpr.Op = CompOp.Lte; compExpr.Rigth = ParseExpr(); temp = compExpr; } mcif.compExpr = temp; if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("then")) { throw new System.Exception("Se esperaba el identificador 'then' despues de 'if'"); } this.indice++; mcif.Then = ParseStmt(); if (this.tokens[this.indice].Equals("else")) { this.indice++; mcif.Else = ParseStmt(); } resultado = mcif; if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("end")) { throw new System.Exception("Sentencia if inconclusa"); } this.indice++; } else if (this.tokens[this.indice].Equals("while")) { this.indice++; WhileLoop whileLoop = new WhileLoop(); Expr temp = ParseExpr(); if (this.tokens[this.indice] == Scanner.Eq || this.tokens[this.indice] == Scanner.Neq || this.tokens[this.indice] == Scanner.Gt || this.tokens[this.indice] == Scanner.Gte || this.tokens[this.indice] == Scanner.Lt || this.tokens[this.indice] == Scanner.Lte) { CompExpr compExpr = new CompExpr(); compExpr.Left = temp; object op = this.tokens[this.indice++]; if (op == Scanner.Eq) compExpr.Op = CompOp.Eq; else if (op == Scanner.Neq) compExpr.Op = CompOp.Neq; else if (op == Scanner.Gt) compExpr.Op = CompOp.Gt; else if (op == Scanner.Gte) compExpr.Op = CompOp.Gte; else if (op == Scanner.Lt) compExpr.Op = CompOp.Lt; else if (op == Scanner.Lte) compExpr.Op = CompOp.Lte; compExpr.Rigth = ParseExpr(); temp = compExpr; } whileLoop.Cond = temp; if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("do")) { throw new System.Exception("Se esperaba el identificador 'do' despues de 'while'"); } this.indice++; whileLoop.Body = ParseStmt(); resultado = whileLoop; if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("end")) { throw new System.Exception("sentencia while inconclusa"); } this.indice++; } //******************* else if (this.tokens[this.indice].Equals("for")) { this.indice++; ForLoop forLoop = new ForLoop(); if (this.indice < this.tokens.Count && this.tokens[this.indice] is string) { forLoop.Ident = (string)this.tokens[this.indice]; } else { throw new System.Exception("se esperaba un indentificador despues de 'for'"); } this.indice++; if (this.indice == this.tokens.Count || this.tokens[this.indice] != Scanner.Igual) { throw new System.Exception("no se encontro en la sentencia for '='"); } this.indice++; forLoop.From = this.ParseExpr(); if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("to")) { throw new System.Exception("se epsaraba 'to' despues de for"); } this.indice++; forLoop.To = this.ParseExpr(); if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("do")) { throw new System.Exception("se esperaba 'do' despues de la expresion en el ciclo for"); } this.indice++; forLoop.Body = this.ParseStmt(); resultado = forLoop; if (this.indice == this.tokens.Count || !this.tokens[this.indice].Equals("end")) { throw new System.Exception("setencia for inconclusa"); } this.indice++; } else if (this.tokens[this.indice] is string) { // assignment Assign assign = new Assign(); assign.Ident = (string)this.tokens[this.indice++]; if (this.indice == this.tokens.Count || this.tokens[this.indice] != Scanner.Igual) { throw new System.Exception("se esperaba '='"); } this.indice++; assign.Expr = this.ParseExpr(); resultado = assign; } else { throw new System.Exception("Error en el token " + this.indice + ": " + this.tokens[this.indice]); } if (this.indice < this.tokens.Count && this.tokens[this.indice] == Scanner.PyC) { this.indice++; if (this.indice < this.tokens.Count && !this.tokens[this.indice].Equals("end") && !this.tokens[this.indice].Equals("else")) { Sequence sequence = new Sequence(); sequence.First = resultado; sequence.Second = this.ParseStmt(); resultado = sequence; } } return resultado; }
public void Visit(Print print) { print.Exp.Accept(this); var printFn = print.Exp.Type.Name == "int" ? _printInt : _printBool; _instructions.Add(Instruction.Create(OpCodes.Call, printFn)); }
public async Task <IActionResult> uploadAsync(OrderPrint orderPrint, OrderDetailPrint orderDetailPrint, Print print, TypePrint typePrint) { orderDetailPrint.PrintId = orderDetailPrint.PrintId.Trim(); string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(Uploadfile.FileName); string extension = Path.GetExtension(Uploadfile.FileName); if (extension == ".jpg" || extension == ".png" || extension == ".gif") { fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; orderDetailPrint.OrdPrintFile = "images/" + fileName; fileName = Path.Combine(wwwRootPath, "images", fileName); using (var fileStream = new FileStream(fileName, FileMode.Create)) { await Uploadfile.CopyToAsync(fileStream); } } var printid = _graphiczoneDBContext.Print.Where(x => x.PrintId == orderDetailPrint.PrintId).FirstOrDefault(); orderDetailPrint.OrdPrintPriceset = printid.PrintPrice; float area = (float)(orderDetailPrint.OrdPrintHeight * orderDetailPrint.OrdPrintWidth) / 10000; float printtotal = (float)(area * orderDetailPrint.OrdPrintPriceset * orderDetailPrint.OrdPrintNum); orderDetailPrint.OrdPrintTotal = printtotal; var genId = _graphiczoneDBContext.OrderDetailPrint.Count(); orderDetailPrint.OrdPrintId = DateTime.Now.ToString("yyMMddHHmmssf") + "0" + (genId + 1).ToString(); orderDetailPrint.OrPrintId = HttpContext.Session.GetString("Cart"); // เพิ่ม _graphiczoneDBContext.OrderDetailPrint.Add(orderDetailPrint); _graphiczoneDBContext.SaveChanges(); return(RedirectToAction("CreateOrder")); }
private void btnOK_Click(object sender, EventArgs e) { NPBarCode[] nPNum = new NPBarCode[this.NPList.Count]; Print print = new Print(); IEnumerator enumerator = this.NPList.GetEnumerator(); for (int i = 0; enumerator.MoveNext(); i++) { nPNum[i] = (NPBarCode) enumerator.Current; } print.LabelPrintSingleNP(nPNum); this.clear(); }
private void btnPrintShopCopies_Click(object sender, RibbonControlEventArgs e) { Print print1 = new Print(); print1.PrintShopCopies(); }
private void init(XElement xelement) { _directory = xelement.zXPathValue("Directory"); _regexModels = new Dictionary<string, RegexValuesModel>(); // zElements("FilenameInfos/FilenameModel") foreach (XElement xe in xelement.zXPathElements("FilenameInfos/FilenameModel")) { RegexValuesModel rvm = new RegexValuesModel(xe); _regexModels.Add(rvm.key, rvm); } // zElements("FilenameInfos/FilenameDate") _dateRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDate")); //XElement xe3 = xelement.zXPathElement("FilenameInfos/FilenameDay"); //if (xe3 != null) // _dayRegex = new RegexValues(xe3); // zElements("FilenameInfos/FilenameDay") _dayRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameDay")); // zElements("FilenameInfos/FilenameNumber") _numberRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameNumber")); //xe3 = xelement.zXPathElement("FilenameInfos/FilenameSpecial"); //if (xe3 != null) // _specialRegex = new RegexValues(xe3); // zElements("FilenameInfos/FilenameSpecial") _specialRegexList = new RegexValuesList(xelement.zXPathElements("FilenameInfos/FilenameSpecial")); _printRegexList = new RegexValuesList(); _prints = new Dictionary<string, Print>(); // zElements("Prints/Print") foreach (XElement xe in xelement.zXPathElements("Prints/Print")) { Print print = null; switch (xe.zXPathValue("Class")) { case "LeMonde": print = new PrintLeMonde(xe, _directory, _regexModels); break; case "LeParisien": print = new PrintLeParisien(xe, _directory, _regexModels); break; case "LExpress": print = new PrintLExpress(xe, _directory, _regexModels); break; case "LeVifExpress": print = new PrintLeVifExpress(xe, _directory, _regexModels); break; default: print = new Print(xe, _directory, _regexModels); break; } string name = print.Name; _prints.Add(name, print); int n = 1; // zElements("Filename") foreach (XElement xe2 in xe.zXPathElements("Filename")) { string key = name + n++.ToString(); string regex = xe2.zExplicitAttribValue("regex"); string values = xe2.zAttribValue("values"); string options = xe2.zAttribValue("options"); _printRegexList.Add(key, new RegexValues(key, name, regex, options, values)); } } }
internal static stmt Convert(Statement stmt) { stmt ast; if (stmt is FunctionDefinition) ast = new FunctionDef((FunctionDefinition)stmt); else if (stmt is ReturnStatement) ast = new Return((ReturnStatement)stmt); else if (stmt is AssignmentStatement) ast = new Assign((AssignmentStatement)stmt); else if (stmt is AugmentedAssignStatement) ast = new AugAssign((AugmentedAssignStatement)stmt); else if (stmt is DelStatement) ast = new Delete((DelStatement)stmt); else if (stmt is PrintStatement) ast = new Print((PrintStatement)stmt); else if (stmt is ExpressionStatement) ast = new Expr((ExpressionStatement)stmt); else if (stmt is ForStatement) ast = new For((ForStatement)stmt); else if (stmt is WhileStatement) ast = new While((WhileStatement)stmt); else if (stmt is IfStatement) ast = new If((IfStatement)stmt); else if (stmt is WithStatement) ast = new With((WithStatement)stmt); else if (stmt is RaiseStatement) ast = new Raise((RaiseStatement)stmt); else if (stmt is TryStatement) ast = Convert((TryStatement)stmt); else if (stmt is AssertStatement) ast = new Assert((AssertStatement)stmt); else if (stmt is ImportStatement) ast = new Import((ImportStatement)stmt); else if (stmt is FromImportStatement) ast = new ImportFrom((FromImportStatement)stmt); else if (stmt is ExecStatement) ast = new Exec((ExecStatement)stmt); else if (stmt is GlobalStatement) ast = new Global((GlobalStatement)stmt); else if (stmt is ClassDefinition) ast = new ClassDef((ClassDefinition)stmt); else if (stmt is BreakStatement) ast = new Break(); else if (stmt is ContinueStatement) ast = new Continue(); else if (stmt is EmptyStatement) ast = new Pass(); else throw new ArgumentTypeException("Unexpected statement type: " + stmt.GetType()); ast.GetSourceLocation(stmt); return ast; }
private static void Execute(Print p) { p("tekst"); }
public override string PutToSleep() { return(Print.MakeSound("Zzzzz")); }
public static void Test_CalculatePrintNumber_02(Print print, string directory, Date date, int nb) { string traceFile = zPath.Combine(zPath.Combine(directory, @"Print\CalculatePrintDateNumber"), string.Format("Print_{0}_Number.txt", print.Name)); Trace.WriteLine("print {0} frequency {1} calculate number from date {2:dd-MM-yyyy} nb {3} trace file \"{4}\"", print.Name, print.Frequency, date, nb, zPath.GetFileName(traceFile)); //Trace.CurrentTrace.DisableBaseLog(); //Trace.CurrentTrace.DisableTraceView = true; //Trace.CurrentTrace.AddTraceFile(traceFile, LogOptions.RazLogFile); Trace.CurrentTrace.AddOnWrite("Test_CalculatePrintNumber_02", WriteToFile.Create(traceFile, FileOption.RazFile).Write); try { Trace.WriteLine("print {0} frequency {1} calculate number from date {2:dd-MM-yyyy} nb {3}", print.Name, print.Frequency, date, nb); Trace.WriteLine(); if (print.Frequency == PrintFrequency.Daily) { for (int i = 0; i < nb; i++) { PrintIssue issue = print.NewPrintIssue(date); int number = issue.PrintNumber; Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number); date = date.AddDays(1); } } else if (print.Frequency == PrintFrequency.Weekly) { for (int i = 0; i < nb; i++) { PrintIssue issue = print.NewPrintIssue(date); int number = issue.PrintNumber; Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number); date = date.AddDays(7); } } else if (print.Frequency == PrintFrequency.Monthly) { for (int i = 0; i < nb; i++) { PrintIssue issue = print.NewPrintIssue(date); int number = issue.PrintNumber; Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number); date = date.AddMonths(1); } } else if (print.Frequency == PrintFrequency.Bimonthly || print.Frequency == PrintFrequency.Quarterly) { int lastNumber = 0; for (int i = 0; i < nb; ) { PrintIssue issue = print.NewPrintIssue(date); int number = issue.PrintNumber; if (number != lastNumber) { Trace.WriteLine("{0:yyyy-MM-dd ddd} {1}", issue.Date, number); lastNumber = number; i++; } date = date.AddMonths(1); } } } finally { //Trace.CurrentTrace.EnableBaseLog(); //Trace.CurrentTrace.RemoveTraceFile(traceFile); Trace.CurrentTrace.RemoveOnWrite("Test_CalculatePrintNumber_02"); Trace.CurrentTrace.DisableViewer = false; } }
private void PhotoPrint() { Print.PrintImage(photoViewer1.Photo.PhotoPath, photoViewer1.Photo.PhotoName); }
public void Visit(Print print) { // Nothing to do here... }
protected void btnPrint_Click(object sender, ImageClickEventArgs e) { try { dt = new DataTable(); dt = Session[clsConstant.SESS_TABLE] as DataTable; Print excel = new Print(); List <clsPrintObject> objPrint = new List <clsPrintObject>(); clsPrintObject clsPrint = null; List <Flags> flag = new List <Flags>(); Flags testFlag = new Flags(); testFlag.key = "Year"; testFlag.value = "2011"; flag.Add(testFlag); Flags testFlag1 = new Flags(); testFlag1.key = "Amount"; testFlag1.value = " in USD"; flag.Add(testFlag1); if (drpLoanNumber.SelectedIndex > 0) { Flags loanFlag = new Flags(); loanFlag.key = "<br/>Loan Number "; loanFlag.value = drpLoanNumber.SelectedItem.Text; flag.Add(loanFlag); } if (drpAgency.SelectedIndex > 0) { Flags agencyFlag = new Flags(); agencyFlag.key = "<br/> Agency "; agencyFlag.value = drpAgency.SelectedItem.Text; flag.Add(agencyFlag); } if (drpState.SelectedIndex > 0) { Flags stateFlag = new Flags(); stateFlag.key = "<br/>State "; stateFlag.value = drpState.SelectedItem.Text; flag.Add(stateFlag); } if (drpYear.SelectedIndex > 0) { Flags yearsFlag = new Flags(); yearsFlag.key = "<br/>Year "; yearsFlag.value = drpYear.SelectedItem.Text; flag.Add(yearsFlag); } string[] header = new string[] { "vsLoanNumber", "vsAgencyName", "vsState", "vsDocCatName", "iYear", "ContractAwardMonthwiseValues", "dtAuditRepDate" }; string[] datacolumn = new string[grdContractAward.Columns.Count - 1]; int j = 0; for (int i = 0; i < grdContractAward.Columns.Count - 2; i++) { clsPrint = new clsPrintObject(); clsPrint.ColumnName = header[j]; clsPrint.Caption = grdContractAward.Columns[i + 1].HeaderText; switch (clsPrint.ColumnName) { case "iYear": clsPrint.Format = ""; clsPrint.ItemStyle = "style='text-align: right'"; break; case "dtAuditRepDate": clsPrint.Format = "{0:d}"; clsPrint.ItemStyle = "style='text-align: center'"; break; } clsPrint.HeaderStyle = "style='font-weight:bold;width:80%;'"; clsPrint.FooterStyle = "style='font-weight:bold;'"; objPrint.Add(clsPrint); j++; } excel.TableStyle = "style:'width:100%;font-size:10pt;'"; if (flag != null) { excel.FlagValues = flag; } excel.TableHeader = "Contract Award Details By Month"; DataTable dtPrint = Session[clsConstant.SESS_TABLE] as DataTable; if (dtPrint != null) { if (!dtPrint.Columns.Contains("ContractAwardMonthwiseValues")) { dtPrint.Columns.Add(new DataColumn("ContractAwardMonthwiseValues")); } foreach (DataRow dr in dtPrint.Rows) { dr["ContractAwardMonthwiseValues"] = dr["iQ1Target"].ToString() + "*" + dr["iQ2Target"].ToString() + "*" + dr["iQ3Target"].ToString() + "*" + dr["iQ4Target"].ToString() + "*" + dr["iTotalTargetAward"].ToString() + "*" + //til here dr["iAMonth1"].ToString() + "*" + dr["iAMonth2"].ToString() + "*" + dr["iAMonth3"].ToString() + "*" + dr["iAMonth4"].ToString() + "*" + dr["iAMonth5"].ToString() + "*" + dr["iAMonth6"].ToString() + "*" + dr["iAMonth7"].ToString() + "*" + dr["iAMonth8"].ToString() + "*" + dr["iAMonth9"].ToString() + "*" + dr["iAMonth10"].ToString() + "*" + dr["iAMonth11"].ToString() + "*" + dr["iAMonth12"].ToString() + "*" + dr["iTotalActualAward"].ToString(); } } Session[clsConstant.SESS_TABLE] = dtPrint; Session[clsConstant.SESS_PRINTVALUE] = (string)excel.GenerateHTMLString(dtPrint, objPrint); AddPrintScript(); } catch (Exception ex) { logger.Error(ex); } }
public static void display(Print pMethod, String msg) { pMethod(msg); }
public void printSmileButton() { Print.PrintTexture(texture2D.EncodeToPNG(), copies, printerName); }
public object VisitPrintStmt(Print stmt) { Resolve(stmt.Expr); return(null); }
private void CommandBinding_Print(object sender, ExecutedRoutedEventArgs e) { Print.Init().PrintTree(Modal[0]); }
public void Visit(Print print) { Indent(); _sb.Append("print("); print.Exp.Accept(this); _sb.Append(")\r\n"); }
protected void imgPrint_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataTable dt = new DataTable(); dt = Session[clsConstant.SESS_TABLE] as DataTable; if (!dt.Columns.Contains("iNominationID")) { dt.Columns.Remove("iNominationID"); } Print excel = new Print(); List <clsPrintObject> objPrint = new List <clsPrintObject>(); clsPrintObject clsPrint = null; List <Flags> flag = new List <Flags>(); Flags testFlag = null; if (txtTopic.Text != "") { testFlag = new Flags(); testFlag.key = "Topic"; testFlag.value = txtTopic.Text; flag.Add(testFlag); } if (drpSector.SelectedIndex != 0) { testFlag = new Flags(); testFlag.key = "Sector"; testFlag.value = drpSector.SelectedItem.Text; flag.Add(testFlag); } if (txtFromDate.Text != "") { testFlag = new Flags(); testFlag.key = "From Date"; testFlag.value = txtFromDate.Text; flag.Add(testFlag); } if (txtToDate.Text != "") { testFlag = new Flags(); testFlag.key = "From Date"; testFlag.value = txtFromDate.Text; flag.Add(testFlag); } if (txtVenue.Text != "") { testFlag = new Flags(); testFlag.key = "Venue"; testFlag.value = txtVenue.Text; flag.Add(testFlag); } if (drpTargetAudience.SelectedIndex != 0) { testFlag = new Flags(); testFlag.key = "Target Audience"; testFlag.value = drpTargetAudience.SelectedItem.Text; flag.Add(testFlag); } if (drpInvite.SelectedIndex != 0) { testFlag = new Flags(); testFlag.key = "Invite By"; testFlag.value = drpInvite.SelectedItem.Text; flag.Add(testFlag); } if (drpNationalInternational.SelectedIndex != 0) { testFlag = new Flags(); testFlag.key = "National / International"; testFlag.value = drpNationalInternational.SelectedItem.Text; flag.Add(testFlag); } if (txtLstDate.Text != "") { testFlag = new Flags(); testFlag.key = "Last Date of Nomination"; testFlag.value = txtLstDate.Text; flag.Add(testFlag); } string[] header = new string[] { "vsTopic", "Sector", "dtFromDate", "dtToDate", "vsVenue", "vsTargetAudienceName", "vsInviteType", "iSeats", "vsName", "dtLastDate", "vsFile" }; try { string[] datacolumn = new string[grdNominationManagementSystem.Columns.Count - 2]; int counter = 0; for (int iLoop = 1; iLoop <= header.Length; iLoop++) { if (grdNominationManagementSystem.Columns[iLoop].Visible != false) { clsPrint = new clsPrintObject(header[counter], grdNominationManagementSystem.Columns[iLoop].HeaderText.Replace("<br />", "")); clsPrint.HeaderStyle = "style='font-weight:bold;width:80%;'"; clsPrint.FooterStyle = "style='font-weight:bold;'"; switch (clsPrint.ColumnName) { case "dtFromDate": clsPrint.Format = "{0:d}"; break; case "dtToDate": clsPrint.Format = "{0:d}"; break; case "dtLastDate": clsPrint.Format = "{0:d}"; break; } objPrint.Add(clsPrint); counter++; } } excel.TableStyle = "style:'width:100%;font-size:10pt;'"; excel.FlagValues = flag; excel.TableHeader = "Nomination Management Details"; Session[clsConstant.SESS_PRINTVALUE] = (string)excel.GenerateHTMLString(dt, objPrint); AddPrintScript(); } catch (Exception ex) { logger.Error(ex); } }
protected void OnPrintButtonClicked(object sender, EventArgs e) { Print pr = new Print(); }
static void Main(string[] args) { //anonymous method to take a string(sentence) Print print = delegate(string sentence) { //split the sentence using " "--space and store in array of string string[] words = sentence.Split(" "); Console.WriteLine("After splitting"); //printing each word on the console foreach (string word in words) { Console.WriteLine(word); } }; //Take string input from user Console.Write("Enter sentence : "); string str = Console.ReadLine(); print(str); Console.WriteLine("************************************************************\n"); //anonymous method to take 2 int values PrintProduct prod = delegate(int num1, int num2) { Console.WriteLine($"Product of {num1} and {num2} is {num1 * num2}"); }; //Take string input from user Console.Write("Enter First Number : "); int n1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Second Number : "); int n2 = Convert.ToInt32(Console.ReadLine()); prod(n1, n2); Console.WriteLine("************************************************************\n"); //Create a List of Employees List <Employee> listEmployees = new List <Employee>(); listEmployees.Add(new Employee("John", 100000)); listEmployees.Add(new Employee("Rahul", 300000)); listEmployees.Add(new Employee("Patel", 200000)); listEmployees.Add(new Employee("Meera", 400000)); listEmployees.Add(new Employee("Alice", 500000)); Employee emps = new Employee(); //Predicate Predicate <List <Employee> > empWithHigherSalary = emps.findEmployee; bool result = empWithHigherSalary(listEmployees); //if emp found call method to print result if (result == true) { emps.printResult(); } else { Console.WriteLine("No employee with salary > 200k found"); } Console.WriteLine("************************************************************\n"); //Create directory string root = @"C:\00_Temp"; // If directory does not exist, create it. if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } string fileName = @"c:\00_Temp\MyTextFile.txt"; //call to method FileWriteAndRead f = new FileWriteAndRead(); f.writeAndRead(fileName); Console.WriteLine("************************************************************\n"); Console.WriteLine("?? Example"); List <string> names = null; string? a = null; string? b = "Meera"; /* * Available in C# 8.0 and later, so if old version add <LangVersion>8.0</LangVersion> in .csproj file * The null -coalescing assignment operator ??= assigns the value of its right-hand operand to its * left-hand operand only if the left-hand operand evaluates to null. * The ??= operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null */ (names ??= new List <string>()).Add("Paul"); foreach (string name in names) { Console.WriteLine(name); } Console.WriteLine(""); names.Add(a ??= "John"); names.Add(b ??= "Bob"); foreach (string name in names) { Console.WriteLine(name); } Console.WriteLine("************************************************************\n"); Console.WriteLine("Nullable Example"); string?bookName = null; double?price = null; //Console.WriteLine(price.GetValueOrDefault()); if (price.HasValue) { Console.WriteLine("Price is " + price.Value); } else { Console.WriteLine("Price is Null"); } string book = bookName ?? "Nimona"; double value = price ?? 50.55; Console.WriteLine("Book : " + book); Console.WriteLine("Value : " + value); NullableClassEx myClass = new NullableClassEx(); if (myClass.val == null) { Console.WriteLine("NullableClass variable is null"); } //Null is considered to be less than any value. So comparison operators won't work against null. if (price < value) { Console.WriteLine("price < value"); } else if (price > value) { Console.WriteLine("price > value"); } else if (price == value) { Console.WriteLine("price == value"); } else { Console.WriteLine("Could not compare price and Value"); } //Nullable static class is a helper class for Nullable types. //It provides a compare method to compare nullable types. /* * if (Nullable.Compare<double>(price, value) < 0) * Console.WriteLine("price < value"); * else if (Nullable.Compare<double>(price, value) > 0) * Console.WriteLine("price > value"); * else * Console.WriteLine("price = value"); */ }