/// <summary> /// Returns an existing unbound ClientProperty with the corresponding name /// or creates a new one if not found. /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="readOnly"> /// null means we don't care and want to get back the existing property if any. /// if none is available, a read/write property is then returned. /// </param> /// <returns></returns> public WoopsaClientProperty GetProperty(string name, WoopsaValueType type, bool?readOnly = null) { WoopsaProperty result = Properties.ByNameOrNull(name); if (result != null) { if (result.Type != type) { throw new Exception(string.Format( "A property with then name '{0}' exists, but with the type {1} instead of {2}", name, result.Type, type)); } else if (readOnly != null && result.IsReadOnly != readOnly) { throw new Exception(string.Format( "A property with then name '{0}' exists, but with the readonly flag {1} instead of {2}", name, result.IsReadOnly, readOnly)); } else if (!(result is WoopsaClientProperty)) { throw new Exception(string.Format( "A property with then name '{0}' exists, but it is not of the type WoopsaClientProperty", name)); } else { return(result as WoopsaClientProperty); } } else { return(base.CreateProperty(name, type, readOnly ?? true)); } }
internal void Add(WoopsaProperty item) { if (_properties.ByNameOrNull(item.Name) != null) { throw new WoopsaException("Tried to add a property with duplicate name '" + item.Name + "' to WoopsaObject '" + Name + "'"); } _properties.Add(item); }
internal void Remove(WoopsaProperty item) { _properties.Remove(item); }