当前位置: 首页>>代码示例>>C#>>正文


C# IAttributesCollection.ContainsKey方法代码示例

本文整理汇总了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);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:18,代码来源:OldClass.cs

示例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);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:25,代码来源:PythonType.cs

示例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;
         }
     }
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:8,代码来源:PythonType.cs

示例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);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:40,代码来源:PythonType.cs


注:本文中的IAttributesCollection.ContainsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。