internal int AddObjectToTable(IPlistElement obj) { if (obj.ElementType == PlistElementType.Array || obj.ElementType == PlistElementType.Dictionary) { // Don't compare these; Assume all arrays and dictionaries are unique objOffsets.Add(this.BaseStream.Position); objects.Add(obj); return(objects.Count); } for (int i = 0; i < objects.Count; i++) { IPlistElement testAgainst = objects[i]; if (obj.Equals(objects[i])) { return(i); } } // this object is unique objOffsets.Add(this.BaseStream.Position); objects.Add(obj); return(objects.Count); }
public PlistDocument(IPlistElement rootNode) { if (rootNode == null) { throw new ArgumentNullException("rootNode"); } _value = rootNode; }
public void Add(IPlistElement value) { if (value == null) { throw new ArgumentNullException("value", "The provided value is null"); } int length = _value.GetLength(0); Array.Resize(ref _value, length); _value[length] = value; }
public void Delete(int index) { int length = _value.GetLength(0); if (index < 0) { throw new ArgumentNullException("index", "The specified index is negative"); } if (length < index) { throw new IndexOutOfRangeException("Index is outside of bounds of the array"); } if (length == index) { // It's the last index Array.Resize(ref _value, length - 1); return; } // TODO: Instead, pack down array ignoring _value[index], then resize // Resize bool reached = false; IPlistElement[] resize = new IPlistElement[length - 1]; length--; // Remove unwanted for (int i = 0; i < length; i++) { if (i == index) { reached = true; } if (reached) { resize[i] = _value[i]; } else { resize[i] = _value[i + 1]; } } _value = resize; }
public void Set(int index, IPlistElement value) { if (value == null) { throw new ArgumentNullException("value"); } if (index < 0) { throw new IndexOutOfRangeException("The specified index is negative"); } if (_value.GetLength(0) <= index) { throw new IndexOutOfRangeException("The specified index is out of the bounds of the array"); } _value[index] = value; }
public PlistDict Add(string key, IPlistElement value) { if (String.IsNullOrEmpty(key)) { throw new ArgumentNullException("key", "The specified key is null or empty"); } if (value == null) { throw new ArgumentNullException("value", "The specified value is null"); } if (_value.ContainsKey(key)) { _value[key] = value; } else { _value.Add(key, value); } return(this); }