本文整理汇总了C#中Scope.TryGetName方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.TryGetName方法的具体用法?C# Scope.TryGetName怎么用?C# Scope.TryGetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.TryGetName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: __getattribute__
public static object __getattribute__(Scope/*!*/ self, string name) {
SymbolId si = SymbolTable.StringToId(name);
object res;
if (self.TryGetName(si, out res)) {
return res;
}
throw PythonOps.AttributeErrorForMissingAttribute("module", si);
}
示例2: __getattribute__
public static object __getattribute__(CodeContext/*!*/ context, Scope/*!*/ self, string name) {
switch (name) {
// never look in the dict for these...
case "__dict__": return Get__dict__(self);
case "__class__": return DynamicHelpers.GetPythonType(self);
}
SymbolId si = SymbolTable.StringToId(name);
object res;
if (self.TryGetName(si, out res)) {
return res;
}
// fall back to object to provide all of our other attributes (e.g. __setattr__, etc...)
return ObjectOps.__getattribute__(context, self, name);
}
示例3: TryGetNestedModule
private static bool TryGetNestedModule(CodeContext/*!*/ context, Scope/*!*/ scope, string/*!*/ name, out object nested) {
Assert.NotNull(context, scope, name);
if (scope.TryGetName(SymbolTable.StringToId(name), out nested)) {
if (nested is Scope) return true;
// This allows from System.Math import *
PythonType dt = nested as PythonType;
if (dt != null && dt.IsSystemType) {
return true;
}
}
return false;
}
示例4: GetParentPathAndScope
/// <summary>
/// Given the parent module name looks up the __path__ property.
/// </summary>
private static List GetParentPathAndScope(CodeContext/*!*/ context, string/*!*/ parentModuleName, out Scope parentScope) {
List path = null;
object parentModule;
parentScope = null;
// Try lookup parent module in the sys.modules
if (PythonContext.GetContext(context).SystemStateModules.TryGetValue(parentModuleName, out parentModule)) {
// see if it's a module
parentScope = parentModule as Scope;
if (parentScope != null) {
object objPath;
// get its path as a List if it's there
if (parentScope.TryGetName(Symbols.Path, out objPath)) {
path = objPath as List;
}
}
}
return path;
}
示例5: GetCustomMember
public static object GetCustomMember(CodeContext/*!*/ context, Scope/*!*/ scope, string name) {
object value;
if (scope.TryGetName(SymbolTable.StringToId(name), out value)) {
if (value != Uninitialized.Instance) {
return value;
}
}
return OperationFailed.Value;
}
示例6: ScopeContains
private static bool ScopeContains(object key, Scope scope) {
string strKey = key as string;
if (strKey != null) {
object dummy;
if (scope.TryGetName(SymbolTable.StringToId(strKey), out dummy)) {
return true;
}
} else {
object dummy;
if (scope.TryGetObjectName(key, out dummy)) {
return true;
}
}
return false;
}