本文整理汇总了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:
//.........这里部分代码省略.........
示例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);
}
示例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]);
}
}
}
}
示例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;
}
}
}