コード例 #1
0
ファイル: ModelExtensions.cs プロジェクト: nguyenhuy2911/CMS
        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
ファイル: ModelExtendions.cs プロジェクト: nguyenhuy2911/CMS
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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
ファイル: ModelExtendions.cs プロジェクト: nguyenhuy2911/CMS
        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
ファイル: ModelExtensions.cs プロジェクト: nguyenhuy2911/CMS
        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
ファイル: ModelExtendions.cs プロジェクト: nguyenhuy2911/CMS
        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);
 }