Пример #1
0
            /// <summary>
            /// Return an object holding the CsvString value.
            /// Object can be a string, CsvString or string[].
            /// </summary>
            /// <returns></returns>
            public object ToObject( )
            {
                if (IsAtValue == false)
                {
                    return(null);
                }
                else if (mAtFinalEmptyValue == true)
                {
                    return(null);
                }
                else if (mCsr.Word == null)
                {
                    return(null);
                }
                else if (mCsr.Word.Class == WordClassification.NamedBraced)
                {
                    string braceName = mCsr.Word.BraceName;
                    if (braceName == "_qv")
                    {
                        string text = mCsr.Word.BracedText;
                        return(Stringer.Dequote(text, mCsr.TextTraits.QuoteEncapsulation));
                    }

                    // a string[] is stored as a sequence of strings in CsvString form.
                    else if (braceName == "_sa")                        // string array
                    {
                        CsvString vlu = new CsvString( );
                        vlu.String = mCsr.Word.BracedText;
                        return(vlu.ToStringArray( ));
                    }

                    // is a string of comma seperated values.
                    else if (braceName == "_csv")
                    {
                        CsvString vlu = new CsvString( );
                        vlu.String = mCsr.Word.BracedText;
                        return(vlu);
                    }

                    else
                    {
                        return(mCsr.Word.BracedText);
                    }
                }
                else
                {
                    return(mCsr.Word.ToString( ));
                }
            }
Пример #2
0
 /// <summary>
 /// Return the encapsulated value in string form.
 /// </summary>
 /// <returns></returns>
 public override string ToString( )
 {
     if (IsAtValue == false)
     {
         return(null);
     }
     else if (mAtFinalEmptyValue == true)
     {
         return(null);
     }
     else if (mCsr.Word == null)
     {
         return("");
     }
     else if (mCsr.Word.Class == WordClassification.NamedBraced)
     {
         string braceName = mCsr.Word.BraceName;
         if (braceName == "_qv")
         {
             string text = mCsr.Word.BracedText;
             return(Stringer.Dequote(text, mCsr.TextTraits.QuoteEncapsulation));
         }
         else
         {
             return(mCsr.Word.BracedText);
         }
     }
     else if (mCsr.Word.IsQuoted == true)
     {
         return(mCsr.Word.DequotedValue);
     }
     else
     {
         return(mCsr.Word.Value);
     }
 }