當前位置: 首頁>>代碼示例>>C#>>正文


C# Script.Serialization.JavaScriptSerializer.Find方法代碼示例

本文整理匯總了C#中System.Web.Script.Serialization.JavaScriptSerializer.Find方法的典型用法代碼示例。如果您正苦於以下問題:C# Script.Serialization.JavaScriptSerializer.Find方法的具體用法?C# Script.Serialization.JavaScriptSerializer.Find怎麽用?C# Script.Serialization.JavaScriptSerializer.Find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.Script.Serialization.JavaScriptSerializer的用法示例。


在下文中一共展示了Script.Serialization.JavaScriptSerializer.Find方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RestoreSelectedState

 private void RestoreSelectedState(string selectedState)
 {
     List<JQTreeNode> list = new JavaScriptSerializer().Deserialize<List<JQTreeNode>>(selectedState);
     JQTreeNodeCollection allNodesFlat = this.GetAllNodesFlat(this.Nodes);
     IEnumerator enumerator = allNodesFlat.GetEnumerator();
     try
     {
         JQTreeNode node;
         while (enumerator.MoveNext())
         {
             node = (JQTreeNode)enumerator.Current;
             JQTreeNode jQTreeNode = list.Find((JQTreeNode selectedNode) => selectedNode.Text == node.Text && selectedNode.Value == node.Value);
             if (jQTreeNode != null)
             {
                 node.Selected = true;
             }
             else
             {
                 node.Selected = false;
             }
         }
     }
     finally
     {
         IDisposable disposable = enumerator as IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
     }
 }
開發者ID:thanyaammyy,項目名稱:thaitaesc,代碼行數:31,代碼來源:JQTreeView.cs

示例2: QueryAttribute

        /// <summary>
        /// 查詢屬性和屬性值
        /// </summary>
        /// <param name="AttributeValues">
        /// The Attribute Values.
        /// </param>
        /// <param name="AttributeModels">
        /// The Attribute Models.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string QueryAttribute(ProductModel result)
        {
            var json = new ProductAttributeService().QueryByCategoryId(Utils.ToString(result.ProductCategoryID));
            if (string.IsNullOrEmpty(json)) return "";

            try
            {
                List<AttributeModel> AttributeModels = new JavaScriptSerializer().Deserialize<List<AttributeModel>>(json);
                if (AttributeModels == null || AttributeModels.Count == 0) return "";

                List<ProductAttributeModel> AttributeValues = new JavaScriptSerializer().Deserialize<List<ProductAttributeModel>>(Utils.ToString(result.Attributes));
                if (AttributeValues == null || AttributeValues.Count == 0) return "";

                StringBuilder sb = new StringBuilder();
                sb.Append("<li><img src=\"/Images/b1.gif\" alt=\"\">商品條碼:<span>" + Utils.ToString(result.Barcode) + "</span></li>");
                foreach (var model in AttributeModels)
                {
                    sb.Append("<li><img src=\"/Images/b1.gif\" alt=\"\">");
                    sb.Append(model.AttributeName);
                    sb.Append(":<span id=\"form_custom_column_" + model.ID + "\">");
                    var val = AttributeValues.Find(v => v.ID == model.ID);
                    if (model.AttributeValues != null && val != null)
                    {
                        AttributeValueModel value = model.AttributeValues.Find(v => v.ID == val.ValueID);
                        if (value != null && value.Value != null)
                        {
                            sb.Append(value.Value);
                        }
                    }
                    sb.Append("</span></li>");
                }
                return "<ul>" + sb.ToString() + "</ul>";
            }
            catch (Exception ex)
            {
                return "";
            }
        }
開發者ID:jxzly229190,項目名稱:OnlineStore,代碼行數:50,代碼來源:ProductController.cs


注:本文中的System.Web.Script.Serialization.JavaScriptSerializer.Find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。