예제 #1
0
        /// <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));
                }
            }
        }
예제 #2
0
        /// <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"));
        }
예제 #3
0
        /// <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"));
        }
예제 #4
0
        public FrmNew(IAPIObject obj)
        {
            InitializeComponent();

            propertyGrid1.SelectedObject = obj;
        }