我想获取一个对象,并使用反射将类属性映射到var adjustmentSum = 0
var baseCurve = 45.00
var diameter = 9.0
let diameterAdjustmentValue : Float = 0.1
let baseCurveAdjustmentValue : Float = 0.25
@IBAction func increaseDiameter(sender: AnyObject) {
adjustmentSum++
diameter = diameter + diameterAdjustmentValue
if adjustmentSum == 5 {
baseCurve = baseCurve - baseCurveAdjustmentValue
adjustmentSum = 0
}
}
@IBAction func decreaseDiameter(sender: AnyObject) {
adjustmentSum--
diameter = diameter - diameterAdjustmentValue
if adjustmentSum == 5 {
baseCurve = baseCurve + baseCurveAdjustmentValue
adjustmentSum = 0
}
}
KeyValuePair
,String
。
不是那么简单,因为类有一些子类,子类也可以有一个子类。
我的想法以String
列表结束,该列表将对象与子类映射。
这样的事情:
KeyValuePair
答案 0 :(得分:1)
我通常这样做
public class Node
{
public Dictionary<string, string> dict = new Dictionary<string, string>();
public List<Node> children = new List<Node>();
}