コード例 #1
0
        public virtual List <T> GetObjects <T>(int id, string parentNoun, RESTOptions <T> options) where T : Noun.Base.BaseNoun, new()
        {
            HttpWebResponse response = null;

            try
            {
                string restUrl = _serverURL + Constant.REST_BASE_PATH;
                if (!String.IsNullOrEmpty(parentNoun))
                {
                    restUrl += "/" + parentNoun;
                }
                else
                {
                    restUrl += "/" + Noun.Base.BaseNoun.GetNoun(typeof(T));
                }
                if (id > 0)
                {
                    restUrl += "/" + id;
                }
                if (!String.IsNullOrEmpty(parentNoun))
                {
                    restUrl += "/" + Noun.Base.BaseNoun.GetNoun(typeof(T));
                }
                string responseText = this.getObjectStringResponse(restUrl, options.GetPostParameters(), options.IfModifiedSince);

                return(JsonConvert.DeserializeObject <List <T> >(responseText));
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }
        }
コード例 #2
0
        public virtual T GetObject <T>(int id, RESTOptions <T> options) where T : Noun.Base.BaseNoun, new()
        {
            HttpWebResponse response = null;

            try
            {
                string restUrl      = _serverURL + Constant.REST_BASE_PATH + "/" + Noun.Base.BaseNoun.GetNoun(typeof(T)) + "/" + id;
                string responseText = this.getObjectStringResponse(restUrl, options.GetPostParameters(), options.IfModifiedSince);

                T objT = JsonConvert.DeserializeObject <T>(responseText);
                return(objT);
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }
        }