Beispiel #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);
            }
 /// <summary>
 /// For parsing from a string. This supports "name" and "name:source" and "name:extra:source". For the last
 /// form, the out extra parameter is sort accordingly. For the other forms, extra is set to null.
 /// Derived classes that want to provide parsing functionality to the CmdParser need to implement
 /// a static Parse method. That method can call this (directly or indirectly) to handle the supported
 /// syntax.
 /// </summary>
 protected bool TryParse(string str, out string extra)
 {
     Contracts.AssertNonEmpty(str);
     return(ColumnParsingUtils.TryParse(str, out Name, out Source, out extra));
 }
 /// <summary>
 /// For parsing from a string. This supports "name" and "name:source".
 /// Derived classes that want to provide parsing functionality to the CmdParser need to implement
 /// a static Parse method. That method can call this (directly or indirectly) to handle the supported
 /// syntax.
 /// </summary>
 protected virtual bool TryParse(string str)
 {
     Contracts.AssertNonEmpty(str);
     return(ColumnParsingUtils.TryParse(str, out Name, out Source));
 }