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


C# ICallerContext类代码示例

本文整理汇总了C#中ICallerContext的典型用法代码示例。如果您正苦于以下问题:C# ICallerContext类的具体用法?C# ICallerContext怎么用?C# ICallerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ICallerContext类属于命名空间,在下文中一共展示了ICallerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Call

 public override object Call(ICallerContext context, params object[] args)
 {
     switch (args.Length) {
         case 0: return Call(context);
         default: throw BadArgumentError(args.Length);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Function.Generated.cs

示例2: GetAttrNames

        public List GetAttrNames(ICallerContext context)
        {
            LoadAllTypes();

            List res = new List(((IDictionary<object, object>)__dict__).Keys);
            res.Sort();
            return res;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:8,代码来源:ReflectedPackage.cs

示例3: KwArgBinder

 public KwArgBinder(ICallerContext context, object[] args, string[] keyNames, bool allowUnboundArgs)
 {
     arguments = args;
     kwNames = keyNames;
     Debug.Assert(keyNames.Length <= args.Length);
     fAllowUnboundArgs = allowUnboundArgs;
     ctx = context;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:8,代码来源:kwargbinder.cs

示例4: FindModule

 public static Tuple FindModule(ICallerContext context, string name, List path)
 {
     if (path == null) {
         return FindBuiltinOrSysPath(context, name);
     } else {
         return FindModulePath(context, name, path);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:8,代码来源:imp.cs

示例5: GetAttrNames

        public override List GetAttrNames(ICallerContext context, object self)
        {
            Assembly asm = self as Assembly;
            TopReflectedPackage reflectedAssembly = GetReflectedAssembly(context.SystemState, asm);

            List ret = base.GetAttrNames(context, self);

            ret.AddRange(reflectedAssembly.GetAttrNames(context));
            return ret;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:10,代码来源:ReflectedAssembly.cs

示例6: TryGetAttr

        public override bool TryGetAttr(ICallerContext context, object self, SymbolId name, out object ret)
        {
            if (base.TryGetAttr(context, self, name, out ret)) {
                return true;
            }

            // This will force creation of the instances dict
            IAttributesDictionary dict = ((ISuperDynamicObject)self).GetDict();
            return dict.TryGetValue(name, out ret);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:10,代码来源:CompiledType.cs

示例7: Call

        public object Call(ICallerContext context, object[] args, string[] names)
        {
            object targetMethod;
            if (!Ops.GetDynamicType(target).TryLookupBoundSlot(context, target, name, out targetMethod))
                throw Ops.AttributeError("type {0} has no attribute {1}",
                    Ops.GetDynamicType(target.Target),
                    name.ToString());

            return Ops.Call(context, targetMethod, args, names);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:10,代码来源:_weakref.cs

示例8: GetAttrDict

        public override Dict GetAttrDict(ICallerContext context, object self)
        {
            List attrs = GetAttrNames(context, self);

            Dict res = new Dict();
            foreach (string o in attrs) {
                res[o] = GetAttr(context, self, SymbolTable.StringToId(o));
            }

            return res;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:11,代码来源:ReflectedAssembly.cs

示例9: SetAttr

        public override void SetAttr(ICallerContext context, object self, SymbolId name, object value)
        {
            object slot;
            bool success = TryGetSlot(context, name, out slot);
            if (success) {
                success = Ops.SetDescriptor(slot, self, value);
            }

            if (!success) {
                // otherwise update the instance
                IAttributesDictionary dict = ((ISuperDynamicObject)self).GetDict();
                dict[name] = value;
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:14,代码来源:CompiledType.cs

示例10: TryGetAttr

        public override bool TryGetAttr(ICallerContext context, object self, SymbolId name, out object ret)
        {
            Assembly asm = self as Assembly;
            TopReflectedPackage reflectedAssembly = GetReflectedAssembly(context.SystemState, asm);

            if (name == SymbolTable.Dict) {
                ret = reflectedAssembly.GetAttrDict(context);
                return true;
            }

            if (base.TryGetAttr(context, self, name, out ret)) {
                return true;
            }

            if (!reflectedAssembly.TryGetAttr(context, name, out ret))
                throw Ops.AttributeError("assembly {0} has no type {1}", asm.GetName().Name, name);

            return true;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:19,代码来源:ReflectedAssembly.cs

示例11: ReduceProtocol2

        /// <summary>
        /// Implements the default __reduce_ex__ method as specified by PEP 307 case 3 (new-style instance, protocol 2)
        /// </summary>
        private static Tuple ReduceProtocol2(ICallerContext context, object self)
        {
            DynamicType myType = Ops.GetDynamicType(self);

            object func, state, listIterator, dictIterator;
            object[] funcArgs;

            func = PythonCopyReg.PythonNewObject;

            object getNewArgsCallable;
            if (Ops.TryGetAttr(myType, SymbolTable.GetNewArgs, out getNewArgsCallable)) {
                // TypeError will bubble up if __getnewargs__ isn't callable
                Tuple newArgs = Ops.Call(getNewArgsCallable, self) as Tuple;
                if (newArgs == null) {
                    throw Ops.TypeError("__getnewargs__ should return a tuple");
                }
                funcArgs = new object[1 + newArgs.Count];
                funcArgs[0] = myType;
                for (int i = 0; i < newArgs.Count; i++) funcArgs[i + 1] = newArgs[i];
            } else {
                funcArgs = new object[] { myType };
            }

            if (!Ops.TryInvokeSpecialMethod(self, SymbolTable.GetState, out state)) {
                object dict;
                if (!Ops.TryGetAttr(self, SymbolTable.Dict, out dict)) {
                    dict = null;
                }

                Dict initializedSlotValues = GetInitializedSlotValues(self);
                if (initializedSlotValues != null && initializedSlotValues.Count == 0) {
                    initializedSlotValues = null;
                }

                if (dict == null && initializedSlotValues == null) state = null;
                else if (dict != null && initializedSlotValues == null) state = dict;
                else if (dict != null && initializedSlotValues != null) state = Tuple.MakeTuple(dict, initializedSlotValues);
                else   /*dict == null && initializedSlotValues != null*/ state = Tuple.MakeTuple(null, initializedSlotValues);
            }

            listIterator = null;
            if (self is List) {
                listIterator = Ops.GetEnumerator(self);
            }

            dictIterator = null;
            if (self is Dict) {
                dictIterator = Ops.Invoke(self, SymbolTable.IterItems, Ops.EMPTY);
            }

            return Tuple.MakeTuple(func, Tuple.MakeTuple(funcArgs), state, listIterator, dictIterator);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:55,代码来源:ObjectOps.cs

示例12: Reduce

 public static object Reduce(ICallerContext context, object self)
 {
     return Reduce(context, self, 0);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:ObjectOps.cs

示例13: SaveReduce

            /// <summary>
            /// Pickle the result of a reduce function.
            /// 
            /// Only context, obj, func, and reduceCallable are required; all other arguments may be null.
            /// </summary>
            private void SaveReduce(ICallerContext context, object obj, object reduceCallable, object func, object args, object state, object listItems, object dictItems)
            {
                if (!Ops.IsCallable(func)) {
                    throw CannotPickle(obj, "func from reduce() should be callable");
                } else if (!(args is Tuple) && args != null) {
                    throw CannotPickle(obj, "args from reduce() should be a tuple");
                } else if (listItems != null && !(listItems is IEnumerator)) {
                    throw CannotPickle(obj, "listitems from reduce() should be a list iterator");
                } else if (dictItems != null && !(dictItems is IEnumerator)) {
                    throw CannotPickle(obj, "dictitems from reduce() should be a dict iterator");
                }

                object funcName;
                string funcNameString;
                if (!Ops.TryGetAttr(func, SymbolTable.Name, out funcName)) {
                    throw CannotPickle(obj, "func from reduce() ({0}) should have a __name__ attribute");
                } else if (!Converter.TryConvertToString(funcName, out funcNameString) || funcNameString == null) {
                    throw CannotPickle(obj, "__name__ of func from reduce() must be string");
                }

                if (protocol >= 2 && "__newobj__" == funcNameString) {
                    if (args == null) {
                        throw CannotPickle(obj, "__newobj__ arglist is None");
                    }
                    Tuple argsTuple = (Tuple)args;
                    if (argsTuple.Count == 0) {
                        throw CannotPickle(obj, "__newobj__ arglist is empty");
                    } else if (!Ops.GetDynamicType(obj).Equals(argsTuple[0])) {
                        throw CannotPickle(obj, "args[0] from __newobj__ args has the wrong class");
                    }
                    Save(context, argsTuple[0]);
                    Save(context, argsTuple[new Slice(1, null)]);
                    Write(Opcode.NewObj);
                } else {
                    Save(context, func);
                    Save(context, args);
                    Write(Opcode.Reduce);
                }

                WritePut(obj);

                if (state != null) {
                    Save(context, state);
                    Write(Opcode.Build);
                }

                if (listItems != null) {
                    BatchAppends(context, (IEnumerator)listItems);
                }

                if (dictItems != null) {
                    BatchSetItems(context, (IEnumerator)dictItems);
                }
            }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:59,代码来源:cPickle.cs

示例14: ReduceProtocol0

        /// <summary>
        /// Implements the default __reduce_ex__ method as specified by PEP 307 case 2 (new-style instance, protocol 0 or 1)
        /// </summary>
        private static Tuple ReduceProtocol0(ICallerContext context, object self)
        {
            // CPython implements this in copy_reg._reduce_ex

            DynamicType myType = Ops.GetDynamicType(self); // PEP 307 calls this "D"
            ThrowIfNativelyPickable(myType);

            object getState;
            bool hasGetState = Ops.TryGetAttr(self, SymbolTable.GetState, out getState);

            object slots;
            if (Ops.TryGetAttr(myType, SymbolTable.Slots, out slots) && Ops.Length(slots) > 0 && !hasGetState) {
                // ??? does this work with superclass slots?
                throw Ops.TypeError("a class that defines __slots__ without defining __getstate__ cannot be pickled with protocols 0 or 1");
            }

            DynamicType closestNonPythonBase = FindClosestNonPythonBase(myType); // PEP 307 calls this "B"

            object func = PythonCopyReg.PythonReconstructor;

            object funcArgs = Tuple.MakeTuple(
                myType,
                closestNonPythonBase,
                TypeCache.Object == closestNonPythonBase ? null : Ops.Call(closestNonPythonBase, self)
            );

            object state;
            if (hasGetState) {
                state = Ops.Call(getState);
            } else {
                Ops.TryGetAttr(self, SymbolTable.Dict, out state);
            }
            if (!Ops.IsTrue(state)) state = null;

            return Tuple.MakeTuple(func, funcArgs, state);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:39,代码来源:ObjectOps.cs

示例15: SaveDict

            private void SaveDict(ICallerContext context, object obj)
            {
                Debug.Assert(Ops.GetDynamicType(obj).Equals(TypeCache.Dict), "arg must be dict");
                Debug.Assert(!memo.Contains(Ops.Id(obj)));
                Memoize(obj);

                if (protocol < 1) {
                    Write(Opcode.Mark);
                    Write(Opcode.Dict);
                } else {
                    Write(Opcode.EmptyDict);
                }

                WritePut(obj);
                BatchSetItems(context, (DictOps.IterItems((IDictionary<object, object>)obj)));
            }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:16,代码来源:cPickle.cs


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