Ejemplo n.º 1
0
            public static bool TryParse(string str, out Column column)
            {
                column = null;

                if (string.IsNullOrEmpty(str))
                {
                    return(false);
                }

                if (!ColumnParsingUtils.TryParse(str, out string name, out string sourceStr, out string kindStr))
                {
                    return(false);
                }

                DataKind?kind = null;

                if (kindStr != null && TypeParsingUtils.TryParseDataKind(kindStr, out DataKind parsedKind, out KeyRange range))
                {
                    kind = parsedKind;
                }

                if (!int.TryParse(sourceStr, out int source))
                {
                    return(false);
                }

                column = new Column()
                {
                    Name   = name,
                    Source = source,
                    Type   = kind
                };

                return(true);
            }
Ejemplo n.º 2
0
            protected override bool TryParse(string str)
            {
                Contracts.AssertNonEmpty(str);

                // We accept N:T:S where N is the new column name, T is the new type,
                // and S is source column names.
                string extra;

                if (!base.TryParse(str, out extra))
                {
                    return(false);
                }
                if (extra == null)
                {
                    return(true);
                }

                DataKind kind;

                if (!TypeParsingUtils.TryParseDataKind(extra, out kind, out KeyRange))
                {
                    return(false);
                }
                ResultType = kind == default(DataKind) ? default(DataKind?) : kind;
                return(true);
            }