//===================================================================== /// <summary> /// This is overridden to allow cloning of a PDI object /// </summary> /// <returns>A clone of the object</returns> public override object Clone() { NoteProperty o = new NoteProperty(); o.Clone(this); return(o); }
/// <summary> /// This is implemented to handle properties as they are parsed from the data stream /// </summary> /// <param name="propertyName">The name of the property.</param> /// <param name="parameters">A string collection containing the parameters and their values. If empty, /// there are no parameters.</param> /// <param name="propertyValue">The value of the property.</param> /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string /// collection. It is up to the derived class to process the parameter list based on the specification /// to which it conforms. For entries that are parameter names, the entry immediately following it in /// the collection is its associated parameter value. The property name, parameter names, and their /// values may be in upper, lower, or mixed case.</para> /// /// <para>The value may be an encoded string. The properties are responsible for any decoding that may /// need to occur (i.e. base 64 encoded image data).</para></remarks> /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data /// stream. Refer to the and inner exceptions for information on the cause of the problem.</exception> protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue) { SpecificationVersions version = SpecificationVersions.None; string temp, group = null; int idx; // Parse out the group name if there is one idx = propertyName.IndexOf('.'); if (idx != -1) { group = propertyName.Substring(0, idx).Trim(); propertyName = propertyName.Substring(idx + 1).Trim(); } // The last entry is always CustomProperty so scan for length minus one for (idx = 0; idx < ntv.Length - 1; idx++) { if (ntv[idx].IsMatch(propertyName)) { break; } } // An opening BEGIN:VCARD property must have been seen if (currentCard == null && ntv[idx].EnumValue != PropertyType.Begin) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VCARD", propertyName)); } // Handle or create the property switch (ntv[idx].EnumValue) { case PropertyType.Begin: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // NOTE: If serializing into an existing instance, this may not be null. If so, it is // ignored. if (currentCard == null) { currentCard = new VCard(); vCards.Add(currentCard); } currentCard.Group = group; break; case PropertyType.End: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } // The group must match too if (currentCard.Group != group) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnexpectedGroupTag", currentCard.Group, group)); } // When done, we'll propagate the version number to all objects to make it consistent currentCard.PropagateVersion(); // The vCard is added to the collection when created so we don't have to rely on an END:VCARD // to add it. currentCard = null; break; case PropertyType.Profile: // The value must be VCARD if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); } currentCard.AddProfile = true; break; case PropertyType.Version: // Version must be 2.1 or 3.0 temp = propertyValue.Trim(); if (temp == "2.1") { version = SpecificationVersions.vCard21; } else if (temp == "3.0") { version = SpecificationVersions.vCard30; } else { throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion", "vCard", temp)); } currentCard.Version = version; break; case PropertyType.MimeName: currentCard.MimeName.EncodedValue = propertyValue; break; case PropertyType.MimeSource: currentCard.MimeSource.DeserializeParameters(parameters); currentCard.MimeSource.EncodedValue = propertyValue; break; case PropertyType.ProductId: currentCard.ProductId.EncodedValue = propertyValue; break; case PropertyType.Nickname: currentCard.Nickname.DeserializeParameters(parameters); currentCard.Nickname.EncodedValue = propertyValue; currentCard.Nickname.Group = group; break; case PropertyType.SortString: currentCard.SortString.DeserializeParameters(parameters); currentCard.SortString.EncodedValue = propertyValue; currentCard.SortString.Group = group; break; case PropertyType.Class: currentCard.Classification.EncodedValue = propertyValue; currentCard.Classification.Group = group; break; case PropertyType.Categories: currentCard.Categories.DeserializeParameters(parameters); currentCard.Categories.EncodedValue = propertyValue; currentCard.Categories.Group = group; break; case PropertyType.FormattedName: currentCard.FormattedName.DeserializeParameters(parameters); currentCard.FormattedName.EncodedValue = propertyValue; currentCard.FormattedName.Group = group; break; case PropertyType.Name: currentCard.Name.DeserializeParameters(parameters); currentCard.Name.EncodedValue = propertyValue; currentCard.Name.Group = group; break; case PropertyType.Title: currentCard.Title.DeserializeParameters(parameters); currentCard.Title.EncodedValue = propertyValue; currentCard.Title.Group = group; break; case PropertyType.Role: currentCard.Role.DeserializeParameters(parameters); currentCard.Role.EncodedValue = propertyValue; currentCard.Role.Group = group; break; case PropertyType.Mailer: currentCard.Mailer.DeserializeParameters(parameters); currentCard.Mailer.EncodedValue = propertyValue; currentCard.Mailer.Group = group; break; case PropertyType.Url: currentCard.Url.DeserializeParameters(parameters); currentCard.Url.EncodedValue = propertyValue; currentCard.Url.Group = group; break; case PropertyType.Organization: currentCard.Organization.DeserializeParameters(parameters); currentCard.Organization.EncodedValue = propertyValue; currentCard.Organization.Group = group; break; case PropertyType.UniqueId: currentCard.UniqueId.EncodedValue = propertyValue; currentCard.UniqueId.Group = group; break; case PropertyType.BirthDate: currentCard.BirthDate.DeserializeParameters(parameters); currentCard.BirthDate.EncodedValue = propertyValue; currentCard.BirthDate.Group = group; break; case PropertyType.Revision: currentCard.LastRevision.DeserializeParameters(parameters); currentCard.LastRevision.EncodedValue = propertyValue; currentCard.LastRevision.Group = group; break; case PropertyType.TimeZone: currentCard.TimeZone.DeserializeParameters(parameters); currentCard.TimeZone.EncodedValue = propertyValue; currentCard.TimeZone.Group = group; break; case PropertyType.GeographicPosition: currentCard.GeographicPosition.EncodedValue = propertyValue; currentCard.GeographicPosition.Group = group; break; case PropertyType.PublicKey: currentCard.PublicKey.DeserializeParameters(parameters); currentCard.PublicKey.EncodedValue = propertyValue; currentCard.PublicKey.Group = group; break; case PropertyType.Photo: currentCard.Photo.DeserializeParameters(parameters); currentCard.Photo.EncodedValue = propertyValue; currentCard.Photo.Group = group; break; case PropertyType.Logo: currentCard.Logo.DeserializeParameters(parameters); currentCard.Logo.EncodedValue = propertyValue; currentCard.Logo.Group = group; break; case PropertyType.Sound: currentCard.Sound.DeserializeParameters(parameters); currentCard.Sound.EncodedValue = propertyValue; currentCard.Sound.Group = group; break; case PropertyType.Note: NoteProperty n = new NoteProperty(); n.DeserializeParameters(parameters); n.EncodedValue = propertyValue; n.Group = group; currentCard.Notes.Add(n); break; case PropertyType.Address: AddressProperty a = new AddressProperty(); a.DeserializeParameters(parameters); a.EncodedValue = propertyValue; a.Group = group; currentCard.Addresses.Add(a); break; case PropertyType.Label: LabelProperty l = new LabelProperty(); l.DeserializeParameters(parameters); l.EncodedValue = propertyValue; l.Group = group; currentCard.Labels.Add(l); break; case PropertyType.Telephone: TelephoneProperty t = new TelephoneProperty(); t.DeserializeParameters(parameters); t.EncodedValue = propertyValue; t.Group = group; currentCard.Telephones.Add(t); break; case PropertyType.EMail: EMailProperty e = new EMailProperty(); e.DeserializeParameters(parameters); e.EncodedValue = propertyValue; e.Group = group; currentCard.EMailAddresses.Add(e); break; case PropertyType.Agent: AgentProperty ag = new AgentProperty(); ag.DeserializeParameters(parameters); ag.EncodedValue = propertyValue; ag.Group = group; currentCard.Agents.Add(ag); break; default: // Anything else is a custom property CustomProperty c = new CustomProperty(propertyName); c.DeserializeParameters(parameters); c.EncodedValue = propertyValue; c.Group = group; currentCard.CustomProperties.Add(c); break; } }
/// <summary> /// This is implemented to handle properties as they are parsed from the data stream /// </summary> /// <param name="propertyName">The name of the property.</param> /// <param name="parameters">A string collection containing the parameters and their values. If empty, /// there are no parameters.</param> /// <param name="propertyValue">The value of the property.</param> /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string /// collection. It is up to the derived class to process the parameter list based on the specification /// to which it conforms. For entries that are parameter names, the entry immediately following it in /// the collection is its associated parameter value. The property name, parameter names, and their /// values may be in upper, lower, or mixed case.</para> /// /// <para>The value may be an encoded string. The properties are responsible for any decoding that may /// need to occur (i.e. base 64 encoded image data).</para></remarks> /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data /// stream. Refer to the and inner exceptions for information on the cause of the problem.</exception> protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue) { SpecificationVersions version = SpecificationVersions.None; string temp, group = null; int idx; // Parse out the group name if there is one idx = propertyName.IndexOf('.'); if(idx != -1) { group = propertyName.Substring(0, idx).Trim(); propertyName = propertyName.Substring(idx + 1).Trim(); } // The last entry is always CustomProperty so scan for length minus one for(idx = 0; idx < ntv.Length - 1; idx++) if(ntv[idx].IsMatch(propertyName)) break; // An opening BEGIN:VCARD property must have been seen if(currentCard == null && ntv[idx].EnumValue != PropertyType.Begin) throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VCARD", propertyName)); // Handle or create the property switch(ntv[idx].EnumValue) { case PropertyType.Begin: // The value must be VCARD if(String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); // NOTE: If serializing into an existing instance, this may not be null. If so, it is // ignored. if(currentCard == null) { currentCard = new VCard(); vCards.Add(currentCard); } currentCard.Group = group; break; case PropertyType.End: // The value must be VCARD if(String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); // The group must match too if(currentCard.Group != group) throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnexpectedGroupTag", currentCard.Group, group)); // When done, we'll propagate the version number to all objects to make it consistent currentCard.PropagateVersion(); // The vCard is added to the collection when created so we don't have to rely on an END:VCARD // to add it. currentCard = null; break; case PropertyType.Profile: // The value must be VCARD if(String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0) throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue", ntv[idx].Name, propertyValue)); currentCard.AddProfile = true; break; case PropertyType.Version: // Version must be 2.1 or 3.0 temp = propertyValue.Trim(); if(temp == "2.1") version = SpecificationVersions.vCard21; else if(temp == "3.0") version = SpecificationVersions.vCard30; else throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion", "vCard", temp)); currentCard.Version = version; break; case PropertyType.MimeName: currentCard.MimeName.EncodedValue = propertyValue; break; case PropertyType.MimeSource: currentCard.MimeSource.DeserializeParameters(parameters); currentCard.MimeSource.EncodedValue = propertyValue; break; case PropertyType.ProductId: currentCard.ProductId.EncodedValue = propertyValue; break; case PropertyType.Nickname: currentCard.Nickname.DeserializeParameters(parameters); currentCard.Nickname.EncodedValue = propertyValue; currentCard.Nickname.Group = group; break; case PropertyType.SortString: currentCard.SortString.DeserializeParameters(parameters); currentCard.SortString.EncodedValue = propertyValue; currentCard.SortString.Group = group; break; case PropertyType.Class: currentCard.Classification.EncodedValue = propertyValue; currentCard.Classification.Group = group; break; case PropertyType.Categories: currentCard.Categories.DeserializeParameters(parameters); currentCard.Categories.EncodedValue = propertyValue; currentCard.Categories.Group = group; break; case PropertyType.FormattedName: currentCard.FormattedName.DeserializeParameters(parameters); currentCard.FormattedName.EncodedValue = propertyValue; currentCard.FormattedName.Group = group; break; case PropertyType.Name: currentCard.Name.DeserializeParameters(parameters); currentCard.Name.EncodedValue = propertyValue; currentCard.Name.Group = group; break; case PropertyType.Title: currentCard.Title.DeserializeParameters(parameters); currentCard.Title.EncodedValue = propertyValue; currentCard.Title.Group = group; break; case PropertyType.Role: currentCard.Role.DeserializeParameters(parameters); currentCard.Role.EncodedValue = propertyValue; currentCard.Role.Group = group; break; case PropertyType.Mailer: currentCard.Mailer.DeserializeParameters(parameters); currentCard.Mailer.EncodedValue = propertyValue; currentCard.Mailer.Group = group; break; case PropertyType.Url: currentCard.Url.DeserializeParameters(parameters); currentCard.Url.EncodedValue = propertyValue; currentCard.Url.Group = group; break; case PropertyType.Organization: currentCard.Organization.DeserializeParameters(parameters); currentCard.Organization.EncodedValue = propertyValue; currentCard.Organization.Group = group; break; case PropertyType.UniqueId: currentCard.UniqueId.EncodedValue = propertyValue; currentCard.UniqueId.Group = group; break; case PropertyType.BirthDate: currentCard.BirthDate.DeserializeParameters(parameters); currentCard.BirthDate.EncodedValue = propertyValue; currentCard.BirthDate.Group = group; break; case PropertyType.Revision: currentCard.LastRevision.DeserializeParameters(parameters); currentCard.LastRevision.EncodedValue = propertyValue; currentCard.LastRevision.Group = group; break; case PropertyType.TimeZone: currentCard.TimeZone.DeserializeParameters(parameters); currentCard.TimeZone.EncodedValue = propertyValue; currentCard.TimeZone.Group = group; break; case PropertyType.GeographicPosition: currentCard.GeographicPosition.EncodedValue = propertyValue; currentCard.GeographicPosition.Group = group; break; case PropertyType.PublicKey: currentCard.PublicKey.DeserializeParameters(parameters); currentCard.PublicKey.EncodedValue = propertyValue; currentCard.PublicKey.Group = group; break; case PropertyType.Photo: currentCard.Photo.DeserializeParameters(parameters); currentCard.Photo.EncodedValue = propertyValue; currentCard.Photo.Group = group; break; case PropertyType.Logo: currentCard.Logo.DeserializeParameters(parameters); currentCard.Logo.EncodedValue = propertyValue; currentCard.Logo.Group = group; break; case PropertyType.Sound: currentCard.Sound.DeserializeParameters(parameters); currentCard.Sound.EncodedValue = propertyValue; currentCard.Sound.Group = group; break; case PropertyType.Note: NoteProperty n = new NoteProperty(); n.DeserializeParameters(parameters); n.EncodedValue = propertyValue; n.Group = group; currentCard.Notes.Add(n); break; case PropertyType.Address: AddressProperty a = new AddressProperty(); a.DeserializeParameters(parameters); a.EncodedValue = propertyValue; a.Group = group; currentCard.Addresses.Add(a); break; case PropertyType.Label: LabelProperty l = new LabelProperty(); l.DeserializeParameters(parameters); l.EncodedValue = propertyValue; l.Group = group; currentCard.Labels.Add(l); break; case PropertyType.Telephone: TelephoneProperty t = new TelephoneProperty(); t.DeserializeParameters(parameters); t.EncodedValue = propertyValue; t.Group = group; currentCard.Telephones.Add(t); break; case PropertyType.EMail: EMailProperty e = new EMailProperty(); e.DeserializeParameters(parameters); e.EncodedValue = propertyValue; e.Group = group; currentCard.EMailAddresses.Add(e); break; case PropertyType.Agent: AgentProperty ag = new AgentProperty(); ag.DeserializeParameters(parameters); ag.EncodedValue = propertyValue; ag.Group = group; currentCard.Agents.Add(ag); break; default: // Anything else is a custom property CustomProperty c = new CustomProperty(propertyName); c.DeserializeParameters(parameters); c.EncodedValue = propertyValue; c.Group = group; currentCard.CustomProperties.Add(c); break; } }
set => SetValue(NoteProperty, value);
get => (int)GetValue(NoteProperty); set => SetValue(NoteProperty, value);