/// <summary> /// Return an object holding the CsvString value. /// </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.NameBraced) { string braceName = mCsr.Word.BraceName; if (braceName == "_qv") { WordValue vlu = mCsr.Word.BracedValue; return(vlu.DequotedWord); } // 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.BracedValue.ToString( ); return(vlu.ToStringArray( )); } // is a string of comma seperated values. else if (braceName == "_csv") { CsvString vlu = new CsvString( ); vlu.String = mCsr.Word.BracedValue.ToString( ); return(vlu); } else { return(mCsr.Word.BracedValue.ToString( )); } } else { return(mCsr.Word.ToString( )); } }
/// <summary> /// Add a comma separated value string as a value to this CsvString. Will enclose /// the value in paren, then add the value as a string. /// </summary> /// <param name="InValue"></param> /// <returns></returns> public CsvString Add(CsvString InValue) { if (InValue == null) { string Value = null; AddString(Value); // will add an empty value. } else { StringBuilder sb = new StringBuilder( ); sb.Append("_csv("); sb.Append(InValue.ToString( )); sb.Append(")"); AddString(sb.ToString( )); } return(this); }