/// <summary> /// Pretty printer /// </summary> /// <returns>A human-readable representation of the this set.</returns> public override string ToString() { StringBuilder sb = new StringBuilder("Set("); bool isFirst = true; if (this.elems != null) { foreach (T val in this.elems) { if (!isFirst) { sb.Append(", "); } PrettyPrinter.Format(sb, val); isFirst = false; } } sb.Append(")"); return(sb.ToString()); }
//rendering the dialog box public static void Render(string name, string action, string legend, string label, string onComplete) { var insideView = ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page); UploadRepository.CreateUploadGUID(insideView.Context); var uploadid = UploadIDTag + Guid.NewGuid().ToString(); insideView.Html.RenderPartial( "FileUpload", new FileUpload() { Name = name, OnComplete = onComplete, Action = action, Title = legend, Label = label, UploadID = uploadid, MaxFileSize = PrettyPrinter.FormatByteCount((ulong)((HttpRuntimeSection)ConfigurationManager.GetSection("system.web/httpRuntime")).MaxRequestLength * 100) }); }
/// <summary> /// Pretty printing /// </summary> /// <returns>A formatted string showing the type and fields of this value</returns> public override string ToString() { StringBuilder sb = new StringBuilder(this.Sort.Name); // PrettyPrinter.FormatType(sb, this.GetType()); sb.Append("("); bool isFirst = true; foreach (object obj in this.FieldValues()) { if (!isFirst) { sb.Append(", "); } PrettyPrinter.Format(sb, obj); isFirst = false; } sb.Append(")"); return(sb.ToString()); }
public void PrintProgram_NewLineOptionNotAuto_ShouldUseSpecifiedNewline(NewlineOption newlineOption, string originalNewline, string expectedNewline) { var programSyntax = ParserHelper.Parse(string.Join(originalNewline, new[] { "var foo = bar", "var bar = foo", "var baz = bar" })); var options = new PrettyPrintOptions(newlineOption, IndentKindOption.Space, 2, false); var output = PrettyPrinter.PrintProgram(programSyntax, options); output.Should().Be(string.Join(expectedNewline, new[] { "var foo = bar", "var bar = foo", "var baz = bar" })); }
public override void Print(PrettyPrinter printer) { base.Print(printer); printer.Print(" ["); if (Count > 0) { printer.Println(); } using (printer.IndentCookie()) { foreach (var v in this) { v.PrintEx(printer); printer.Println(); } } printer.Println("]"); }
string Evaluate(string input) { bool result_set; object result; try { input = evaluator.Evaluate(input, out result, out result_set); if (result_set) { PrettyPrinter.PrettyPrint(logTextWriter, result); WriteLine(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(null); } return(input); }
//custom body //equals trait //hash code trait //pretty print public override void Print(PrettyPrinter printer) { printer.Println("UnityModel ("); using (printer.IndentCookie()) { printer.Print("play = "); _Play.PrintEx(printer); printer.Println(); printer.Print("pause = "); _Pause.PrintEx(printer); printer.Println(); printer.Print("step = "); _Step.PrintEx(printer); printer.Println(); printer.Print("unityPluginVersion = "); _UnityPluginVersion.PrintEx(printer); printer.Println(); printer.Print("riderProcessId = "); _RiderProcessId.PrintEx(printer); printer.Println(); printer.Print("applicationPath = "); _ApplicationPath.PrintEx(printer); printer.Println(); printer.Print("applicationVersion = "); _ApplicationVersion.PrintEx(printer); printer.Println(); printer.Print("logModelInitialized = "); _LogModelInitialized.PrintEx(printer); printer.Println(); printer.Print("isBackendConnected = "); _IsBackendConnected.PrintEx(printer); printer.Println(); printer.Print("getUnityEditorState = "); _GetUnityEditorState.PrintEx(printer); printer.Println(); printer.Print("openFileLineCol = "); _OpenFileLineCol.PrintEx(printer); printer.Println(); printer.Print("updateUnityPlugin = "); _UpdateUnityPlugin.PrintEx(printer); printer.Println(); printer.Print("refresh = "); _Refresh.PrintEx(printer); printer.Println(); printer.Print("unitTestLaunch = "); _UnitTestLaunch.PrintEx(printer); printer.Println(); } printer.Print(")"); }
public void ServerAsyncReceive(IAsyncResult ar) { try { AsyncState state = (AsyncState)(ar.AsyncState); byte[] serverData = state.buffer; int serverBytes = 0; serverBytes = connection.Socket.EndReceive(ar); if (serverBytes > 0) { // Add the packets serverPacketizer.QueuePackets(serverData, serverBytes); int packets = serverPacketizer.ProcessPackets(); for (int i = 0; i < packets; i++) { byte[] packet = serverPacketizer.PopItem(); PyObject data = Unmarshal.Process <PyObject>(packet); Log.Warning("PacketTracer::Server", PrettyPrinter.Print(data)); data = OldHandle(data); SendClient(data); } } connection.Socket.BeginReceive(state.buffer, 0, 8192, SocketFlags.None, serverReceive, state); } catch (Exception ex) { Log.Error("ExceptionHandler", ex.ToString()); CloseConnection(); } }
internal static void PrettyPrint(PrettyPrinter p, IReflectionBindable instance) { Action <IReflectionBindable, PrettyPrinter> prettyPrinter; lock (ourPrettyPrintersLock) { ourPrettyPrinters.TryGetValue(instance.GetType(), out prettyPrinter); } if (prettyPrinter == null) { var t = instance.GetType(); var header = t.Name + " ("; var bindableMembers = SerializerReflectionUtil.GetBindableMembers(t.GetTypeInfo()); var getters = bindableMembers.Select(ReflectionUtil.GetGetter).ToArray(); var intros = bindableMembers.Select(mi => $"{mi.Name} = ").ToArray(); prettyPrinter = (o, printer) => { printer.Print(header); using (printer.IndentCookie()) { for (int i = 0; i < getters.Length; i++) { printer.Print(intros[i]); getters[i](o).PrintEx(printer); printer.Println(); } } printer.Print(")"); }; lock (ourPrettyPrintersLock) { ourPrettyPrinters[t] = prettyPrinter; } } prettyPrinter(instance, p); }
private void ClientAsyncReceive(IAsyncResult ar) { try { AsyncState state = (AsyncState)(ar.AsyncState); byte[] clientData = state.buffer; int clientBytes = 0; clientBytes = socket.Socket.EndReceive(ar); if (clientBytes > 0) { clientPacketizer.QueuePackets(clientData, clientBytes); int packets = clientPacketizer.ProcessPackets(); for (int i = 0; i < packets; i++) { byte[] packet = clientPacketizer.PopItem(); PyObject data = Unmarshal.Process <PyObject>(packet); Log.Warning("PacketTracer::Client", PrettyPrinter.Print(data)); data = OldHandle(data); SendServer(data); } } socket.Socket.BeginReceive(state.buffer, 0, 8192, SocketFlags.None, clientReceive, state); } catch (Exception ex) { Log.Error("ExceptionHandler", ex.ToString()); CloseConnection(); } }
static void ExecuteCommandArgument(string[] args) { //Strip command argument from args string commandArg = args[0].ToLower(); string[] arguments = args.Where(x => x != args[0]).ToArray(); try { //Execute the argument and pass the remaining arguments ConsoleCommand command = CommandTable[commandArg]; command.CommandDelegate(arguments); } catch (KeyNotFoundException) { Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(); PrettyPrinter.Print($"Unknown command '{commandArg}'!"); Console.ForegroundColor = ConsoleColor.White; Help(); } }
public void Body_ShouldPrint_Prints() { var ast = new Body ( new IntegerLiteral(0, "123"), new List <Print> { new Print(0, new Identifier(0, "x")), new Print(0, new Identifier(0, "y")) } ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Body Print Identifier(x) Print Identifier(y) Expr Integer(123) ")); }
public override string dump(string prefix) { string pfx1 = prefix + PrettyPrinter.Spacer; string pfx2 = pfx1 + PrettyPrinter.Spacer; string pfx3 = pfx2 + PrettyPrinter.Spacer; StringBuilder builder = new StringBuilder(); builder.AppendLine("[CallMachoBindObject]:"); builder.AppendLine(pfx1 + "Bind Arguments:"); if (bindArgs != null) { PrettyPrinter.Print(builder, pfx2, bindArgs); } else { if (locationID == 0) { if (characterID == 0) { builder.AppendLine(pfx2 + "<nullptr>"); } else { builder.AppendLine(pfx2 + "characterID: " + characterID); } } else { builder.AppendLine(pfx2 + "LocationID: " + locationID); builder.AppendLine(pfx2 + "LocationGourpID: " + locationGroupID); } } builder.AppendLine(pfx1 + "Call: '" + callMethod + "'"); builder.AppendLine(pfx2 + "Call Arguments:"); PrettyPrinter.Print(builder, pfx3, callTuple); builder.AppendLine(pfx2 + "Call Named Arguments:"); PrettyPrinter.Print(builder, pfx3, callDict); return(builder.ToString()); }
public override void dump(PrettyPrinter printer) { printer.addLine("[CallMachoBindObject]:"); printer.indentLevel++; printer.addLine("Bind Arguments:"); if (bindArgs != null) { printer.addItem(bindArgs); } else { printer.indentLevel++; if (locationID == 0) { if (characterID == 0) { printer.addLine("<nullptr>"); } else { printer.addLine("characterID: " + characterID); } } else { printer.addLine("LocationID: " + locationID); printer.addLine("LocationGourpID: " + locationGroupID); } printer.indentLevel--; } printer.addLine("Call: '" + callMethod + "'"); printer.indentLevel++; printer.addLine("Call Arguments:"); printer.addItem(callTuple); printer.addLine("Call Named Arguments:"); printer.addItem(callDict); printer.indentLevel--; printer.indentLevel--; }
/// <exclude /> public override string ToString() { StringBuilder sb = new StringBuilder("Bag("); bool isFirst = true; foreach (Pair <T, int> keyValue in this.representation) { if (!isFirst) { sb.Append(", "); } PrettyPrinter.Format(sb, keyValue.First); if (keyValue.Second > 1) { sb.Append(" ("); PrettyPrinter.Format(sb, keyValue.Second); sb.Append(")"); } isFirst = false; } sb.Append(")"); return(sb.ToString()); }
public override string dump(string prefix) { string pfx1 = prefix + PrettyPrinter.Spacer; string pfx2 = pfx1 + PrettyPrinter.Spacer; string pfx3 = pfx2 + PrettyPrinter.Spacer; StringBuilder builder = new StringBuilder(); builder.AppendLine("[PyCallStream" + zeroOne + "]"); if (remoteObject == 0) { builder.AppendLine(pfx1 + "remoteObject: '" + remoteObjectStr + "'"); } else { builder.AppendLine(pfx1 + "remoteObject: " + remoteObject); } builder.AppendLine(pfx1 + "Method: '" + method + "'"); builder.AppendLine(pfx1 + "Arguments:"); if (extended != null) { PrettyPrinter.Print(builder, pfx2, extended); } else { PrettyPrinter.Print(builder, pfx2, arg_tuple); } if (arg_dict == null) { builder.AppendLine(pfx1 + "Named Arguments: None"); } else { builder.AppendLine(pfx1 + "Named Arguments:"); PrettyPrinter.Print(builder, pfx2, arg_dict); } return(builder.ToString()); }
public void TrimIndents() { string origin = @"try { $LogHandler->writeToLog(""message""); } catch (Exception $e) { // do nothing }" ; var printer = new PrettyPrinter() { TrimIndent = true }; string actual = printer.Print(origin); string expected = @"try { $LogHandler->writeToLog(""message""); } catch (Exception $e) { // do nothing }"; Assert.AreEqual(expected, actual); }
/// <summary> /// Sends a PyObject through this socket /// </summary> /// <param name="packet">The packet data to send</param> public void Send(PyDataType packet) { #if DEBUG this.mPacketLog.Trace(PrettyPrinter.FromDataType(packet)); #endif // marshal the packet first byte[] encodedPacket = PythonTypes.Marshal.Marshal.ToByteArray(packet); // compress the packet if it exceeds the maximum size if (encodedPacket.Length > Constants.Network.MAX_PACKET_SIZE) { encodedPacket = ZlibHelper.Compress(encodedPacket); } // generate the final buffer byte[] packetBuffer = new byte[encodedPacket.Length + sizeof(int)]; // write the packet size and the buffer to the new buffer Buffer.BlockCopy(BitConverter.GetBytes(encodedPacket.Length), 0, packetBuffer, 0, sizeof(int)); Buffer.BlockCopy(encodedPacket, 0, packetBuffer, sizeof(int), encodedPacket.Length); // after processing the whole packet queue the actual data this.Send(packetBuffer); }
private void ExtractGVNodes2(Node <IList <IInstruction> > node, Dictionary <Node <IList <IInstruction> >, GraphVizNode> nodeDict) { if (!nodeDict.ContainsKey(node)) { var ms = new MemoryStream(); var sw = new StreamWriter(ms); PrettyPrinter.PrettyPrint(node.Content, sw); sw.Flush(); ms.Seek(0, SeekOrigin.Begin); var data = new StreamReader(ms).ReadToEnd(); nodeDict.Add(node, new GraphVizNode() { Id = IdC++, Label = data }); if (node.Left != null) { ExtractGVNodes(node.Left, nodeDict); } if (node.Right != null) { ExtractGVNodes(node.Right, nodeDict); } } }
/// <summary> /// Sends a PyObject through this socket /// </summary> /// <param name="packet">The packet data to send</param> public void Send(PyDataType packet) { #if DEBUG this.mPacketLog.Trace(PrettyPrinter.FromDataType(packet)); #endif MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); // marshal the packet first byte[] encodedPacket = PythonTypes.Marshal.Marshal.ToByteArray(packet); // compress the packet if it exceeds the maximum size if (encodedPacket.Length > Constants.Network.MAX_PACKET_SIZE) { encodedPacket = ZlibHelper.Compress(encodedPacket); } // write the size to the stream writer.Write(encodedPacket.Length); // finally copy the packet buffer writer.Write(encodedPacket); // after processing the whole packet queue the actual data this.Send(stream.ToArray()); }
/// <nodoc /> public static string ToDisplayString(this Node node, ImmutableContextBase context) { Contract.Requires(node != null); Contract.Requires(context != null); using (var writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture)) { try { return(PrettyPrinter.GetLogStringRepr( context.FrontEndContext, writer, context.LastActiveUsedPath.GetParent(context.FrontEndContext.PathTable), context.Package.Path.GetParent(context.FrontEndContext.PathTable), node)); } catch (NotImplementedException) { // Some AST values have no implementation of visitor. // TODO: Fix me! return(I($"<ValueExpression:({node.Location.Line},{node.Location.Position})>")); } } }
public void RunTests() { // Read graphs to test from files ReadGraphsFromFile(); // Prepare table printing PrettyPrinter printer = new PrettyPrinter(Logger); TableBuilder table = printer.BuildTable(new string[] { "Graph", "Algorithm", "Time" }, "Execution Times"); // Perform tests Logger.LogInformation("Run minimum spanning tree tests..."); foreach (KeyValuePair <string, IWeightedGraph <int, double> > graph in Graphs) { foreach (ALGORITHM algorithm in AlgorithmsToTest) { TimeSpan time = RunTest(graph.Key, graph.Value, algorithm); table.AddLine(new string[] { graph.Key, algorithm.ToString(), time.ToString() }); } } Logger.LogInformation("Done running minimum spanning tree tests.\n"); // Display times as table table.Print(); }
public void RunTests() { // Read graphs to test from files ReadGraphsFromFile(); // Prepare table printing PrettyPrinter printer = new PrettyPrinter(Logger); TableBuilder table = printer.BuildTable(new string[] { "Graph", "Algorithm", "Route Costs", "Time" }); // Perform tests Logger.LogInformation("Run TSP tests..."); foreach (KeyValuePair <string, IWeightedGraph <int, double> > graph in Graphs) { foreach (TspAlgorithm algorithm in AlgorithmsToTest) { TestResult result = RunTest(graph.Key, graph.Value, algorithm); table.AddLine(new string[] { graph.Key, algorithm.ToString(), result.Weight.ToString(), result.Time.ToString() }); } } Logger.LogInformation("Done TSP tree tests.\n"); // Display times as table table.Print(); }
public void PrintProgram_AnyProgram_ShouldRoundTrip(DataSet dataSet) { var program = ParserHelper.Parse(dataSet.Bicep); var diagnostics = program.GetParseDiagnostics(); var diagnosticMessages = diagnostics.Select(d => d.Message); var options = new PrettyPrintOptions(NewlineOption.Auto, IndentKindOption.Space, 2, true); var formattedOutput = PrettyPrinter.PrintProgram(program, options); var formattedProgram = ParserHelper.Parse(formattedOutput !); var newDiagnostics = formattedProgram.GetParseDiagnostics(); var newDiagnosticMessages = newDiagnostics.Select(d => d.Message); // Diagnostic messages should remain the same after formatting. newDiagnostics.Should().HaveSameCount(diagnostics); newDiagnosticMessages.Should().BeEquivalentTo(diagnosticMessages); // Normalize formatting var regex = new Regex("[\\r\\n\\s]+"); string programText = regex.Replace(program.ToTextPreserveFormatting(), ""); string formattedProgramText = regex.Replace(formattedProgram.ToTextPreserveFormatting(), ""); formattedProgramText.Should().Be(programText); }
//ToString - - - - - - - - - - - - - - - - - - - - - - - - - /// <summary> /// Returns the map formatted in the form "Map(key_1 -> value_1, ..., key_n -> value_n)" /// </summary> public override string ToString() { StringBuilder sb = new StringBuilder("Map("); bool isFirst = true; if (this.elems != null) { foreach (Maplet keyValue in this.elems) { if (!isFirst) { sb.Append(", "); } // sb.Append("("); PrettyPrinter.Format(sb, keyValue.d.First); sb.Append(" -> "); PrettyPrinter.Format(sb, keyValue.d.Second); // sb.Append(")"); isFirst = false; } } sb.Append(")"); return(sb.ToString()); }
public void Example_uses_consistent_formatting(ExampleData example) { // save all the files in the containing directory to disk so that we can test module resolution var parentStream = Path.GetDirectoryName(example.BicepStreamName) !.Replace('\\', '/'); var outputDirectory = FileHelper.SaveEmbeddedResourcesWithPathPrefix(TestContext, typeof(ExamplesTests).Assembly, example.OutputFolderName, parentStream); var bicepFileName = Path.Combine(outputDirectory, Path.GetFileName(example.BicepStreamName)); var originalContents = File.ReadAllText(bicepFileName); var program = ParserHelper.Parse(originalContents); var printOptions = new PrettyPrintOptions(NewlineOption.LF, IndentKindOption.Space, 2, true); var formattedContents = PrettyPrinter.PrintProgram(program, printOptions); formattedContents.Should().NotBeNull(); File.WriteAllText(bicepFileName + ".formatted", formattedContents); originalContents.Should().EqualWithLineByLineDiffOutput( TestContext, formattedContents !, expectedLocation: example.BicepStreamName, actualLocation: bicepFileName + ".formatted"); }
public static void PrintEx(this object me, PrettyPrinter printer) { var printable = me as IPrintable; if (printer.BufferExceeded) { return; } if (printable != null) { printable.Print(printer); } else { switch (me) { case null: printer.Print("<null>"); break; case string _: printer.Print("\"" + me + "\""); break; case IEnumerable enumerable: { if (!printer.PrintContent) { break; } printer.Print("["); using (printer.IndentCookie()) { var en = enumerable.GetEnumerator(); var count = 0; var maxPrint = printer.CollectionMaxLength; while (en.MoveNext()) { if (printer.BufferExceeded) { return; } if (count < maxPrint) { printer.Println(); en.Current.PrintEx(printer); } count++; } if (count > maxPrint) { printer.Println(); printer.Print("... and " + (count - maxPrint) + " more"); } if (count > 0) { printer.Println(); } else { printer.Print("<empty>"); } } printer.Print("]"); break; } default: printer.Print(me.ToString()); break; } } }
public static string Print(TiState state) { var node = ShowState(state); return(PrettyPrinter.Display(node)); }
public static string Print(IEnumerable <TiState> states) { var node = Append(states.Select(ShowState).ToArray()); return(PrettyPrinter.Display(node)); }
private void editCodeActivity_Preview_ExecuteCode(object sender, EventArgs e) { IInlineFunction functionInfo = this.GetBinding <IInlineFunction>("Function"); string code = this.GetBinding <string>("FunctionCode"); List <string> selectedAssemblies = this.GetBinding <List <string> >("SelectedAssemblies"); StringInlineFunctionCreateMethodErrorHandler handler = new StringInlineFunctionCreateMethodErrorHandler(); MethodInfo methodInfo = InlineFunctionHelper.Create(functionInfo, code, handler, selectedAssemblies); FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); IFormFlowWebRenderingService formFlowWebRenderingService = serviceContainer.GetService <IFormFlowWebRenderingService>(); if (handler.HasErrors) { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrWhiteSpace(handler.MissingContainerType)) { AddFormattedTextBlock(sb, handler.MissingContainerType); } if (!string.IsNullOrWhiteSpace(handler.NamespaceMismatch)) { AddFormattedTextBlock(sb, handler.NamespaceMismatch); } if (!string.IsNullOrWhiteSpace(handler.MissionMethod)) { AddFormattedTextBlock(sb, handler.MissionMethod); } if (handler.LoadingException != null) { AddFormattedTextBlock(sb, handler.LoadingException.ToString()); } foreach (Tuple <int, string, string> compileError in handler.CompileErrors) { AddFormattedTextBlock(sb, "{0} : {1} : {2}".FormatWith(compileError.Item1, compileError.Item2, compileError.Item3)); } formFlowWebRenderingService.SetNewPageOutput(new LiteralControl(sb.ToString())); return; } List <ManagedParameterDefinition> parameters = this.GetBinding <List <ManagedParameterDefinition> >("Parameters"); List <object> parameterValues = new List <object>(); bool parameterErrors = false; StringBuilder parameterErrorMessages = new StringBuilder(); foreach (ParameterInfo parameterInfo in methodInfo.GetParameters()) { ManagedParameterDefinition parameter = parameters.FirstOrDefault(f => f.Name == parameterInfo.Name); if (parameter == null) { string message = string.Format(GetText("CSharpInlineFunction.MissingParameterDefinition"), parameterInfo.Name); parameterErrors = true; AddFormattedTextBlock(parameterErrorMessages, message); } else if (parameter.Type != parameterInfo.ParameterType) { string message = string.Format(GetText("CSharpInlineFunction.WrongParameterTestValueType"), parameterInfo.Name, parameterInfo.ParameterType, parameter.Type); parameterErrors = true; AddFormattedTextBlock(parameterErrorMessages, message); } else { string previewValueFunctionMarkup = (string.IsNullOrEmpty(parameter.TestValueFunctionMarkup) ? parameter.DefaultValueFunctionMarkup : parameter.TestValueFunctionMarkup); if (string.IsNullOrEmpty(previewValueFunctionMarkup)) { string message = string.Format(GetText("CSharpInlineFunction.MissingParameterTestOrDefaultValue"), parameterInfo.Name, parameterInfo.ParameterType, parameter.Type); parameterErrors = true; AddFormattedTextBlock(parameterErrorMessages, message); } else { try { BaseRuntimeTreeNode treeNode = FunctionFacade.BuildTree(XElement.Parse(previewValueFunctionMarkup)); object value = treeNode.GetValue(); object typedValue = ValueTypeConverter.Convert(value, parameter.Type); parameterValues.Add(typedValue); } catch (Exception ex) { string message = string.Format("Error setting '{0}'. {1}", parameterInfo.Name, ex.Message); parameterErrors = true; AddFormattedTextBlock(parameterErrorMessages, message); } } } } if (parameterErrors) { formFlowWebRenderingService.SetNewPageOutput(new LiteralControl(parameterErrorMessages.ToString())); return; } CultureInfo oldCurrentCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldCurrentUICulture = Thread.CurrentThread.CurrentUICulture; try { Guid pageId; if (this.GetBinding <object>("PageId") == null) { pageId = Guid.Empty; } else { pageId = this.GetBinding <Guid>("PageId"); } string dataScopeName = this.GetBinding <string>("PageDataScopeName"); string cultureName = this.GetBinding <string>("ActiveCultureName"); CultureInfo cultureInfo = null; if (cultureName != null) { cultureInfo = CultureInfo.CreateSpecificCulture(cultureName); } using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo)) { Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = cultureInfo; IPage page = DataFacade.GetData <IPage>(f => f.Id == pageId).FirstOrDefault(); if (page != null) { PageRenderer.CurrentPage = page; } object result = methodInfo.Invoke(null, parameterValues.ToArray()); string resultString; try { resultString = PrettyPrinter.Print(result); } catch (Exception ex) { throw new TargetInvocationException(ex); } SetOutput(formFlowWebRenderingService, resultString); } } catch (TargetInvocationException ex) { SetOutput(formFlowWebRenderingService, ex.InnerException.ToString()); } finally { Thread.CurrentThread.CurrentCulture = oldCurrentCulture; Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture; } }
// File Menu public void OnFileNew (object sender, EventArgs args) { currentfile = null; savename = null; asn = null; pp = null; appbar1.Default = String.Empty; UpdateDisplay (); findfwd = textview1.Buffer.StartIter; findbck = textview1.Buffer.EndIter; findstart = -1; findend = -1; OnFindEntryChange (sender, args); }
private void UpdateDisplay () { textview1.Buffer.Text = String.Empty; if (asn == null) { return; } if (pp == null) { pp = new PrettyPrinter(asn); } pp.Options = options; textview1.Buffer.Text = pp.ToString (); Highlight (findhighlight); findfwd = textview1.Buffer.StartIter; findbck = textview1.Buffer.EndIter; // process possible encapsulated ASN.1 element // (i.e. ASN.1 elements contained in other ASN.1 elements) if (options.IncludeEncapsulated) { TextIter start; TextIter end; TextIter search = textview1.Buffer.StartIter; while (search.ForwardSearch(", encapsulates {", tsf, out start, out end, textview1.Buffer.EndIter)) { start.ForwardChars (2); int num1 = 1; while (end.ForwardChar ()) { if (end.Char == "}") { num1--; if (num1 == 0) { end.ForwardChar (); break; } continue; } if (end.Char == "{") { num1++; } } textview1.Buffer.ApplyTag (encapsulated, start, end); search = end; } } else { textview1.Buffer.RemoveTag (encapsulated, textview1.Buffer.StartIter, textview1.Buffer.EndIter); } }