예제 #1
0
        protected static ODataEntityResponse GetEntity(ODataResponse response)
        {
            var text = response.Result;
            var jo   = (JObject)Deserialize(text);

            return(ODataEntityResponse.Create((JObject)jo["d"]));
        }
예제 #2
0
        protected static ODataEntitiesResponse GetEntities(ODataResponse response)
        {
            var text = response.Result;

            var result = new List <ODataEntityResponse>();
            var jo     = (JObject)Deserialize(text);
            var d      = (JObject)jo["d"];
            var count  = d["__count"].Value <int>();
            var jarray = (JArray)d["results"];

            for (int i = 0; i < jarray.Count; i++)
            {
                result.Add(ODataEntityResponse.Create((JObject)jarray[i]));
            }
            return(new ODataEntitiesResponse(result.ToList(), count));
        }
예제 #3
0
        private static ODataActionItem ConvertToAction(ODataEntityResponse entity)
        {
            var operation = entity.AllProperties;

            return(new ODataActionItem
            {
                Name = ((JValue)operation["Name"]).Value <string>(),
                DisplayName = ((JValue)operation["DisplayName"]).Value <string>(),
                Icon = ((JValue)operation["Icon"]).Value <string>(),
                Index = ((JValue)operation["Index"]).Value <int>(),
                Scenario = ((JValue)operation["Scenario"]).Value <string>(),
                Forbidden = ((JValue)operation["Forbidden"]).Value <bool>(),
                Url = ((JValue)operation["Url"]).Value <string>(),
                IsODataAction = ((JValue)operation["IsODataAction"]).Value <bool>(),
                ActionParameters = ((JArray)operation["ActionParameters"]).Select(p => p.ToString()).ToArray()
            });
        }
예제 #4
0
        public async Task OD_GET_Children_Entity_SelectChildren_NoExpand()
        {
            await ODataChildrenTest(async() =>
            {
                // ACTION
                var response = await ODataGetAsync(
                    $"/OData.svc/Root/WSRoot('Workspace1')",
                    "?metadata=no&$select=Id,Name,Children")
                               .ConfigureAwait(false);

                // ASSERT
                var entity = GetEntity(response);
                // ODataReference will be serialized as "__deferred"
                var propertyValue = (JObject)entity.AllProperties["Children"];
                var children      = ODataEntityResponse.Create(propertyValue);
                Assert.IsTrue(children.IsDeferred);
            }).ConfigureAwait(false);
        }