Exemple #1
0
        /// <summary>
        /// 收集条件
        /// 遍历该容器下所有继承IInputControl接口的控件的_Value属性,并反序列化到对应的类的对象字段中
        /// </summary>
        /// <returns></returns>
        public T _GetConditon <T>()
        {
            var dic = new Dictionary <string, object>();

            GetCondition(this, dic);

            if (dic.Count > 0)
            {
                string json = dic.DictionaryToJson();
                return(JsonUtil.DeSerializer <T>(json));
            }

            return(System.Activator.CreateInstance <T>());
        }
Exemple #2
0
        public bool Execute(string packageName, XmlNode xmlData)
        {
            try
            {
                var path = HttpContext.Current.Server.MapPath(string.Concat(BootstrapPath, "media.json"));
                var imageDic = new Dictionary<int, int>();

                // Set images in media library
                var picturesFolder = Media.MakeNew("Bootstrap Images", folderType, adminUser, -1);

                // Brazil
                var brazilFolder = Media.MakeNew("Brazil", folderType, adminUser, picturesFolder.Id);
                imageDic.Add(1401, CreateImage(brazilFolder.Id, "Holambra", "holambra.jpg").Id);
                imageDic.Add(1402, CreateImage(brazilFolder.Id, "Frevo", "ibirapuera-three.jpg").Id);
                imageDic.Add(1405, CreateImage(brazilFolder.Id, "Iguazu", "iguazu.jpg").Id);
                imageDic.Add(1407, CreateImage(brazilFolder.Id, "Liberdade", "liberdade-one.jpg").Id);
                imageDic.Add(1410, CreateImage(brazilFolder.Id, "Praca da se", "praca-da-se.jpg").Id);

                // London
                var londonFolder = Media.MakeNew("London", folderType, adminUser, picturesFolder.Id);
                imageDic.Add(1430, CreateImage(londonFolder.Id, "Jubilee Walkway", "jubilee-walkway.jpg").Id);
                imageDic.Add(1431, CreateImage(londonFolder.Id, "London Bridge", "london-bridge.jpg").Id);
                imageDic.Add(1433, CreateImage(londonFolder.Id, "Wimbledon Common", "wimbledon-common.jpg").Id);

                // Spain
                var spainFolder = Media.MakeNew("Spain", folderType, adminUser, picturesFolder.Id);
                imageDic.Add(1435, CreateImage(spainFolder.Id, "Alhambra", "alhambra.jpg").Id);
                imageDic.Add(1436, CreateImage(spainFolder.Id, "Cordoba", "cordoba.jpg").Id);
                imageDic.Add(1437, CreateImage(spainFolder.Id, "El retiro", "el-retiro.jpg").Id);
                imageDic.Add(1438, CreateImage(spainFolder.Id, "Sevilla", "sevilla.jpg").Id);
                imageDic.Add(1439, CreateImage(spainFolder.Id, "Tenerife", "tenerife.jpg").Id);

                // Images folder
                var imagesFolder = Media.MakeNew("Others", folderType, adminUser,picturesFolder.Id);
                imageDic.Add(1395, CreateImage(imagesFolder.Id, "Bootstrap", "bootstrap-from-twitter.jpg").Id);
                imageDic.Add(1396, CreateImage(imagesFolder.Id, "Settings Less", "settings-less.jpg").Id);

                var json = imageDic.DictionaryToJson();
                File.WriteAllText(path, json);
                return true;
            }
            catch (Exception ex)
            {
                Log.Add(LogTypes.PackagerInstall, -1, ex.Message);
                return false;
            }
        }
 public void CanConvertIntIntDictionaryToJason()
 {
     var dictionary = new Dictionary<int, int> {{1, 10}, {2, 20}, {3, 30}};
     var json = dictionary.DictionaryToJson();
     Assert.IsNotNullOrEmpty(json);
 }