当前位置: 首页>>代码示例>>C#>>正文


C# SetType.ToString方法代码示例

本文整理汇总了C#中SetType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SetType.ToString方法的具体用法?C# SetType.ToString怎么用?C# SetType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SetType的用法示例。


在下文中一共展示了SetType.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Set

        /// <summary>
        /// Ϊ�ڵ㸳ֵ[ͨ��ֵ����values�и�ֵ]
        /// </summary>
        public void Set(XmlNode node, SetType setType, params string[] values)
        {
            if (node != null && values != null)
            {
                switch (setType)
                {
                    case SetType.InnerText:
                        string value = SetValue(node.InnerText, values[0], false);
                        try
                        {
                            node.InnerText = value;
                        }
                        catch
                        {
                            node.InnerText = SetCDATA(value);
                        }
                        break;
                    case SetType.InnerXml:
                        node.InnerXml = SetValue(node.InnerXml, values[0], true);
                        break;
                    case SetType.Value:
                    case SetType.Href:
                    case SetType.Src:
                    case SetType.Class:
                    case SetType.Disabled:
                    case SetType.ID:
                    case SetType.Name:
                    case SetType.Visible:
                    case SetType.Title:
                    case SetType.Style:
                        string key = setType.ToString().ToLower();
                        SetAttrValue(node, key, values[0]);
                        break;
                    case SetType.Custom:
                        for (int i = 0; i < values.Length; i++)
                        {
                            if (i > 0 && i % 2 == 1)
                            {
                                key = values[i - 1].ToLower();
                                switch (key)
                                {
                                    case "innertext":
                                        Set(node, SetType.InnerText, values[i]);
                                        break;
                                    case "innerhtml":
                                    case "innerxml":
                                        Set(node, SetType.InnerXml, values[i]);
                                        break;
                                    default:
                                        SetAttrValue(node, key, values[i]);
                                        break;
                                }
                            }
                        }

                        break;
                    case SetType.A:
                        node.InnerXml = SetValue(node.InnerXml, values[0], true);
                        if (values.Length > 1)
                        {
                            SetAttrValue(node, "href", values[1]);
                            if (values.Length > 2)
                            {
                                SetAttrValue(node, "title", values[2]);
                                if (values.Length > 3)
                                {
                                    SetAttrValue(node, "target", values[3]);
                                }
                            }
                        }
                        break;
                    case SetType.Select:
                        if (node.InnerXml.Contains(AppConfig.XHtml.CDataLeft))//�������ַ�
                        {
                            string innerHtml = node.InnerXml.Replace(string.Format("value=\"{0}\"", values[0]), string.Format("selected=\"selected\" value=\"{0}\"", values[0]));
                            try
                            {
                                node.InnerXml = innerHtml;
                            }
                            catch
                            {
                                node.InnerXml = SetCDATA(innerHtml);
                            }
                        }
                        else
                        {
                            foreach (XmlNode option in node.ChildNodes)
                            {
                                if (option.Attributes["value"] != null && (option.Attributes["value"].Value == values[0] || option.Attributes["value"].Value.Split(',')[0] == values[0]))
                                {
                                    SetAttrValue(option, "selected", "selected");
                                    break;
                                }
                            }
                        }
                        break;
                    case SetType.Checked:
//.........这里部分代码省略.........
开发者ID:Feng2012,项目名称:cyqdata,代码行数:101,代码来源:XHtmlAction.cs

示例2: SetForeach

 public void SetForeach(string id, SetType setType, params object[] formatValues)
 {
     string text = string.Empty;
     XmlNode node = GetByID(id);
     if (node == null)
     {
         return;
     }
     switch (setType)
     {
         case SetType.InnerText:
             text = node.InnerText;
             break;
         case SetType.InnerXml:
             text = node.InnerXml;
             break;
         case SetType.Value:
         case SetType.Href:
         case SetType.Src:
         case SetType.Class:
             string key = setType.ToString().ToLower();
             if (node.Attributes[key] != null)
             {
                 text = node.Attributes[key].Value;
             }
             break;
     }
     SetForeach(node, text, formatValues);
 }
开发者ID:Angliy,项目名称:Common,代码行数:29,代码来源:XmlHelper.cs

示例3: RemoveAttrList

 /// <summary>
 /// �����Ƴ�
 /// </summary>
 /// <param name="attrName">��������</param>
 /// <param name="excludeSetType">�ų��Ľڵ�����</param>
 public void RemoveAttrList(string attrName, SetType excludeSetType)
 {
     XmlNodeList nodeList = GetList("*", attrName);
     if (nodeList != null && nodeList.Count > 0)
     {
         XmlNode node = null;
         string setType = excludeSetType.ToString().ToLower();
         for (int i = 0; i < nodeList.Count; i++)
         {
             node = nodeList[i];
             if (node.Name != setType)
             {
                 node.Attributes.Remove(node.Attributes[attrName]);
             }
         }
     }
 }
开发者ID:Feng2012,项目名称:cyqdata,代码行数:22,代码来源:XHtmlAction.cs

示例4: Set

 public void Set(XmlNode node, SetType setType, params string[] values)
 {
     if (node != null)
     {
         switch (setType)
         {
             case SetType.InnerText:
                 node.InnerText = SetValue(node.InnerText, values[0], false);
                 break;
             case SetType.InnerXml:
                 node.InnerXml = SetValue(node.InnerXml, values[0], true);
                 break;
             case SetType.Value:
             case SetType.Href:
             case SetType.Src:
             case SetType.Class:
             case SetType.Disabled:
             case SetType.ID:
             case SetType.Name:
                 string key = setType.ToString().ToLower();
                 SetAttrValue(node, key, values[0]);
                 break;
             case SetType.Custom:
                 SetAttrValue(node, values[0], values[1]);
                 break;
             case SetType.A:
                 node.InnerXml = SetValue(node.InnerXml, values[0], true);
                 if (values.Length > 1)
                 {
                     SetAttrValue(node, "href", values[1]);
                 }
                 break;
             case SetType.Select:
                 foreach (XmlNode option in node.ChildNodes)
                 {
                     if (option.Attributes["value"] != null && option.Attributes["value"].Value == values[0])
                     {
                         SetAttrValue(option, "selected", "selected");
                         break;
                     }
                 }
                 break;
             case SetType.Checked:
                 if (values[0] == "1" || values[0].ToLower() == "true")
                 {
                     key = setType.ToString().ToLower();
                     SetAttrValue(node, key, key);
                 }
                 break;
         }
     }
 }
开发者ID:Angliy,项目名称:Common,代码行数:52,代码来源:XmlHelper.cs


注:本文中的SetType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。