コード例 #1
0
ファイル: APIObject.cs プロジェクト: manuth/RHR-Patcher
        /// <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;
        }