public string GetJson <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, ResultAsJson = true, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.Serialize(true)}"); var response = SendRequest(reqest); using (var file = File.OpenText($"{typeof(T).Name}sSchema.json")) using (var reader = new JsonTextReader(file)) { var schema = JSchema.Load(reader); var collection = JArray.Parse(response); Console.WriteLine($"Collection is {(collection.IsValid(schema) ? "" : "not ")}valid."); } return(response); }
public string GetXml <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.Serialize(true)}"); var response = SendRequest(reqest); return(response); }
public List <T> Get <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.SerializeXml(true)}"); var response = SendRequest(reqest); Console.WriteLine($"\r\nCollection is {(IsValidXml<T>(response) ? "" : "not ")}valid."); return(response.Deserialize <List <T> >()); }