public static T ToObject <T>(this IViewRow row) { var rawValue = row.Info["value"] as Dictionary <string, object>; var json = JsonConvert.SerializeObject(rawValue); var model = JsonToObject <T>(json); return(model); }
private TextContent ViewRowToTextContent(IViewRow viewRow) { if (viewRow == null) { return(null); } var uuid = GetUUID(viewRow); return(this.ContentQuery.Repository.GetClient().ExecuteGet(uuid).ToContent()); }
public static Category ToCategory(this IViewRow row) { Category category = new Category(); var dict = row.Info["value"] as Dictionary <string, object>; category.CategoryFolder = dict["CategoryFolder"] as string; category.CategoryUUID = dict["CategoryUUID"] as string; category.ContentUUID = dict["ContentUUID"] as string; return(category); }
public void When_UrlEncodeKeys_Is_False_In_Ctor_Keys_With_Special_Chars_Fails() { CreateViewFromFile(@"Data\\ViewWithCompoundKey.json", "test"); IViewRow item = Client.GetView("test", "all", false).Key(new object[] { 123, "a+b" }).Stale(StaleMode.False).FirstOrDefault(); Assert.IsNull(item); }
public void When_UrlEncodeKeys_Is_True_Keys_With_Special_Chars_Are_Succesful() { CreateViewFromFile(@"Data\\ViewWithCompoundKey.json", "test"); var view = Client.GetView("test", "all").UrlEncode(true); IViewRow item = view.Key(new object[] { 123, "a+b" }).Stale(StaleMode.False).FirstOrDefault(); Assert.IsNotNull(item); }
public static TextContent ToContent(this IViewRow row) { if (row == null) { return(null); } TextContent content = new TextContent(); Dictionary <string, object> dict = row.Info["value"] as Dictionary <string, object>; foreach (var key in dict.Keys) { content[key] = dict[key]; } return(content); }
public static T ToModel <T>(this IViewRow row, Site site, Func <Site, string, T> createModel) where T : IPersistable { var rawValue = row.Info["value"] as Dictionary <string, object>; var json = JsonConvert.SerializeObject(rawValue); var rawKey = ModelExtensions.GetRawDocumentKey(row.ItemId); var dummy = createModel(site, rawKey); var model = JsonToObject <T>(json); ((IPersistable)model).Init(dummy); return(model); }
private static string GetUUID(IViewRow viewRow) { var uuid = viewRow.DictionaryValue()["UUID"]; return uuid.ToString(); }
private TextContent ViewRowToTextContent(IViewRow viewRow) { if (viewRow == null) { return null; } var uuid = GetUUID(viewRow); return this.ContentQuery.Repository.GetClient().ExecuteGet(uuid).ToContent(); }
public static IDictionary <string, object> DictionaryValue(this IViewRow row) { Dictionary <string, object> dict = row.Info["value"] as Dictionary <string, object>; return(dict); }
private static string GetUUID(IViewRow viewRow) { var uuid = viewRow.DictionaryValue()["UUID"]; return(uuid.ToString()); }
private double GetSecondsLeft(IViewRow viewRow) { var expiration = (long)((IDictionary<string, object>)viewRow.Info["value"])["expiration"]; return UnixTimestampToSecondsLeft(expiration); }