/// <summary> /// Clones the object and all its properties to another object. /// </summary> /// <param name="obj">The object to copy this object to.</param> public void CloneTo(IAPIObject obj) { BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; foreach (PropertyInfo property in GetType().GetProperties(flags)) { if ( property.CanRead && obj.GetType().GetProperty(property.Name, flags) != null) { property.SetValue(obj, property.GetValue(this)); } } }
/// <summary> /// Add object /// </summary> /// <param name="obj">Object to add</param> /// <param name="parent">Parent object if needed</param> /// <returns></returns> public APIResponse AddObject(IAPIObject obj, APIObject parent) { obj.SetParentId(parent.id); string json = obj.Serialize(); if (obj.IsParentIdRequired()) { ParentId = parent.id; } LastResponseTotalItem = 1; return(SetObject(obj.GetType(), json, "POST")); }
/// <summary> /// Update object /// </summary> /// <param name="obj">modified object</param> /// <param name="parent">Parent object if needed</param> /// <returns></returns> public APIResponse UpdateObject(IAPIObject obj, APIObject parent = null) { var result = new APIResponse(); if (obj == null) { return(result); } LastResponseTotalItem = 1; string json = obj.Serialize(); Id = ((APIObject)obj).id; if (obj.IsParentIdRequired()) { ParentId = parent.id; } return(SetObject(obj.GetType(), json, "PUT")); }
public FrmNew(IAPIObject obj) { InitializeComponent(); propertyGrid1.SelectedObject = obj; }