Пример #1
0
        protected void messageReceived(ConnectionEventArgs a)
        {
            PUC.Communication.Message msg = a.GetMessage();

            if (msg is DeviceSpec)
            {
                DeviceSpec dmsg = (DeviceSpec)msg;

                Appliance appl = new Appliance(this);

#if POCKETPC
                Globals.AddFrameMapping(appl, PUCFrame.DEFAULT_FRAME);
#endif
#if SMARTPHONE
                Globals.AddFrameMapping(appl, PhonePUC.PUCFrame.DEFAULT_FRAME);
#endif
#if DESKTOP && !DEBUGSVR
                // TODO: Make DesktopPUC use multiple windows, like Debug Server
                Globals.AddFrameMapping(appl, DesktopPUC.PUCFrame.DEFAULT_FRAME);
#endif

                try
                {
                    SpecParser.Parse(new StringReader(dmsg.GetSpec()), appl);

                    MenuItem mi = new MenuItem();
                    mi.Text = appl.Name;
                    appl.SetMenuItem(mi);

                    _server.ActivateAppliance(this, appl);

                    Cursor.Current = Cursors.Default;

                    _connection.MessageReceivedEvent    -= new Connection.MessageReceivedHandler(this.messageReceived);
                    _connection.ConnectionRegainedEvent -= new Connection.ConnectionRegainedHandler(this.connectionRegained);
                    _connection.ConnectionLostEvent     += new Connection.ConnectionLostHandler(appl.ConnectionLost);
                    _connection.MessageReceivedEvent    += new Connection.MessageReceivedHandler(appl.MessageReceived);
                    _connection.ConnectionRegainedEvent += new Connection.ConnectionRegainedHandler(appl.ConnectionRegained);

                    FullStateRequest fsrMsg = new FullStateRequest();
                    _connection.Send(fsrMsg);
                }
                catch (Exception e)
                {
                    Globals.GetFrame(appl).AddLogLine(e.ToString());
                    Cursor.Current = Cursors.Default;
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                var    specParser = new SpecParser();
                var    errorCount = 0;
                string outputFile = args[1] + ".output.csv";
                using (var sr = new StreamReader(args[0]))
                    using (var data = new FileStream(args[1], FileMode.Open, FileAccess.Read))
                        using (var output = new StreamWriter(args[1] + ".output.csv"))
                        {
                            var importer = new Importer(specParser.Parse(sr));
                            var listener = new CsvOutputListener(output);
                            importer.Import(data, listener);
                            listener.Task.Wait();
                            errorCount = listener.Errors;
                        }
                if (errorCount > 0)
                {
                    File.Delete(outputFile);
                    WriteLine("No output created.");
                }
                else
                {
                    WriteLine($"Output in in \"{outputFile}\"");
                }
            }
            catch (Exception ex)
            {
                WriteLine($"Error: {ex.Message}");
            }
#if DEBUG
            WriteLine("Press any key to continue");
            ReadKey();
#endif
        }
Пример #3
0
 public void Parse_RecognisesTrimFilterByDefault()
 {
     var spec = _parser.Parse(new StringReader("Import:\n  Line Classes:\n    - Foo:\n        Extract:\n          Field1: Column A | Trim"));
 }