AddPermission() public méthode

public AddPermission ( IPermission perm ) : JintEngine
perm IPermission
Résultat JintEngine
        void init()
        {
            PythonEngine.Inst.init();

            jint = new JintEngine();

            string absUserDir = Directory.GetCurrentDirectory() + "/Js";
            jint.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, absUserDir));

            //set some simple funcitons.
            Func<object, int> alert = delegate(object s)
            {
                MessageBox.Show(s.ToString());
                return 0;
            };

            Func<string, double, string, double[]> ema = delegate(string label, double days, string outLabel)
            {
                if (arrays.ContainsKey(label))
                {
                    double[] inputs = arrays[label];
                    double[] outputs = MathUtil.calcEMA(inputs, days);
                    addArray(outLabel, outputs);
                    return outputs;
                }
                return null;
            };




            Func<string, string, string, double[]> diff = delegate(string label0, string label1, string outLabel)
            {
                if (arrays.ContainsKey(label0) && arrays.ContainsKey(label1))
                {
                    double[] inputs0 = arrays[label0];
                    double[] inputs1 = arrays[label1];
                    double[] outputs = MathUtil.calcDiff(inputs0, inputs1);

                    addArray(outLabel, outputs);
                    return outputs;
                }
                return null;
            };

            //tell canvas to line
            Func<string, double, double, double, double, double, double, int> line = delegate(string label, double part, double r, double g, double b, double a, double thickness)
            {
                if (!arrays.ContainsKey(label))
                {
                    return 1;

                }

                Color c = new Color()
                {
                    R = (byte)r,
                    G = (byte)g,
                    B = (byte)b,
                    A = (byte)a
                };

                canvas.addDrawingObj(label, arrays[label], (int)part, c, thickness, DrawingObjectType.Line);
                return 0;
            };

            Func<string, double, double, double, double, double, double, int> zeroBars = delegate(string label, double part, double r, double g, double b, double a, double thickness)
            {
                if (!arrays.ContainsKey(label))
                {
                    return 1;

                }

                Color c = new Color()
                {
                    R = (byte)r,
                    G = (byte)g,
                    B = (byte)b,
                    A = (byte)a
                };
                canvas.addDrawingObj(label, arrays[label], (int)part, c, thickness, DrawingObjectType.zVLines);

                return 0;
            };
            ////kdj('close','high','low',9,'k','d','j');

            Func<string, string, string, double, string, string, string, int> kdj
                = delegate(string close, string high, string low, double days, string k, string d, string j)
            {
                if (arrays.ContainsKey(close) && arrays.ContainsKey(high) && arrays.ContainsKey(low))
                {
                    double[] inputs0 = arrays[close];
                    double[] inputs1 = arrays[high];
                    double[] inputs2 = arrays[low];

                    double[] kArray;
                    double[] dArray;
                    double[] jArray;
                    MathUtil.calcKDJ((int)days, inputs0, inputs1, inputs2, out kArray, out dArray, out jArray);

                    addArray(k, kArray);
                    addArray(d, dArray);
                    addArray(j, jArray);

                    return 0;
                }
                return 1;
            };


            //draw candle line.
            Func<string, double, string, string, string, string, int> candleLine = delegate(string id, double part, string open, string close, string high, string low)
            {
                if (!arrays.ContainsKey(open) || !arrays.ContainsKey(close)
                    || !arrays.ContainsKey(high) || !arrays.ContainsKey(low))
                {
                    return 1;
                }

                canvas.addKLineObj(id, (int)part, arrays[open], arrays[close], arrays[high], arrays[low]);
                return 0;
            };

            Func<string, object, int> addConfig = delegate(string id, object value)
            {
                addConfigVal(id, value);
                return 0;
            };


            Func<string, int> runScript = delegate(string scriptName)
            {
                runJsScript(scriptName);
                return 0;
            };


            Func<string, double, string, double, double, double, double, double, int> vLines = delegate(string id, double part, string label, double r, double g, double b, double a, double thickness)
            {
                if (!arrays.ContainsKey(label))
                {
                    return 1;

                }

                Color c = new Color()
                {
                    R = (byte)r,
                    G = (byte)g,
                    B = (byte)b,
                    A = (byte)a
                };

                //
                canvas.addDrawingObj(id, arrays[label], (int)part, c, thickness, DrawingObjectType.vLines);
                return 0;
            };

            //
            Func<string, string, int> setDrawItemEventHandler = delegate(string id, string handlerName)
            {
                canvas.setDrawItemEventHandler(id, handlerName);
                return 0;

            };




            jint.SetFunction("addConfig", addConfig);
            jint.SetFunction("runScript", runScript);

            jint.SetFunction("setDrawItemEventHandler", setDrawItemEventHandler);
            

            jint.SetFunction("alert", alert);
            jint.SetFunction("ema", ema);
            jint.SetFunction("kdj", kdj);
            jint.SetFunction("diff", diff);
            jint.SetFunction("line", line);
            jint.SetFunction("zeroBars", zeroBars);
            jint.SetFunction("candleLine", candleLine);
            jint.SetFunction("vLines", vLines);


          
        }