Ejemplo n.º 1
0
        public ButtonEvent[] GetAll()
        {
            var result = new ArrayList();

            if (File.Exists(_filePath))
            {
                lock (_sync)
                {
                    using (TextReader reader = new StreamReader(_filePath))
                    {
                        for (;;)
                        {
                            string line = reader.ReadLine();
                            if (line == null)
                            {
                                break;
                            }

                            ButtonEvent item = ButtonEventConverter.ToEntity(line);
                            result.Add(item);
                        }
                    }
                }
            }

            return((ButtonEvent[])result.ToArray(typeof(ButtonEvent)));
        }
Ejemplo n.º 2
0
        public void Add(ButtonEvent buttonEvent)
        {
            string content = ButtonEventConverter.ToString(buttonEvent);

            lock (_sync)
            {
                using (TextWriter writer = new StreamWriter(_filePath, true))
                {
                    writer.WriteLine(content);
                }
            }
        }