本文整理汇总了C#中PyObject.Attributes方法的典型用法代码示例。如果您正苦于以下问题:C# PyObject.Attributes方法的具体用法?C# PyObject.Attributes怎么用?C# PyObject.Attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyObject
的用法示例。
在下文中一共展示了PyObject.Attributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListPyObject
private void ListPyObject(PyObject pyObject)
{
PyType type;
switch (_typeMode)
{
case TypeMode.Value:
// Fill the value here
var value = new PyValue();
value.Attribute = "(this)";
value.Value = GetPyValue(pyObject);
value.Type = pyObject.GetPyType().ToString();
_values.Add(value);
return;
case TypeMode.Class:
// Force it to unknown
type = PyType.Unknown;
break;
case TypeMode.List:
// Force it to a list
type = PyType.ListType;
break;
case TypeMode.Tuple:
// Force it to a tuple
type = PyType.TupleType;
break;
case TypeMode.Dictionary:
// Force it to a dictionary
type = PyType.DictType;
break;
default:
// Let the type decide
type = pyObject.GetPyType();
break;
}
switch (type)
{
case PyType.DictType:
case PyType.DictProxyType:
case PyType.DerivedDictType:
case PyType.DerivedDictProxyType:
foreach (var attribute in pyObject.ToDictionary())
{
var item = new PyValue();
item.Attribute = GetPyValue(attribute.Key);
item.Value = GetPyValue(attribute.Value);
item.Type = attribute.Value.GetPyType().ToString();
item.Eval = _evaluate + "[" + item.Attribute + "]";
_values.Add(item);
}
break;
case PyType.ListType:
case PyType.TupleType:
case PyType.DerivedListType:
case PyType.DerivedTupleType:
var length = pyObject.Size(type);
for (var i = 0; i < length; i++)
{
var item = new PyValue();
item.Attribute = i.ToString();
item.Value = GetPyValue(pyObject.Item(i, type));
item.Type = pyObject.Item(i, type).GetPyType().ToString();
item.Eval = _evaluate + "[" + i + "]";
_values.Add(item);
}
break;
default:
foreach (var attribute in pyObject.Attributes())
{
var item = new PyValue();
item.Attribute = attribute.Key;
item.Value = GetPyValue(attribute.Value);
item.Type = attribute.Value.GetPyType().ToString();
item.Eval = _evaluate + "." + attribute.Key;
_values.Add(item);
}
break;
}
}