Пример #1
0
        /// <summary>
        /// The HotKeyMangaer detects, if a hotkey has been pressed in the given control object
        /// </summary>
        /// <param name="_control">The control on which the hotkeyManger should listen for hotkeys</param>
        public HotKeyHandler(Control _control)
        {
            // set the control
            this.control = _control;

            // initialze the eventhandler, which listens on key down events
            this.control.PreviewKeyDown += this.KeyDownEvent;

            // get all hotKey combinations
            this.hotKeys = ReflectionHandler.GetProperties <HotKeyT>();

            // get a instance of the hotKey class which contains all defined hotKeys
            this.hotKeyT = ReflectionHandler.GetInstance <HotKeyT>();
        }
Пример #2
0
        public static List <T> Get_FromData <T>(String _data, Char _seperator)
            where T : class
        {
            List <T> rows = new List <T>();

            List <PropertyInfo> properties = ReflectionHandler.GetProperties <T>();

            try
            {
                String[] row;
                Int32    valuesCount = new Int32();

                Int32 endIndex = new Int32();

                while ((endIndex = _data.IndexOf((Char)10)) != -1)
                {
                    row         = _data.Substring(0, endIndex).Split(_seperator);
                    valuesCount = row.Count <String>();

                    _data = _data.Remove(0, endIndex + 1);

                    T    tupel     = ReflectionHandler.GetInstance <T>();
                    Type tupelType = tupel.GetType();


                    for (Int32 i = new Int32(); i < valuesCount; i++)
                    {
                        PropertyInfo propertyInfo = tupelType.GetProperty(properties[i].Name);

                        Object value = CSVManager.getObject(row[i], propertyInfo.PropertyType);

                        propertyInfo.SetValue(tupel, value, null);
                    }

                    rows.Add(tupel);
                }
            }
            catch (IOException ioexeption)
            { System.Console.WriteLine(ioexeption.Message); }

            return(rows);
        }
Пример #3
0
        /// <summary>
        /// Reads and splits the given csv file
        /// </summary>
        /// <param name="_csvData">The data to split</param>
        /// <param name="_seperator">The char which is the seperator between the values</param>
        /// <returns>A List which contains the rows as T Object</returns>
        public static List <T> Get_FromFile <T>(String _filePath, Char _seperator)
            where T : class
        {
            List <T> rows = new List <T>();

            List <PropertyInfo> properties = ReflectionHandler.GetProperties <T>();

            using (StreamReader streamReader = new StreamReader(_filePath))
            {
                try
                {
                    String[] row;
                    Int32    valuesCount = new Int32();

                    while (streamReader.Peek() != -1)
                    {
                        row         = streamReader.ReadLine().Split(_seperator);
                        valuesCount = row.Count <String>();

                        T    tupel     = ReflectionHandler.GetInstance <T>();
                        Type tupelType = tupel.GetType();

                        for (Int32 i = new Int32(); i < valuesCount; i++)
                        {
                            PropertyInfo propertyInfo = tupelType.GetProperty(properties[i].Name);

                            Object value = CSVManager.getObject(row[i], propertyInfo.PropertyType);

                            propertyInfo.SetValue(tupel, value, null);
                        }

                        rows.Add(tupel);
                    }
                }

                catch (IOException ioexeption)
                { System.Console.WriteLine(ioexeption.Message); }
            }

            return(rows);
        }