/// <summary> /// Creates a new decoder to parse XML archives /// created by the {@code XMLEncoder} class. /// </summary> /// <param name="is"> the input source to parse </param> /// <param name="owner"> the owner of this decoder </param> /// <param name="el"> the exception handler for the parser, /// or {@code null} to use the default exception handler </param> /// <param name="cl"> the class loader used for instantiating objects, /// or {@code null} to use the default class loader /// /// @since 1.7 </param> private XMLDecoder(InputSource @is, Object owner, ExceptionListener el, ClassLoader cl) { this.Input = @is; this.Owner_Renamed = owner; ExceptionListener = el; this.Handler.ClassLoader = cl; this.Handler.Owner = this; }
/// <summary> /// Creates a new handler for SAX parser /// that can be used to parse embedded XML archives /// created by the {@code XMLEncoder} class. /// /// The {@code owner} should be used if parsed XML document contains /// the method call within context of the <java> element. /// The {@code null} value may cause illegal parsing in such case. /// The same problem may occur, if the {@code owner} class /// does not contain expected method to call. See details <a /// href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">here</a>. /// </summary> /// <param name="owner"> the owner of the default handler /// that can be used as a value of <java> element </param> /// <param name="el"> the exception handler for the parser, /// or {@code null} to use the default exception handler </param> /// <param name="cl"> the class loader used for instantiating objects, /// or {@code null} to use the default class loader </param> /// <returns> an instance of {@code DefaultHandler} for SAX parser /// /// @since 1.7 </returns> public static DefaultHandler CreateHandler(Object owner, ExceptionListener el, ClassLoader cl) { DocumentHandler handler = new DocumentHandler(); handler.Owner = owner; handler.ExceptionListener = el; handler.ClassLoader = cl; return(handler); }
/*异常错误回调接口*/ void IEccExceptionListener.Ecc_BreakOff(Exception ex) { if (ExceptionListener != null) { ExceptionListener.Ecc_BreakOff(ex); return; } //code... }
void IEccExceptionListener.Ecc_ConnectionFail(SocketException ex) { if (ExceptionListener != null) { ExceptionListener.Ecc_ConnectionFail(ex); return; } //code... }
private static void CommandADB(string r) { try { var cmd = r.Replace("adb ", ""); TastyScript.Main.IO.Print("This command does not currently work as expected."); } catch (Exception e) { ExceptionListener.LogThrow("Unexpected error", e); } }
private static void CommandConnect(string r) { try { TastyScript.Main.AndroidDriver = new Driver(r); } catch (Exception e) { if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
/// <summary> /// This method calls <code>flush</code>, writes the closing /// postamble and then closes the output stream associated /// with this stream. /// </summary> public virtual void Close() { Flush(); Writeln("</java>"); try { @out.Close(); } catch (IOException e) { ExceptionListener.ExceptionThrown(e); } }
private void Close(Closeable @in) { if (@in != null) { try { @in.Close(); } catch (IOException e) { ExceptionListener.ExceptionThrown(e); } } }
private void InitializeWithDTEAndSolutionReady() { m_dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE)); if (m_dte == null) { ErrorHandler.ThrowOnFailure(1); } var solutionBase = ""; var solutionName = ""; if (m_dte.Solution != null) { solutionBase = System.IO.Path.GetDirectoryName(m_dte.Solution.FullName); solutionName = System.IO.Path.GetFileNameWithoutExtension(m_dte.Solution.FullName); } //string dbName = string.Format("Ganji.History-{0}.sdf", solutionName); var basePath = PreparePath(); var ganjiContext = new GanjiContext(); ganjiContext.RepositoryPath = System.IO.Path.Combine(basePath, "LocalHistory"); ganjiContext.SolutionPath = solutionBase; CodeElementMagic.m_applicationObject = m_dte; HistoryContext.ConfigureDatabase(basePath); RemindersContext.ConfigureDatabase(basePath); SessionsContext.ConfigureDatabase(basePath); m_saveListener = new SaveListener(); m_saveListener.Register(m_dte, ganjiContext); m_navigateListener = new NavigateListener(); m_navigateListener.Register(m_dte, ganjiContext); m_exceptionListener = new ExceptionListener(); m_exceptionListener.Register(m_dte, ganjiContext); //if (m_version != null) //{ // dbName = string.Format("ActivityDB{0}-{1}.sdf", m_version.ToString(),solutionName); //} //var basePath = PreparePath(); //var path = System.IO.Path.Combine(basePath, dbName); //database = new Database(path); //database.OpenOrCreate(); }
/// <summary> /// This method writes out the preamble associated with the /// XML encoding if it has not been written already and /// then writes out all of the values that been /// written to the stream since the last time <code>flush</code> /// was called. After flushing, all internal references to the /// values that were written to this stream are cleared. /// </summary> public virtual void Flush() { if (!PreambleWritten) // Don't do this in constructor - it throws ... pending. { if (this.Declaration) { Writeln("<?xml version=" + Quote("1.0") + " encoding=" + Quote(this.Charset) + "?>"); } Writeln("<java version=" + Quote(System.getProperty("java.version")) + " class=" + Quote(typeof(XMLDecoder).Name) + ">"); PreambleWritten = true; } Indentation++; List <Statement> statements = StatementList(this); while (statements.Count > 0) { Statement s = statements.Remove(0); if ("writeObject".Equals(s.MethodName)) { OutputValue(s.Arguments[0], this, true); } else { OutputStatement(s, this, false); } } Indentation--; Statement statement = MissedStatement; while (statement != null) { OutputStatement(statement, this, false); statement = MissedStatement; } try { @out.Flush(); } catch (IOException e) { ExceptionListener.ExceptionThrown(e); } Clear(); }
public static void CommandExec(string r) { try { Init(); var cmd = r.Replace("exec ", "").Replace("-e ", ""); var file = "override.Start(){\n" + cmd + "}"; var path = "AnonExecCommand.ts"; TokenParser.SleepDefaultTime = 1200; TokenParser.Stop = false; StartScript(path, file); } catch (Exception e) { if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
private void Writeln(String exp) { try { StringBuilder sb = new StringBuilder(); for (int i = 0; i < Indentation; i++) { sb.Append(' '); } sb.Append(exp); sb.Append('\n'); [email protected](sb.ToString()); } catch (IOException e) { ExceptionListener.ExceptionThrown(e); } }
/// <summary> /// Records the Statement so that the Encoder will /// produce the actual output when the stream is flushed. /// <P> /// This method should only be invoked within the context /// of initializing a persistence delegate. /// </summary> /// <param name="oldStm"> The statement that will be written /// to the stream. </param> /// <seealso cref= java.beans.PersistenceDelegate#initialize </seealso> public override void WriteStatement(Statement oldStm) { // System.out.println("XMLEncoder::writeStatement: " + oldStm); bool @internal = this.@internal; this.@internal = true; try { base.WriteStatement(oldStm); /* * Note we must do the mark first as we may * require the results of previous values in * this context for this statement. * Test case is: * os.setOwner(this); * os.writeObject(this); */ Mark(oldStm); Object target = oldStm.Target; if (target is Field) { String method = oldStm.MethodName; Object[] args = oldStm.Arguments; if ((method == null) || (args == null)) { } else if (method.Equals("get") && (args.Length == 1)) { target = args[0]; } else if (method.Equals("set") && (args.Length == 2)) { target = args[0]; } } StatementList(target).Add(oldStm); } catch (Exception e) { ExceptionListener.ExceptionThrown(new Exception("XMLEncoder: discarding statement " + oldStm, e)); } this.@internal = @internal; }
private static void CommandShell(string r) { try { if (TastyScript.Main.AndroidDriver != null) { TastyScript.Main.IO.Print($"Result: {TastyScript.Main.AndroidDriver.SendShellCommand(r.Replace("shell ", "").Replace("-sh ", ""))}"); } else { TastyScript.Main.Throw(new ExceptionHandler(ExceptionType.DriverException, "Device must be defined")); } } catch (Exception e) { if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
private static void CommandApp(string r) { try { if (TastyScript.Main.AndroidDriver != null) { TastyScript.Main.AndroidDriver.SetAppPackage(r); } else { TastyScript.Main.Throw(new ExceptionHandler(ExceptionType.DriverException, "Device must be defined")); } } catch (Exception e) { if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
private static void CommandScreenshot(string r) { try { if (TastyScript.Main.AndroidDriver != null) { var ss = TastyScript.Main.AndroidDriver.GetScreenshot(); ss.Result.Save(r, ImageFormat.Png); } else { TastyScript.Main.Throw(new ExceptionHandler(ExceptionType.DriverException, "Device must be defined")); } } catch (Exception e) { if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
private static void DirectRun(string r) { try { var path = r.Replace("\'", "").Replace("\"", ""); var file = Utilities.GetFileFromPath(path); TokenParser.SleepDefaultTime = 1200; TokenParser.Stop = false; StartScript(path, file); } catch (Exception e) { //if loglevel is throw, then compilerControledException gets printed as well //only for debugging srs issues if (!(e is CompilerControledException) || Settings.LogLevel == "throw") { ExceptionListener.LogThrow("Unexpected error", e); } } }
public void InitializeStartApp() { _appThemes.LoadTheme(); _mainWindow.Title = Constants.AppName; if (Constants.AppPath.Contains("beta")) { AlarmText = $"BETA CHANNEL / v{ Constants.AppVersion } / { Environment.MachineName }"; } if (Constants.AppPath.Contains("test build")) { AlarmText = $"TEST BUILD / v{ Constants.AppVersion } / { Environment.MachineName }"; } if (Constants.AppPath.Contains("Elektrum.Master")) { AlarmText = $"dev build / compiled { File.GetLastWriteTime(Constants.AppAssemblyPath).ToShortDateString() } { File.GetLastWriteTime(Constants.AppAssemblyPath).ToShortTimeString() } ({ (DateTime.Now - File.GetLastWriteTime(Constants.AppAssemblyPath)).Hours }h { (DateTime.Now - File.GetLastWriteTime(Constants.AppAssemblyPath)).Minutes }m ago) / v{ Constants.AppVersion } / { Environment.MachineName }"; } new PathChecker().CheckPath(); new RegistryChecker().UpdateMasterPaths(); new RegistryChecker().RegistryFileExtension(); new FontsChecker().CheckFonts(this); if (!Debugger.IsAttached) { ExceptionListener.StartListening(Logger.W, Dispatcher); } if (Common.AppData.WorkMode == WorkMode.Project) { if (_mainBlockViewModel == null) { _commonData.ProductType = ProductType.Continent_RP; CreateSubstation(); } Mouse.OverrideCursor = Cursors.Wait; if (Common.AppData.LineArgs.From != null) { Diser(Common.AppData.LineArgs.From); } else { ShowWelcome(); } Mouse.OverrideCursor = null; } else if (Common.AppData.WorkMode == WorkMode.Master) { // грузим файл из 1С // обрати внимание что _commonData.ProductType уже содержит выбранное изделие в 1С, см. строку 202 //Wrapper.ShowNotify("Получили команду из 1С создать новый проект для изделия " + _commonData.ProductType); _commonData.ProductType = ProductType.NA; ShowWelcome(); } else if (Common.AppData.WorkMode == WorkMode.File) { // грузим файл из проводника, путь к нему в Common.AppData.LineArgs.FileName Wrapper.ShowNotify("Получили команду из проводника загрузить файл " + Common.AppData.LineArgs.FileName); Mouse.OverrideCursor = Cursors.Wait; if (_mainBlockViewModel == null) { _commonData.ProductType = ProductType.Continent_RP; CreateSubstation(); } Diser(Common.AppData.LineArgs.FileName); Mouse.OverrideCursor = null; } else { ShowWhatsnew(); ShowWelcome(); } }
/// <summary> /// Creates a new input stream for reading archives /// created by the <code>XMLEncoder</code> class. /// </summary> /// <param name="in"> the underlying stream. <code>null</code> may be passed without /// error, though the resulting XMLDecoder will be useless </param> /// <param name="owner"> the owner of this stream. <code>null</code> is a legal /// value </param> /// <param name="exceptionListener"> the exception handler for the stream, or /// <code>null</code> to use the default </param> /// <param name="cl"> the class loader used for instantiating objects. /// <code>null</code> indicates that the default class loader should /// be used /// @since 1.5 </param> public XMLDecoder(InputStream @in, Object owner, ExceptionListener exceptionListener, ClassLoader cl) : this(new InputSource(@in), owner, exceptionListener, cl) { }
public static void NewWaitForCommand() { while (true) { _consoleCommand = ""; TastyScript.Main.IO.Print("\nSet your game to correct screen and then type run 'file/directory'\n", ConsoleColor.Green); TastyScript.Main.IO.Print('>', false); var r = ""; try { _cancelSource = new CancellationTokenSource(); r = Reader.ReadLine(_cancelSource.Token); } catch (OperationCanceledException e) {} catch (Exception e) { ExceptionListener.LogThrow("Unexpected error", e); } if (_consoleCommand != "") { r = _consoleCommand; } var split = r.Split(' '); var userInput = ""; if (split.Length > 1) { userInput = r.Replace(split[0] + " ", ""); } switch (split[0]) { case ("adb"): CommandADB(userInput); break; case ("app"): CommandApp(userInput); break; case ("-c"): case ("connect"): CommandConnect(userInput); break; case ("-d"): case ("devices"): CommandDevices(userInput); break; case ("dir"): CommandDir(userInput); break; case ("-e"): case ("exec"): TastyScript.Main.CommandExec(userInput); break; case ("-h"): case ("help"): CommandHelp(userInput); break; case ("-ll"): case ("loglevel"): CommandLogLevel(userInput); break; case ("remote"): CommandRemote(userInput); break; case ("-r"): case ("run"): TastyScript.Main.CommandRun(userInput); break; case ("-ss"): case ("screenshot"): CommandScreenshot(userInput); break; case ("-sh"): case ("shell"): CommandShell(userInput); break; default: TastyScript.Main.IO.Print("Enter '-h' for a list of commands!"); break; } } }
private void AsyncCallExceptionListener(Object error) { var exception = error as StompException; ExceptionListener?.Invoke(exception); }
/// <summary> /// Creates a new input stream for reading archives /// created by the <code>XMLEncoder</code> class. /// </summary> /// <param name="in"> the underlying stream. </param> /// <param name="owner"> the owner of this stream. </param> /// <param name="exceptionListener"> the exception handler for the stream; /// if <code>null</code> the default exception listener will be used. </param> public XMLDecoder(InputStream @in, Object owner, ExceptionListener exceptionListener) : this(@in, owner, exceptionListener, null) { }