zoukankan      html  css  js  c++  java
  • 遍历接口中所有成员

    i设备基本资料 targetEquip = ios.CreateObject<i设备基本资料>();
    foreach (var mi in Equip.GetType().GetMembers())
    {
    switch (mi.MemberType)
    {
    case System.Reflection.MemberTypes.Constructor:

    break;
    case System.Reflection.MemberTypes.Event:

    break;
    case System.Reflection.MemberTypes.Field:
    break;
    case System.Reflection.MemberTypes.Method:

    break;
    case System.Reflection.MemberTypes.Property:
    if (mi.Name != "Oid" )
    {
    PropertyInfo pi = Equip.GetType().GetProperty(mi.Name);
    if (pi.CanWrite)
    {
    object value = pi.GetValue(Equip, null);
    if (value != null) //value = "null";
    pi.SetValue(targetEquip, value, null);
    //targetEquip.GetType().GetProperty(mi.Name).SetValue(value.GetType(), value, null);
    }
    }
    break;
    case System.Reflection.MemberTypes.TypeInfo:

    break;
    case System.Reflection.MemberTypes.Custom:

    break;
    case System.Reflection.MemberTypes.NestedType:

    break;
    case System.Reflection.MemberTypes.All:

    break;
    default:
    throw new Exception("Invalid value for MemberTypes");
    }
    }

  • 相关阅读:
    Gym
    Gym
    Gym
    LA 3713 宇航员分组
    LA 3211 飞机调度(2—SAT)
    POJ 1050 To The Max
    51nod 1050 循环数组最大子段和
    UVa 11149 矩阵的幂(矩阵倍增法模板题)
    POJ 1236 Network of School
    UVa 11324 最大团(强连通分量缩点)
  • 原文地址:https://www.cnblogs.com/jacker1979/p/2344448.html
Copyright © 2011-2022 走看看