示例#1
0
        public static DataPath Parse(string text)
        {
            Guard.ArgumentNotNullOrEmptyString(text, "text");

            string[] parts = text.Split(':');

            if (parts.Length < 2)
            {
                throw new FormatException("String was not recognized as a valid data path");
            }

            string fromTable = parts[0];
            parts = parts[1].Split('!');
            int count = parts.Length;
            DataPath dataPath = new DataPath(fromTable, parts[count - 1]);

            for (int i = 0; i < count - 1; i++)
            {
                DataPathJoin join = DataPathJoin.Parse(fromTable, parts[i]);
                dataPath.Joins.Add(join);
                fromTable = join.ToTable;
            }

            return dataPath;
        }
示例#2
0
        public DataPath Reverse()
        {
            DataPath newDataPath = new DataPath(TargetTable, RootField);

            foreach (DataPathJoin join in _joins)
            {
                newDataPath._joins.Insert(0, new DataPathJoin(
                                                 join.ToTable,
                                                 join.ToField,
                                                 join.FromTable,
                                                 join.FromField));
            }

            return newDataPath;
        }