Ejemplo n.º 1
0
 public void AccessingAndModifyingGlobalVariables1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("interop", 15);
     engine.ExecuteFile(@"..\..\..\Unit Tests\Core\Sample Files\globals1.js");
     Assert.AreEqual(20, engine.GetGlobalValue<int>("interop"));
 }
Ejemplo n.º 2
0
 public void AccessingAndModifyingGlobalVariables1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("interop", 15);
     engine.ExecuteFile(Path.Combine (FilesDir, "globals1.js"));
     Assert.AreEqual(20, engine.GetGlobalValue<int>("interop"));
 }
Ejemplo n.º 3
0
        public void AccessingAndModifyingGlobalVariables1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("interop", 15);
            engine.ExecuteFile(Path.Combine(FilesDir, "globals1.js"));
            Assert.AreEqual(20, engine.GetGlobalValue <int>("interop"));
        }
Ejemplo n.º 4
0
        public void AccessingAndModifyingGlobalVariables1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("interop", 15);
            engine.ExecuteFile(@"..\..\..\Unit Tests\Core\Sample Files\globals1.js");
            Assert.AreEqual(20, engine.GetGlobalValue <int>("interop"));
        }
Ejemplo n.º 5
0
 public void Construct(params string[] JavascriptSourceFiles)
 {
     JurassicEngine = new Jurassic.ScriptEngine();
     foreach (string JavascriptSourceFile in JavascriptSourceFiles)
     {
         JurassicEngine.ExecuteFile(JavascriptSourceFile);
     }
     JurassicEngine.Execute("var Parse = function (strCDL) " +
                            "{ return grammarAst.parse(strCDL); };");
 }
Ejemplo n.º 6
0
        //string connectionString = String.Empty;
        //MongoClient client = null;

        //public class Entity
        //{
        //    public ObjectId Id { get; set; }

        //    public string Name { get; set; }
        //}

        public Form1()
        {
            InitializeComponent();

            //fontName = "InspectionXpert GDT";
            fontName = "SOLIDWORKS GDT";
            //fontSize = "9.5";
            fontSize   = "8";
            fontFormat = "#,##0.000";
            ffontSize  = Convert.ToSingle(fontSize);
            newFont    = new System.Drawing.Font(fontName, ffontSize);

            Version version = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                version = ApplicationDeployment.CurrentDeployment.CurrentVersion;
            }
            else
            {
                version = Assembly.GetExecutingAssembly().GetName().Version;
            }

            this.label10.Text = String.Format(this.label10.Text, version.Major, version.Minor, version.Build, version.Revision);

            var engine = new Jurassic.ScriptEngine();
            //engine.EnableDebugging = true;
            var result = engine.Evaluate("5 * 10 + 2");

            //engine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(engine));

            engine.ExecuteFile(@"test.js");
            var result1 = engine.GetGlobalValue <string>("s");
            var result2 = engine.GetGlobalValue <string>("word");
            var resultx = engine.GetGlobalValue <int>("x");
            var resulty = engine.GetGlobalValue <string>("y");

            int result3 = 0;

            try
            {
                result3 = engine.CallGlobalFunction <int>("test2", 50, 6 * 2);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }

            string resultTest3 = String.Empty;

            try
            {
                resultTest3 = engine.CallGlobalFunction <string>("test3", 50, 6 * 2);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }

            var result5 = engine.GetGlobalValue("z");
            var result4 = engine.GetGlobalValue <string>("z");

            foreach (var entry in result4)
            {
                int x = 0;
                x++;
            }

            var            json   = JSONObject.Stringify(engine, result4);
            var            json2  = JSONObject.Stringify(engine, result5);
            Object         xxxx   = JSONObject.Parse(engine, json2);
            JsonTextReader reader = new JsonTextReader(new StringReader(json2));

            while (reader.Read())
            {
                if (reader.Value != null)
                {
                    Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
                }
                else
                {
                    Console.WriteLine("Token: {0}", reader.TokenType);
                }
            }

            //var x = result4["sVal"];


            //int i = 0;

            //string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AXMCMMUtil.config");

            //if (File.Exists(configPath))
            //{
            //    Lua lua = new Lua();

            //    lua.DoFile(configPath);

            //    fontName = (string)lua["fontName"];
            //    double tempSize = (double)lua["fontSize"];
            //    fontSize = tempSize.ToString();
            //    fontFormat = (string)lua["fontFormat"];

            //    ffontSize = Convert.ToSingle(fontSize);
            //    newFont = new System.Drawing.Font(fontName, ffontSize);
            //}


            //connectionString = "mongodb://192.168.1.9";
            //client = new MongoClient(connectionString);
            //var server = client.GetServer();
            //var database = server.GetDatabase("test"); // "test" is the name of the database

            //// "entities" is the name of the collection
            //var collection = database.GetCollection<Entity>("entities");

            //var entity = new Entity { Name = "Tom" };
            //collection.Insert(entity);
            //var id = entity.Id; // Insert will set the Id if necessary (as it was in this example)

            //var query = Query<Entity>.EQ(e => e.Id, id);
            //entity = collection.FindOne(query);

            //entity.Name = "Dick";
            //collection.Save(entity);

            //var update = Update<Entity>.Set(e => e.Name, "Harry");
            //collection.Update(query, update);

            //collection.Remove(query);

            //var fileName = "D:\\Dropbox\\Dev\\AXMCMMUtil\\bin\\Debug\\Output.zip";
            //var newFileName = "D:\\Dropbox\\Dev\\AXMCMMUtil\\bin\\Debug\\OutputNew.zip";
            //using (var fs = new FileStream(fileName, FileMode.Open))
            //{
            //    var gridFsInfo = database.GridFS.Upload(fs, fileName);
            //    var fileId = gridFsInfo.Id;

            //    ObjectId oid = new ObjectId(fileId);
            //    ObjectId xxx = new ObjectId();
            //    var file = database.GridFS.FindOne(Query.EQ("_id", oid));

            //    //using (var stream = file.OpenRead())
            //    //{
            //    //    var bytes = new byte[stream.Length];
            //    //    stream.Read(bytes, 0, (int)stream.Length);
            //    //    using (var newFs = new FileStream(newFileName, FileMode.Create))
            //    //    {
            //    //        newFs.Write(bytes, 0, bytes.Length);
            //    //    }
            //   //}
            //}
        }
Ejemplo n.º 7
0
 public void ExecutingScript1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.ExecuteFile(@"..\..\..\Unit Tests\Core\Sample Files\execute1.js");
 }
Ejemplo n.º 8
0
        public void ExecutingScript1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.ExecuteFile(Path.Combine(FilesDir, "execute1.js"));
        }
Ejemplo n.º 9
0
 public void ExecutingScript1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.ExecuteFile(Path.Combine (FilesDir, "execute1.js"));
 }
Ejemplo n.º 10
0
        public void ExecutingScript1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.ExecuteFile(@"..\..\..\Unit Tests\Core\Sample Files\execute1.js");
        }