本文整理汇总了C#中PythonDictionary.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# PythonDictionary.TryGetValue方法的具体用法?C# PythonDictionary.TryGetValue怎么用?C# PythonDictionary.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonDictionary
的用法示例。
在下文中一共展示了PythonDictionary.TryGetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StructType
private static readonly Field[] _emptyFields = new Field[0]; // fields were never initialized before a type was created
public StructType(CodeContext/*!*/ context, string name, PythonTuple bases, PythonDictionary members)
: base(context, name, bases, members) {
foreach (PythonType pt in ResolutionOrder) {
StructType st = pt as StructType;
if (st != this && st != null) {
st.EnsureFinal();
}
UnionType ut = pt as UnionType;
if (ut != null) {
ut.EnsureFinal();
}
}
object pack;
if (members.TryGetValue("_pack_", out pack)) {
if (!(pack is int) || ((int)pack < 0)) {
throw PythonOps.ValueError("pack must be a non-negative integer");
}
_pack = (int)pack;
}
object fields;
if (members.TryGetValue("_fields_", out fields)) {
SetFields(fields);
}
// TODO: _anonymous_
}
示例2: ArrayType
public ArrayType(CodeContext/*!*/ context, string name, PythonTuple bases, PythonDictionary dict)
: base(context, name, bases, dict) {
object len;
int iLen;
if (!dict.TryGetValue("_length_", out len) || !(len is int) || (iLen = (int)len) < 0) {
throw PythonOps.AttributeError("arrays must have _length_ attribute and it must be a positive integer");
}
object type;
if (!dict.TryGetValue("_type_", out type)) {
throw PythonOps.AttributeError("class must define a '_type_' attribute");
}
_length = iLen;
_type = (INativeType)type;
if (_type is SimpleType) {
SimpleType st = (SimpleType)_type;
if (st._type == SimpleTypeKind.Char) {
// TODO: (c_int * 2).value isn't working
SetCustomMember(context,
"value",
new ReflectedExtensionProperty(
new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetCharArrayValue")),
NameType.Property | NameType.Python
)
);
SetCustomMember(context,
"raw",
new ReflectedExtensionProperty(
new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayRaw")),
NameType.Property | NameType.Python
)
);
} else if (st._type == SimpleTypeKind.WChar) {
SetCustomMember(context,
"value",
new ReflectedExtensionProperty(
new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayValue")),
NameType.Property | NameType.Python
)
);
SetCustomMember(context,
"raw",
new ReflectedExtensionProperty(
new ExtensionPropertyInfo(this, typeof(CTypes).GetMethod("GetWCharArrayRaw")),
NameType.Property | NameType.Python
)
);
}
}
}
示例3: UnionType
public UnionType(CodeContext/*!*/ context, string name, PythonTuple bases, PythonDictionary members)
: base(context, name, bases, members) {
object fields;
if (members.TryGetValue("_fields_", out fields)) {
SetFields(fields);
}
}
示例4: PointerType
public PointerType(CodeContext/*!*/ context, string name, PythonTuple bases, PythonDictionary members)
: base(context, name, bases, members) {
object type;
if (members.TryGetValue("_type_", out type) && !(type is INativeType)) {
throw PythonOps.TypeError("_type_ must be a type");
}
_type = (INativeType)type;
if (_type != null) {
_typeFormat = _type.TypeFormat;
}
}
示例5: TryGetDictValue
private static bool TryGetDictValue(PythonDictionary dict, string name, out object dictTime) {
if (dict != null && dict.TryGetValue(name, out dictTime)) {
dictTime = TryShrinkToInt(dictTime);
return true;
}
dictTime = null;
return false;
}