/// <summary> /// Parses the specified identifier. /// the string format is as follows: /// key1:value1|key2:value2|key3:value3|... /// IMPORTANT: this method depends on EnumTextAttribute class and /// hence all IdFields texts have to be used first. /// </summary> /// <param name="identifier">The identifier.</param> /// <returns> /// A <see cref="PaperBallotIdentifier" /> containing the specified /// identifier. /// </returns> /// <externalUnit/> /// <revision revisor="dev11" date="12/24/2008" version="1.0.0.0"> /// Member Created /// </revision> public static PaperBallotIdentifier Parse(string identifier) { PaperBallotIdentifier pbiId = new PaperBallotIdentifier(); string[] pairs = identifier.Split(SepMajor), pair; IdField key; foreach (string strPair in pairs) { pair = strPair.Split(SepMinor); if (pair.Length != 2) { continue; } try { key = (IdField)EnumTextAttribute.GetValue(pair[0]); pbiId.Set(key, pair[1]); } catch (Exception) { // simply ignore the exception and drop the current field // since the field is not supported or is mispelled } } return(pbiId); }
/// <summary> /// Clones this instance. /// </summary> /// <returns> /// A clone of the <see cref="PaperBallotIdentifier'" />. /// </returns> /// <externalUnit cref="fieldMap"/> /// <externalUnit cref="KeyValuePair{TKey,TValue}"/> /// <externalUnit cref="PaperBallotIdentifier"/> /// <revision revisor="dev11" date="2/25/2009" version="1.0.8.0801"> /// Member Created /// </revision> public PaperBallotIdentifier Clone() { PaperBallotIdentifier identifier = new PaperBallotIdentifier(); foreach (KeyValuePair <IdField, object> pair in this.fieldMap) { identifier.Set(pair.Key, pair.Value); } return(identifier); }