zoukankan      html  css  js  c++  java
  • wp7 xml

    public class DynamicXMLNode : DynamicObject
    {
    XElement node;
    public DynamicXMLNode(XElement node)
    {
    this.node = node;
    }
    public DynamicXMLNode()
    {
    }
    public DynamicXMLNode(String name)
    {
    node = new XElement(name);
    }
    public override bool TrySetMember(
    SetMemberBinder binder, object value)
    {
    XElement setNode = node.Element(binder.Name);
    if (setNode != null)
    setNode.SetValue(value);
    else
    {
    if (value.GetType() == typeof(DynamicXMLNode))
    node.Add(new XElement(binder.Name));
    else
    node.Add(new XElement(binder.Name, value));
    }
    return true;
    }
    public override bool TryGetMember(
    GetMemberBinder binder, out object result)
    {
    XElement getNode = node.Element(binder.Name);
    if (getNode != null)
    {
    result = new DynamicXMLNode(getNode);
    return true;
    }
    else
    {
    result = null;
    return false;
    }
    }

    public override bool TryConvert(
    ConvertBinder binder, out object result)
    {
    if (binder.Type == typeof(String))
    {
    result = node.Value;
    return true;
    }
    else
    {
    result = null;
    return false;
    }
    }

    public override bool TryInvokeMember(
    InvokeMemberBinder binder,
    object[] args,
    out object result)
    {
    Type xmlType = typeof(XElement);
    try
    {
    result = xmlType.InvokeMember(
    binder.Name,
    BindingFlags.InvokeMethod |
    BindingFlags.Public |
    BindingFlags.Instance,
    null, node, args);
    return true;
    }
    catch
    {
    result = null;
    return false;
    }
    }

    }

  • 相关阅读:
    HDU-5980
    HDU-5974
    HDU-5979
    关于position的定位
    javascript学习笔记w3chool
    表单相关css技巧
    fis压缩工具的使用
    将HTML页面内容存入json数组
    中介PHP连接前台HTML与数据库MySQL
    lesscss的使用
  • 原文地址:https://www.cnblogs.com/androllen/p/3484625.html
Copyright © 2011-2022 走看看