コード例 #1
0
ファイル: DataModifier.cs プロジェクト: orlovk/PtProject
        public DataModifier(string[] rows)
        {
            var result = new Dictionary<string, ExprDesc>();

            int idx = 0;
            foreach (string row in rows)
            {
                if (row == null) continue;
                string trow = row.Trim();
                if (trow.StartsWith("#")) continue;
                if (string.IsNullOrWhiteSpace(trow)) continue;
                string[] blocks = trow.Split(';');

                string expr = blocks[0];
                if (string.IsNullOrWhiteSpace(expr)) continue;

                var descr = new ExprDesc();
                descr.ExprStr = expr;
                descr.Idx = idx;
                descr.Alias = blocks.Length >= 2 ? (string.IsNullOrWhiteSpace(blocks[1]) ? null : blocks[1]) : null;

                if (!result.ContainsKey(expr))
                    result.Add(expr, descr);
                else
                    throw new Exception("duplicate expr: " + expr);
            }

            Fields = result;
        }
コード例 #2
0
        public DataModifier(string[] rows)
        {
            var result = new Dictionary <string, ExprDesc>();

            int idx = 0;

            foreach (string row in rows)
            {
                if (row == null)
                {
                    continue;
                }
                string trow = row.Trim();
                if (trow.StartsWith("#"))
                {
                    continue;
                }
                if (string.IsNullOrWhiteSpace(trow))
                {
                    continue;
                }
                string[] blocks = trow.Split(';');

                string expr = blocks[0];
                if (string.IsNullOrWhiteSpace(expr))
                {
                    continue;
                }

                var descr = new ExprDesc(expr);
                descr.Idx   = idx;
                descr.Alias = blocks.Length >= 2 ? (string.IsNullOrWhiteSpace(blocks[1]) ? null : blocks[1]) : null;

                if (!result.ContainsKey(expr))
                {
                    result.Add(expr, descr);
                }
                else
                {
                    throw new Exception("duplicate expr: " + expr);
                }
            }

            Fields = result;
        }