예제 #1
0
        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);
        }
예제 #2
0
        private TextContent ViewRowToTextContent(IViewRow viewRow)
        {
            if (viewRow == null)
            {
                return(null);
            }
            var uuid = GetUUID(viewRow);

            return(this.ContentQuery.Repository.GetClient().ExecuteGet(uuid).ToContent());
        }
예제 #3
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
파일: CouchbaseQuery.cs 프로젝트: Godoy/CMS
 private static string GetUUID(IViewRow viewRow)
 {
     var uuid = viewRow.DictionaryValue()["UUID"];
     return uuid.ToString();
 }
예제 #9
0
파일: CouchbaseQuery.cs 프로젝트: Godoy/CMS
 private TextContent ViewRowToTextContent(IViewRow viewRow)
 {
     if (viewRow == null)
     {
         return null;
     }
     var uuid = GetUUID(viewRow);
     return this.ContentQuery.Repository.GetClient().ExecuteGet(uuid).ToContent();
 }
예제 #10
0
        public static IDictionary <string, object> DictionaryValue(this IViewRow row)
        {
            Dictionary <string, object> dict = row.Info["value"] as Dictionary <string, object>;

            return(dict);
        }
예제 #11
0
        private static string GetUUID(IViewRow viewRow)
        {
            var uuid = viewRow.DictionaryValue()["UUID"];

            return(uuid.ToString());
        }
예제 #12
0
 private double GetSecondsLeft(IViewRow viewRow)
 {
     var expiration = (long)((IDictionary<string, object>)viewRow.Info["value"])["expiration"];
     return UnixTimestampToSecondsLeft(expiration);
 }