• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PythonDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PerformModuleReload

        public static void PerformModuleReload(PythonContext context, PythonDictionary dict) {
            if (!context.HasModuleState(_zip_directory_cache_key))
                context.SetModuleState(_zip_directory_cache_key, new PythonDictionary());

            dict["_zip_directory_cache"] = context.GetModuleState(_zip_directory_cache_key);
            InitModuleExceptions(context, dict);
        }
开发者ID:Gerhman,项目名称:IronLanguages,代码行数:7,代码来源:zipimport.cs


示例2: IronPythonUpdateProcessor

        /// <summary>APIの設定を用いてインスタンスを初期化します。 </summary>
        /// <param name="api">IronPython用APIの何らかの実装</param>
        /// <param name="setting">更新処理の設定</param>
        /// <param name="dictionary">キャラに対応するグローバル変数用にディクショナリ</param>
        public IronPythonUpdateProcessor(IScriptApi api, IScriptUpdateSetting setting, PythonDictionary dictionary)
        {
            _setting = setting;

            var engine = Python.CreateEngine();

            //名前参照にexeのディレクトリとキャラのディレクトリを追加
            var paths = engine.GetSearchPaths();
            paths.Add(Environment.CurrentDirectory);
            paths.Add(DirectoryNames.GetCharacterScriptDirectory(api.CharacterName));
            engine.SetSearchPaths(paths);

            //可視領域を限界まで広く取るためビルトインスコープにぶち込んでおく
            ScriptScope builtin = engine.GetBuiltinModule();
            builtin.SetVariable(IronPythonCommonVariableNames.ApiVariableName, api);
            builtin.SetVariable(IronPythonCommonVariableNames.ApiGlobalDictionaryName, dictionary);

            string path = Path.Combine(DirectoryNames.GetCharacterScriptDirectory(api.CharacterName), UpdateScriptName);

            //高スピードで読むので先にコンパイル
            try
            {
                _updateCode = engine.CreateScriptSourceFromFile(path).Compile();
                IsValid = true;
            }
            catch (Exception)
            {
                IsValid = false;
            }
        }
开发者ID:malaybaku,项目名称:harriet,代码行数:34,代码来源:IronPythonUpdateProcessor.cs


示例3: PerformModuleReload

        public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {            
            var socket = context.GetBuiltinModule("socket");
            var socketError = PythonSocket.GetSocketError(context, socket.__dict__);
            
            context.EnsureModuleException("SSLError", socketError, dict, "SSLError", "ssl");

        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:7,代码来源:_ssl.cs


示例4: Py_InitModule4

        Py_InitModule4(string name, IntPtr methodsPtr, string doc, IntPtr selfPtr, int apiver)
        {
            name = this.FixImportName(name);
            
            PythonDictionary methodTable = new PythonDictionary();
            PythonModule module = new PythonModule();
            this.AddModule(name, module);
            this.CreateModulesContaining(name);

            PythonDictionary __dict__ = module.Get__dict__();
            __dict__["__doc__"] = doc;
            __dict__["__name__"] = name;
            string __file__ = this.importFiles.Peek();
            __dict__["__file__"] = __file__;
            List __path__ = new List();
            if (__file__ != null)
            {
                __path__.append(Path.GetDirectoryName(__file__));
            }
            __dict__["__path__"] = __path__;
            __dict__["_dispatcher"] = new Dispatcher(this, methodTable, selfPtr);

            StringBuilder moduleCode = new StringBuilder();
            moduleCode.Append(CodeSnippets.USEFUL_IMPORTS);
            CallableBuilder.GenerateFunctions(moduleCode, methodsPtr, methodTable);
            this.ExecInModule(moduleCode.ToString(), module);
            
            return this.Store(module);
        }
开发者ID:netcharm,项目名称:ironclad,代码行数:29,代码来源:PythonMapper_module.cs


示例5: Argument

        public Argument(PythonBoss pyBoss, long address, PythonDictionary spec, Process process, int depth, Arguments parent, string namePrefix)
        {
            Address = address;
            this.process = process;
            _pyBoss = pyBoss;
            _parent = parent;
            NamePrefix = namePrefix;

            // Parse the spec for this argument
            // stackspec: [{"name": "socket",
            //		      "size": 4,
            //		      "type": None,
            //		      "fuzz": NOFUZZ,
            //            "type_args": None},]

            Fuzz = (bool)spec.get("fuzz");
            Name = (string)spec.get("name");
            _argumentType = (object)spec.get("type");
            if ( spec.ContainsKey("type_args") )
            {
                _typeArgs = spec.get("type_args");
            }

            // Validate required fields
            if (Name == null)
                throw new Exception("ERROR: Argument specification must include 'name' attribute. Failed when parsing name prefix '" + namePrefix + "'.");
            else if (Fuzz == null)
                throw new Exception("ERROR: Argument specification must include 'fuzz' attribute. Failed when parsing type '" + namePrefix + Name + "'.");
            else if (spec.get("size") == null)
                throw new Exception("ERROR: Argument specification must include 'size' attribute. Failed when parsing type '" + namePrefix + Name + "'.");

            if (spec.get("size") is string)
            {
                object sizeArgument = null;
                if (parent.TryGetMemberSearchUp((string)spec.get("size"), out sizeArgument))
                    Size = ((Argument)sizeArgument).ToInt();
                else
                    throw new Exception("ERROR: Unable to load size for type '" + Name + "' from parent member named '" + (string)spec.get("size") + "'. Please make sure this field exists in the parent.");
            }
            else if (spec.get("size") is int)
            {
                Size = (int)spec.get("size");
            }
            else
            {
                throw new Exception("ERROR: Unable to load size for type '" + Name + "'. The size must be of type 'int' or type 'string'. Size is type: '" + spec.get("size").ToString() + "'" );
            }

            // Read the data
            try
            {
                Data = MemoryFunctions.ReadMemory(process.ProcessDotNet, address, (uint)Size);
            }
            catch (Exception e)
            {
                Data = null;
            }

            PointerTarget = null;
        }
开发者ID:Zinterax,项目名称:meddle,代码行数:60,代码来源:Arguments.cs


示例6: PythonModule

 public PythonModule() {
     _dict = new PythonDictionary();
     if (GetType() != typeof(PythonModule) && this is IPythonObject) {
         // we should share the user dict w/ our dict.
         ((IPythonObject)this).ReplaceDict(_dict);
     }
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:7,代码来源:PythonModule.cs


示例7: 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_
            }
开发者ID:atczyc,项目名称:ironruby,代码行数:32,代码来源:StructType.cs


示例8: Initialize

        /// <summary>フィールド初期化を行います。</summary>
        private void Initialize()
        {
            var chatWindowPosition = new ChatWindowPositionModel(
                _mainWindow,
                _setting.ChatWindowLayout,
                _relocator
                );

            _chatWindow = new ChatWindowModel(chatWindowPosition);

            var voiceOperator = new VoiceOperator(_setting.Voice);
            voiceOperator.LipSynchRequested += (_, e) => _lipSyncher = e.LipSyncher;

            var scriptRequestor = new SimpleScriptRequestor();

            var api = new ScriptApi(
                _mainWindow, _character, voiceOperator, _chatWindow, scriptRequestor,
                _setting,
                _setting.ScriptApi,
                _characterName
                );

            var dict = new PythonDictionary();
            _updateProcessor = new IronPythonUpdateProcessor(api, _setting.ScriptUpdate, dict);

            var ironPythonReader = new IronPythonMainScriptReader(api, dict);
            _scriptStateManager = new ScriptStateManager(ironPythonReader, _setting.ScriptRoutine, _characterName);

            scriptRequestor.ScriptRequested += (_, e) => _scriptStateManager.Request(
                e.ScriptName,
                e.Priority
                );

        }
开发者ID:malaybaku,项目名称:harriet,代码行数:35,代码来源:ScriptingOperator.cs


示例9: PythonFunction

        /// <summary>
        /// Python ctor - maps to function.__new__
        /// 
        /// y = func(x.__code__, globals(), 'foo', None, (a, ))
        /// </summary>
        public PythonFunction(CodeContext context, FunctionCode code, PythonDictionary globals, string name, PythonTuple defaults, PythonTuple closure) {
            if (closure != null && closure.__len__() != 0) {
                throw new NotImplementedException("non empty closure argument is not supported");
            }

            if (globals == context.GlobalDict) {
                _module = context.Module.GetName();
                _context = context;
            } else {
                _module = null;
                _context = new CodeContext(new PythonDictionary(), new ModuleContext(globals, DefaultContext.DefaultPythonContext));
            }

            _defaults = defaults == null ? ArrayUtils.EmptyObjects : defaults.ToArray();
            _code = code;
            _name = name;
            _doc = code._initialDoc;
            Closure = null;

            var scopeStatement = _code.PythonCode;
            if (scopeStatement.IsClosure) {
                throw new NotImplementedException("code containing closures is not supported");
            }
            scopeStatement.RewriteBody(FunctionDefinition.ArbitraryGlobalsVisitorInstance);

            _compat = CalculatedCachedCompat();
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:32,代码来源:PythonFunction.cs


示例10: 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);
                }
            }
开发者ID:TerabyteX,项目名称:ironpython3,代码行数:8,代码来源:UnionType.cs


示例11: MapRoute

        public static void MapRoute(string name, string url, PythonDictionary defaults) {
            var defaultValues = new RouteValueDictionary();
            foreach (var kvp in defaults) {
                defaultValues.Add(Convert.ToString(kvp.Key, CultureInfo.InvariantCulture), kvp.Value);
            }

            RouteTable.Routes.Add(name, new Route(url, defaultValues, new MvcRouteHandler())) ;
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:8,代码来源:Routes.cs


示例12: PerformModuleReload

 public static void PerformModuleReload(PythonContext context, PythonDictionary dict) {
     PythonModule scope = Importer.ImportModule(context.SharedContext, context.SharedContext.GlobalDict, "itertools", false, -1) as PythonModule;
     if (scope != null) {
         dict["map"] = scope.__dict__["imap"];
         dict["filter"] = scope.__dict__["ifilter"];
         dict["zip"] = scope.__dict__["izip"];
     }
 }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:8,代码来源:FutureBuiltins.cs


示例13: PerformModuleReload

 public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {
     context.EnsureModuleException("PickleError", dict, "PickleError", "cPickle");
     context.EnsureModuleException("PicklingError", dict, "PicklingError", "cPickle");
     context.EnsureModuleException("UnpicklingError", dict, "UnpicklingError", "cPickle");
     context.EnsureModuleException("UnpickleableError", dict, "UnpickleableError", "cPickle");
     context.EnsureModuleException("BadPickleGet", dict, "BadPickleGet", "cPickle");
     dict["__builtins__"] = context.BuiltinModuleInstance;
     dict["compatible_formats"] = PythonOps.MakeList("1.0", "1.1", "1.2", "1.3", "2.0");
 }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:9,代码来源:cPickle.cs


示例14: create_node

        public Tree create_node(int left, int top, int width, int height, PythonDictionary tags)
        {
            BoundingBox bb = new BoundingBox(left, top, width, height);
            Dictionary<string, object> cTags = new Dictionary<string,object>();
            foreach(string key in tags.Keys)
                cTags[key] = tags[key];

            return Tree.FromBoundingBox(bb, cTags);
        
       }
开发者ID:nunb,项目名称:interpretation,代码行数:10,代码来源:PythonInterpretArgs.cs


示例15: GenerateFunctions

 GenerateFunctions(StringBuilder code, IntPtr methods, PythonDictionary methodTable)
 {
     GenerateCallablesFromMethodDefs(
         code, methods, methodTable, "",
         CodeSnippets.OLDARGS_FUNCTION_TEMPLATE,
         CodeSnippets.NOARGS_FUNCTION_TEMPLATE,
         CodeSnippets.OBJARG_FUNCTION_TEMPLATE,
         CodeSnippets.VARARGS_FUNCTION_TEMPLATE,
         CodeSnippets.VARARGS_KWARGS_FUNCTION_TEMPLATE);
 }
开发者ID:netcharm,项目名称:ironclad,代码行数:10,代码来源:CallableBuilder.cs


示例16: GenerateMethods

 GenerateMethods(StringBuilder code, IntPtr methods, PythonDictionary methodTable, string tablePrefix)
 {
     GenerateCallablesFromMethodDefs(
         code, methods, methodTable, tablePrefix,
         CodeSnippets.OLDARGS_METHOD_TEMPLATE,
         CodeSnippets.NOARGS_METHOD_TEMPLATE,
         CodeSnippets.OBJARG_METHOD_TEMPLATE,
         CodeSnippets.VARARGS_METHOD_TEMPLATE,
         CodeSnippets.VARARGS_KWARGS_METHOD_TEMPLATE);
 }
开发者ID:netcharm,项目名称:ironclad,代码行数:10,代码来源:CallableBuilder.cs


示例17: from_bounding_box

        public static MutableTree from_bounding_box(IBoundingBox box, PythonDictionary dict)
        {
            var csharpDict = new Dictionary<string, object>();
            foreach (string key in dict.Keys)
            {
                csharpDict[key] = dict[key];
            }

            return MutableTree.FromBoundingBox(box, csharpDict);
        }
开发者ID:prefab,项目名称:code,代码行数:10,代码来源:CreateTree.cs


示例18: InitModuleExceptions

 private static void InitModuleExceptions(PythonContext context,
     PythonDictionary dict)
 {
     ZipImportError = context.EnsureModuleException(
         "zipimport.ZipImportError",
         PythonExceptions.ImportError,
         typeof(PythonExceptions.BaseException),
         dict, "ZipImportError", "zipimport",
         msg => new ImportException(msg));
 }
开发者ID:TerabyteX,项目名称:main,代码行数:10,代码来源:zipimport.cs


示例19: 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
                            )
                        );
                    }
                }
            }
开发者ID:jschementi,项目名称:iron,代码行数:54,代码来源:ArrayType.cs


示例20: Get__dict__

 public static PythonDictionary Get__dict__(CodeContext context, NamespaceTracker self) {
     PythonDictionary res = new PythonDictionary();
     foreach (var kvp in self) {
         if (kvp.Value is TypeGroup || kvp.Value is NamespaceTracker) {
             res[kvp.Key] = kvp.Value;
         } else {
             res[kvp.Key] = DynamicHelpers.GetPythonTypeFromType(((TypeTracker)kvp.Value).Type);
         }
     }
     return res;
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:11,代码来源:NamespaceTrackerOps.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PythonIndexType类代码示例发布时间:2022-05-24
下一篇:
C# PythonContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap