示例#1
0
        //private static DataSet ConvertJsonStringToDataSet(string jsonString)
        //{
        //    try
        //    {
        //        //XmlDocument xd = new XmlDocument();
        //        jsonString = jsonString.Trim().TrimStart('\"').TrimEnd('\"') ;
        //        string xd = JsonConvert.DeserializeXmlNode(jsonString).ToString();
        //        DataSet ds = new DataSet();
        //        //DataSet ds = JsonConvert.DeserializeObject<DataSet>(jsonString);
        //        //ds.ReadXml(new System.Xml.XmlNodeReader(xd));
        //        return ds;



        //        //Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();

        //        //json.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
        //        //json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
        //        //json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
        //        //json.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

        //        //StringReader sr = new StringReader(jsonString);
        //        //Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);
        //        //DataSet result = json.Deserialize<DataSet>(reader);
        //        //reader.Close();

        //        //return result;

        //    }
        //    catch (Exception ex)
        //    {
        //        throw new ArgumentException(ex.Message);
        //    }
        //}


        protected void DDLBinding(int id, Semantics Stype)
        {
            String type      = Stype.ToString();
            string strResult = ProxyService.GetSemanticLists(id, type);

            strResult = strResult.Replace("\\", String.Empty);
            strResult = strResult.Trim().TrimStart('\"').TrimEnd('\"');
            var           objSerializer = new JavaScriptSerializer();
            var           obj           = objSerializer.Deserialize <List <SemanticList> >(strResult);
            RibbonGallery rbbnGallary   = null;

            switch (Stype)
            {
            case Semantics.abbreviation: rbbnGallary = glyAbbrevations;
                break;

            case Semantics.cite: rbbnGallary = glyCites;
                break;

            case Semantics.idiom: rbbnGallary = glyIdioms;
                break;

            case Semantics.variable: rbbnGallary = glyVariables;
                break;

            case Semantics.definition: rbbnGallary = glyDefinitions;
                break;

            case Semantics.links: rbbnGallary = glyLinks;
                break;

                //case "new": rbbnGallary = null;
                //    break;
            }
            if (rbbnGallary != null)
            {
                try
                {
                    for (int loop = 0; loop < obj.Count; loop++)
                    {
                        string strNameOfItem = obj[loop].Text;
                        Microsoft.Office.Tools.Ribbon.RibbonDropDownItem menuItem = Factory.CreateRibbonDropDownItem();
                        menuItem.Tag = obj[loop].Value;
                        //menuItem.Id = obj[loop].Value.ToString();
                        menuItem.Label = obj[loop].Text;

                        rbbnGallary.Items.Add(menuItem);
                        rbbnGallary.Items[loop].Label = strNameOfItem;
                    }
                }
                catch
                {
                }
            }
        }