public override void CopyFrom(object obj) { if (obj is TextCollection) { TextCollection tc = (TextCollection)obj; Text[] array = new Text[tc.Values.Count]; tc.CopyTo(array, 0); Values.Clear(); Values.AddRange(array); } base.CopyFrom(obj); }
public override void CopyFrom(object obj) { if (obj is RequestStatus) { RequestStatus rs = (RequestStatus)obj; StatusCode = new StatusCode(); StatusCode.CopyFrom(rs.StatusCode); StatusDesc = new Text(rs.StatusDesc.Value); if (rs.ExtData != null) ExtData = new Text(rs.ExtData.Value); } base.CopyFrom(obj); }
public override bool TryParse(string value, ref object obj) { RequestStatus rs = (RequestStatus)obj; Match match = Regex.Match(value, @"(\.*[^\\]);(\.*[^\\])(;(\.*))?"); if (match.Success) { if (!match.Groups[1].Success || !match.Groups[2].Success) return false; StatusCode = new StatusCode(match.Groups[1].Value); StatusDesc = new Text(match.Groups[1].Value); if (match.Groups[3].Success) ExtData = new Text(match.Groups[4].Value); } return false; }
private Text NewText(string value) { Text t = new Text(); t.Encoding = Encoding; object obj = t; if (t.TryParse(value, ref obj)) return t; return null; }
public TextSerializer(Text text) : base(text) { this.m_Text = text; }
virtual public void RemoveRelatedTo(string uid) { if (Related_To == null) return; else { int index = -1; for (int i = 0; i < Related_To.Length; i++) { if (Related_To[i].Value.Equals(uid) || Related_To[i].Value.Equals("<" + uid + ">")) { index = i; break; } } if (index >= 0) { Text[] related_to = new Text[Related_To.Length - 1]; Array.Copy(Related_To, 0, related_to, 0, index); Array.Copy(Related_To, index + 1, related_to, index, related_to.Length - index); Related_To = related_to; } } }
public override void SetContentLineValue(ContentLine cl) { base.SetContentLineValue(cl); if (cl.Name == "UID") { Text text = new Text(); text.ContentLine = cl; UID = text.Value; } }
virtual public void RemoveContact(string contact) { if (Comment == null) return; else { int index = Array.IndexOf<Text>(Contact, contact); if (index >= 0) { Text[] contacts = new Text[Contact.Length - 1]; Array.Copy(Contact, 0, contacts, 0, index); Array.Copy(Contact, index + 1, contacts, index, contacts.Length - index); Contact = contacts; } } }
virtual public void AddRelatedTo(string uid, string relationshipType) { Text text = uid; if (relationshipType != null) text.AddParameter(new Parameter("RELTYPE", relationshipType)); if (Related_To == null) { Related_To = new Text[] { text }; } else { Text[] related_to = Related_To; Related_To = new Text[Related_To.Length + 1]; related_to.CopyTo(Related_To, 0); Related_To[Related_To.Length - 1] = text; } }
virtual public void AddComment(string comment) { if (Comment == null) Comment = new Text[] { comment }; else { Text[] comments = Comment; Comment = new Text[Comment.Length + 1]; comments.CopyTo(Comment, 0); Comment[Comment.Length - 1] = comment; } }
virtual public void AddContact(string contact, Uri alternateTextRepresentation) { if (Contact == null) { Contact = new Text[] { contact }; if (alternateTextRepresentation != null) Contact[0].AddParameter("ALTREP", alternateTextRepresentation.OriginalString); } else { Text[] contacts = Contact; Contact = new Text[Contact.Length + 1]; contacts.CopyTo(Contact, 0); Contact[Contact.Length - 1] = contact; if (alternateTextRepresentation != null) Contact[Contact.Length - 1].AddParameter("ALTREP", alternateTextRepresentation.OriginalString); } }
protected void OnUIDChanged(Text oldUID, Text newUID) { if (UIDChanged != null) UIDChanged(this, oldUID, newUID); }
virtual public void RemoveCategory(string categoryName) { if (Categories != null) { Text cn = new Text(categoryName); foreach (TextCollection tc in Categories) { if (tc.Values.Contains(cn)) { tc.Values.Remove(cn); return; } } } }
virtual public void AddCategory(string categoryName) { Text cn = new Text(categoryName); if (Categories != null) { foreach (TextCollection tc in Categories) { if (tc.Values.Contains(cn)) { return; } } } if (Categories == null || Categories.Length == 0) { Categories = new TextCollection[1] { new TextCollection(categoryName) }; Categories[0].Name = "CATEGORIES"; } else { Categories[0].Values.Add(cn); } }
virtual public void RemoveResource(string resource) { if (Resources != null) { Text r = new Text(resource); foreach (TextCollection tc in Resources) { if (tc.Values.Contains(r)) { tc.Values.Remove(r); return; } } } }
virtual public void AddResource(string resource) { Text r = new Text(resource); if (Resources != null) { foreach (TextCollection tc in Resources) { if (tc.Values.Contains(r)) { return; } } } if (Resources == null || Resources.Length == 0) { Resources = new TextCollection[1] { new TextCollection(resource) }; Resources[0].Name = "RESOURCES"; } else { Resources[0].Values.Add(r); } }