本文整理汇总了C#中IAttributesCollection.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# IAttributesCollection.ContainsKey方法的具体用法?C# IAttributesCollection.ContainsKey怎么用?C# IAttributesCollection.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttributesCollection
的用法示例。
在下文中一共展示了IAttributesCollection.ContainsKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: __new__
public static object __new__(CodeContext/*!*/ context, [NotNull]PythonType cls, string name, PythonTuple bases, IAttributesCollection dict) {
if (cls != TypeCache.OldClass) throw PythonOps.TypeError("{0} is not a subtype of classobj", cls.Name);
if (!dict.ContainsKey(Symbols.Module)) {
object moduleValue;
if (context.GlobalScope.TryGetVariable(Symbols.Name, out moduleValue)) {
dict[Symbols.Module] = moduleValue;
}
}
foreach (object o in bases) {
if (o is PythonType) {
return PythonOps.MakeClass(context, name, bases._data, String.Empty, dict);
}
}
return new OldClass(name, bases, dict, String.Empty);
}
示例2: BuildUserTypeDictionary
private void BuildUserTypeDictionary(CodeContext context, IAttributesCollection vars) {
bool hasDictionary = false, hasWeakRef = false;
if (vars.ContainsKey(Symbols.Slots)) {
List<string> slots = NewTypeMaker.SlotsToList(vars[Symbols.Slots]);
_originalSlotCount += slots.Count;
if (slots.Contains("__dict__")) hasDictionary = true;
if (slots.Contains("__weakref__")) hasWeakRef = true;
} else {
hasDictionary = true;
hasWeakRef = true;
}
EnsureDict();
if (hasWeakRef && !vars.ContainsKey(Symbols.WeakRef)) {
AddSlot(Symbols.WeakRef, new PythonTypeWeakRefSlot(this));
}
if (!vars.ContainsKey(Symbols.Dict) && hasDictionary) {
AddSlot(Symbols.Dict, new PythonTypeDictSlot(this));
}
PopulateSlots(context, vars);
}
示例3: EnsureModule
private static void EnsureModule(CodeContext context, IAttributesCollection dict) {
if (!dict.ContainsKey(Symbols.Module)) {
object modName;
if (context.Scope.TryLookupName(Symbols.Name, out modName)) {
dict[Symbols.Module] = modName;
}
}
}
示例4: InitializeUserType
private void InitializeUserType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection vars) {
// we don't support overriding __mro__
if (vars.ContainsKey(Symbols.MethodResolutionOrder))
throw new NotImplementedException("Overriding __mro__ of built-in types is not implemented");
// cannot override mro when inheriting from type
if (vars.ContainsKey(SymbolTable.StringToId("mro"))) {
foreach (object o in bases) {
PythonType dt = o as PythonType;
if (dt != null && dt.IsSubclassOf(TypeCache.PythonType)) {
throw new NotImplementedException("Overriding type.mro is not implemented");
}
}
}
bases = ValidateBases(bases);
_name = name;
_bases = GetBasesAsList(bases).ToArray();
_pythonContext = PythonContext.GetContext(context);
_resolutionOrder = CalculateMro(this, _bases);
foreach (PythonType pt in _bases) {
pt.AddSubType(this);
_originalSlotCount += pt.SlotCount;
}
BuildUserTypeDictionary(context, vars);
InitializeSlots(name, bases, vars);
// calculate the .NET type once so it can be used for things like super calls
_underlyingSystemType = NewTypeMaker.GetNewType(name, bases, vars);
// then let the user intercept and rewrite the type - the user can't create
// instances of this type yet.
_underlyingSystemType = __clrtype__();
// finally assign the ctors from the real type the user provided
_ctor = BuiltinFunction.MakeMethod(Name, _underlyingSystemType.GetConstructors(), _underlyingSystemType, FunctionType.Function);
}