Esempio n. 1
0
        public static object Load(Type _type, List <MekaItem> _data)
        {
            object @out = _type.GetConstructor(new Type[0]).Invoke(new object[0]);

            Bunch <FieldInfo> fs = _type.GetFields();

            Dictionary <string, object> ps = Load(_type.GetFields().ToDictionary(item => item.Name, item => item.FieldType), _data);

            foreach (MekaItem item in _data)
            {
                if (fs.Any(f => f.Name == item.Name))
                {
                    _type.GetField(item.Name).SetValue(@out, ps[item.Name]);
                }
            }

            return(@out);
        }
Esempio n. 2
0
        public File(string _path, string _localto = null)
        {
            string p = System.IO.Path.GetFullPath(_path);

            this.Path = p;
            this.Name = System.IO.Path.GetFileNameWithoutExtension(p);
            string ext = System.IO.Path.GetExtension(p);

            this.Extension = (ext == "") ? "" : ext.Substring(1);

            this.Directories = new Bunch <string>();
            if (_localto != null && p.Contains(_localto))
            {
                p = p.Substring(_localto.Length + ((_localto.Last() == '\\') ? 0 : 1));
            }
            string[] ds = p.Split('\\');
            for (int i = 0; i < ds.Length - 1; i++)
            {
                this.Directories.Add(ds[i]);
            }

            while (Directories.Any(item => item[0] == '#'))
            {
                Directories.Remove(Directories.First(item => item[0] == '#'));
            }

            //if (_localto != null)
            //{
            //	this.Directories = new Bunch<string>();
            //	if (p.Contains(_localto))
            //	{
            //		p = p.Substring(_localto.Length);
            //		string[] ds = p.Split('\\');
            //		for (int i = 0; i < ds.Length - 1; i++)
            //			this.Directories.Add(ds[i]);
            //	}
            //}

            //string assembly = Assembly.GetCallingAssembly().Location.Substring(0, Assembly.GetCallingAssembly().Location.Length - System.IO.Path.GetFileName(Assembly.GetCallingAssembly().Location).Length);
        }
Esempio n. 3
0
        public void Apply(RichText _text)
        {
            string inrange    = null;
            int    rangestart = 0;

            for (int i = 0; i < _text.Content.Length; i++)
            {
                if (inrange == null)
                {
                    Bunch <Tuple <ColorPattern, int> > symbols = new Bunch <Tuple <ColorPattern, int> >();
                    foreach (ColorPattern pattern in this.Patterns)
                    {
                        symbols.Add(new Tuple <ColorPattern, int>(pattern, pattern.GetLength(_text.Content.Substring(i))));
                    }

                    if (symbols.Any(item => item.Item2 > 0))
                    {
                        Tuple <ColorPattern, int> t = symbols.OrderByDescending(item => item.Item2)[0];                       //this.Patterns.First(item => item.Symbols.Contains(symbol));

                        ColorPattern p = t.Item1;
                        int          l = t.Item2;

                        if (p.Range)
                        {
                            inrange    = p.Symbols[0];
                            rangestart = i;
                        }
                        else
                        {
                            _text.ColorIn(p.Color, i, l);
                        }

                        i += l - 1;
                    }
                    //else
                    //{
                    //	List<ColorPattern> ps = this.Patterns.Where(item => item.Func != null && item.Func(_text.Content.Substring(i))).ToList();
                    //	if (ps.Count > 0)
                    //	{

                    //	}
                    //}
                }
                else
                {
                    Bunch <Tuple <ColorPattern, int> > ps = new Bunch <Tuple <ColorPattern, int> >();
                    foreach (ColorPattern p in this.Patterns.Where(item => item.Range && item.Symbols[0] == inrange))
                    {
                        ps.Add(new Tuple <ColorPattern, int>(p, p.GetLength2(_text.Content.Substring(i))));
                    }

                    if (ps.Any(item => item.Item2 > 0))
                    {
                        _text.ColorIn(ps.OrderByDescending(item => item.Item2)[0].Item1.Color, rangestart, i - rangestart + 1);
                        inrange = null;
                    }
                }
            }

            if (inrange != null)
            {
                Bunch <ColorPattern> ps = this.Patterns.Where(item => item.Range && item.Symbols[0] == inrange && item.EndLine);
                if (ps.Count > 0)
                {
                    _text.ColorIn(ps[0].Color, rangestart, _text.Content.Length - 1 - rangestart + 1);
                }
            }
        }