예제 #1
1
 public void EvaluateExpression2()
 {
     var engine = new Jurassic.ScriptEngine();
     Assert.AreEqual(3, engine.Evaluate<int>("1.5 + 2.4"));
 }
예제 #2
0
        public void IntProperty()
        {
            var engine = new Jurassic.ScriptEngine();
            engine.SetGlobalValue("test", new ClassWithProperty(engine));

            Assert.AreEqual(9, engine.Evaluate<int>("test.TestInt"));
            Assert.AreEqual(5, engine.Evaluate<int>("test.TestInt = 5; test.TestInt"));
            Assert.AreEqual(0, engine.Evaluate<int>("test.TestInt = 'test'; test.TestInt"));
        }
예제 #3
0
 public void PrivateSetter()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("test", new ClassWithPrivateSetter(engine));
     Assert.AreEqual(11, engine.Evaluate<int>("test.GetterOnly"));
     Assert.AreEqual(11, engine.Evaluate<int>("test.GetterOnly = 3; test.GetterOnly"));
     Assert.AreEqual(13, engine.Evaluate<int>("test.PrivateSetter"));
     Assert.AreEqual(13, engine.Evaluate<int>("test.PrivateSetter = 4; test.PrivateSetter"));
 }
예제 #4
0
        public void ObjectProperty()
        {
            var engine = new Jurassic.ScriptEngine();
            engine.SetGlobalValue("test", new ClassWithProperty(engine));

            Assert.AreEqual(5, engine.Evaluate<object>("test.TestObj = 5; test.TestObj"));
            Assert.AreEqual("test", engine.Evaluate<object>("test.TestObj = 'test'; test.TestObj"));
            Assert.AreEqual(Undefined.Value, engine.Evaluate<object>("test.TestObj = undefined; test.TestObj"));
            Assert.AreEqual(Null.Value, engine.Evaluate<object>("test.TestObj = null; test.TestObj"));
        }
예제 #5
0
        public void StringProperty()
        {
            var engine = new Jurassic.ScriptEngine();
            engine.SetGlobalValue("test", new ClassWithProperty(engine));

            Assert.AreEqual("Initial", engine.Evaluate<string>("test.TestStr"));
            Assert.AreEqual("test", engine.Evaluate<string>("test.TestStr = 'test'; test.TestStr"));
            Assert.AreEqual("null", engine.Evaluate<string>("test.TestStr = null; test.TestStr"));
            Assert.AreEqual("5", engine.Evaluate<string>("test.TestStr = 5; test.TestStr"));
        }
예제 #6
0
        public void PropertyAttributes()
        {
            var engine = new Jurassic.ScriptEngine();
            engine.SetGlobalValue("test", new ClassWithProperty(engine));

            // IsEnumerable.
            Assert.AreEqual("TestStr,TestObj", engine.Evaluate<string>("array = []; for (var key in test) array.push(key); array.join(',')"));

            // IsConfigurable
            Assert.AreEqual(false, engine.Evaluate<bool>("delete test.TestStr"));
            Assert.AreEqual(true, engine.Evaluate<bool>("delete test.TestObj"));
        }
예제 #7
0
 public void CallANETMethod1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalFunction("test", new Func<int, int, int>((a, b) => a + b));
     Assert.AreEqual(11, engine.Evaluate<int>("test(5, 6)"));
     engine.SetGlobalFunction("test2", new Func<string, string>(str => str.ToUpper()));
     Assert.AreEqual("TEST", engine.Evaluate<string>("test2('test')"));
     var num = 0;
     engine.SetGlobalFunction("test3", new Action<int>(a => num = a));
     engine.Evaluate("test3(5)");
     Assert.AreEqual(5, num);
 }
예제 #8
0
        public void PropertyAttributes()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("test", new ClassWithProperty(engine));

            // IsEnumerable.
            Assert.AreEqual("TestStr,TestObj", engine.Evaluate <string>("array = []; for (var key in test) array.push(key); array.join(',')"));

            // IsConfigurable
            Assert.AreEqual(false, engine.Evaluate <bool>("delete test.TestStr"));
            Assert.AreEqual(true, engine.Evaluate <bool>("delete test.TestObj"));
        }
예제 #9
0
        public void ExposingANETClass2()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("math2", new Math2(engine));
            Assert.AreEqual(3.0, engine.Evaluate <double>("math2.log10(1000)"));
        }
예제 #10
0
        public void AnonymousProperty()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("test", new ClassWithAnonymousProperty(engine));
            Assert.AreEqual(5, engine.Evaluate <int>("test['']"));
        }
예제 #11
0
        public void CallANETMethod1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalFunction("test", new Func <int, int, int>((a, b) => a + b));
            Assert.AreEqual(11, engine.Evaluate <int>("test(5, 6)"));
        }
예제 #12
0
        public void ExposingANETClass3_Call()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("Random", new RandomConstructor(engine));
            Assert.AreEqual(Undefined.Value, engine.Evaluate("Random(1000);"));
        }
예제 #13
0
        public void ExposingANETClass1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("appInfo", new AppInfo(engine));
            Assert.AreEqual("Test Application 5", engine.Evaluate <string>("appInfo.name + ' ' + appInfo.version"));
        }
예제 #14
0
        public void ExposingANETClass3()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.SetGlobalValue("Random", new RandomConstructor(engine));
            Assert.AreEqual(0.15155745910087481, engine.Evaluate <double>("var rand = new Random(1000); rand.nextDouble()"));
        }
예제 #15
0
        public void CallJavaScriptFunction1()
        {
            var engine = new Jurassic.ScriptEngine();

            engine.Evaluate("function test(a, b) { return a + b }");
            Assert.AreEqual(11, engine.CallGlobalFunction <int>("test", 5, 6));
        }
예제 #16
0
        public void TranslateAny()
        {
            var expression  = Expression(m => m.Items.Any(s => s.StartsWith("x")) ? null : "fail");
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x']}";
            var engine      = new Jurassic.ScriptEngine();
            var result      = engine.Evaluate($"({translation})({model})");

            Assert.AreEqual(Jurassic.Null.Value, result);
        }
예제 #17
0
        public void TranslateCountWithFilter()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.Items.Count(i => i.Length > 1));
            var translation = Translate(expression);
            var model       = @"{items:['y', 'xx', 'z']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual(1, result);
        }
예제 #18
0
        public void TranslateContains()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.Items.Contains("x2"));
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x2']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual(true, result);
        }
예제 #19
0
        public void TranslateElementAtOrDefault()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.Items.ElementAtOrDefault(3));
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x', 'z']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual(Null.Value, result);
        }
예제 #20
0
        public void TranslateAverage()
        {
            var expression  = (Expression <Func <TestModel, double> >)(m => m.Items.Average(i => i.Length));
            var translation = Translate(expression);
            var model       = @"{items:['x', 'xx', 'xxx']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual(2, result);
        }
예제 #21
0
        public void TranslateSum()
        {
            var expression  = Expression(m => m.Items.Sum(i => i.Length).ToString());
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x2']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual("3", result);
        }
예제 #22
0
        public void TranslateDefaultIfEmpty()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.IntItems.DefaultIfEmpty());
            var translation = Translate(expression);
            var model       = @"{intItems:[]}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script) as ArrayInstance;

            Assert.IsNotNull(result);
            Assert.AreEqual((uint)1, result.Length);
            Assert.AreEqual(0, result.ElementValues.First());
        }
예제 #23
0
        public void TranslateWhere()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.Items.Where(i => i.Length > 1));
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x2']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script) as ArrayInstance;

            Assert.IsNotNull(result);
            Assert.AreEqual((uint)1, result.Length);
            Assert.AreEqual("x2", result.ElementValues.First());
        }
예제 #24
0
        public void TranslateSelect()
        {
            var expression  = (Expression <Func <TestModel, object> >)(m => m.Items.Select(i => i.Length));
            var translation = Translate(expression);
            var model       = @"{items:['y', 'x2']}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script) as ArrayInstance;

            Assert.IsNotNull(result);
            Assert.AreEqual((uint)2, result.Length);
            Assert.AreEqual(1, result[0]);
            Assert.AreEqual(2, result[1]);
        }
예제 #25
0
        public void TranslateEndsWithWithIgnoreCase()
        {
            var expression = Expression(m =>
                                        m.Text.EndsWith("xy", StringComparison.OrdinalIgnoreCase)
                    ? "fail"
                    : DryvResultMessage.Success);

            var translation = Translate(expression);
            var model       = @"{text:'zzzzzzzXY'}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script) as string;

            Assert.AreEqual("fail", result);
        }
예제 #26
0
        public void TranslateNotEndsWith()
        {
            var expression = Expression(m =>
                                        m.Text.EndsWith("xy")
                    ? "fail"
                    : DryvResultMessage.Success);

            var translation = Translate(expression);
            var model       = @"{text:'ab'}";
            var engine      = new Jurassic.ScriptEngine();
            var script      = $"({translation})({model})";
            var result      = engine.Evaluate(script);

            Assert.AreEqual(Null.Value, result);
        }
예제 #27
0
        private object evaluateExpression(string expression)
        {
            try
            {
                object result = _engine.Evaluate(expression);
                if (result is Jurassic.Null)
                {
                    return(null);
                }

                return(result);
            }
            catch (System.Exception ex)
            {
                throw new JavascriptException(ex.Message);
            }
        }
예제 #28
0
        static void Main(string[] args)
        {
            var engine = new Jurassic.ScriptEngine();

            new Dictionary <string, ObjectInstance>
            {
                { "console", new Jurassic.Library.FirebugConsole(engine) },
                { "advapi32", new JsConstructor <AdvApi32>(engine) }
            }
            .ToList()
            .ForEach(x => engine.SetGlobalValue(x.Key, x.Value));

            var file = "";

            #if DEBUG
            file = args.Length >= 1 ? args[0] : "../../def.js";
            #else
            if (args.Length < 0)
            {
                Console.WriteLine("error");
                return;
            }
            file = args[0];
            #endif

            try
            {
                var result = engine.Evaluate <CreateServiceOut>(File.ReadAllText(file));
                var x      = result.Message;
                Console.WriteLine($"C# Result: {result.Result}");
                Console.WriteLine($"C# ErrorCode: {result.ErrorCode}");
                Console.WriteLine($"C# Message: {result.Message}");
            }
            catch (JavaScriptException e)
            {
                Console.WriteLine("C# JavaScriptException: " + e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("C# Exception: " + e.Message);
            }

            Console.ReadKey();
        }
예제 #29
0
    public static void RunConsoleLine(string Line)
    {
        object Returned;

        try
        {
            Returned = ConsoleEngine.Evaluate(Line);
        }
        catch (JavaScriptException Error)
        {
            Console.Print(Error.Message);
            return;
        }

        if (!(Returned is Jurassic.Undefined))
        {
            Console.Print(Returned.ToString());
        }
    }
예제 #30
0
        public void EvaluateExpression1()
        {
            var engine = new Jurassic.ScriptEngine();

            Assert.AreEqual(52, engine.Evaluate("5 * 10 + 2"));
        }
예제 #31
0
 public void AnonymousProperty()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("test", new ClassWithAnonymousProperty(engine));
     Assert.AreEqual(5, engine.Evaluate<int>("test['']"));
 }
예제 #32
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);
            //    //    }
            //   //}
            //}
        }
예제 #33
0
 public void ExposingANETClass3_Call()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("Random", new RandomConstructor(engine));
     Assert.AreEqual(Undefined.Value, engine.Evaluate("Random(1000);"));
 }
예제 #34
0
 public void ExposingANETClass2()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("math2", new Math2(engine));
     Assert.AreEqual(3.0, engine.Evaluate<double>("math2.log10(1000)"));
 }
예제 #35
0
 public void ExposingANETClass1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("appInfo", new AppInfo(engine));
     Assert.AreEqual("Test Application 5", engine.Evaluate<string>("appInfo.name + ' ' + appInfo.version"));
 }
예제 #36
0
 public void EvaluateExpression1()
 {
     var engine = new Jurassic.ScriptEngine();
     Assert.AreEqual(52, engine.Evaluate("5 * 10 + 2"));
 }
예제 #37
0
 public void CallJavaScriptFunction1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.Evaluate("function test(a, b) { return a + b }");
     Assert.AreEqual(11, engine.CallGlobalFunction<int>("test", 5, 6));
 }
예제 #38
0
 public void CallANETMethod1()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalFunction("test", new Func<int, int, int>((a, b) => a + b));
     Assert.AreEqual(11, engine.Evaluate<int>("test(5, 6)"));
 }
예제 #39
0
        public static object DoJs(string jscode)
        {
            var engine = new Jurassic.ScriptEngine();

            return(engine.Evaluate(jscode));// var addResult= engine.CallGlobalFunction(" main", 5, 6);//结果11
        }
예제 #40
0
        private bool DoLogin()
        {
            _logger.Debug("Login");

            LoadHomePageWithCsrf();

            _engine.Evaluate(string.Format("var name = '{0}';", _config.Login));
            _engine.Evaluate(string.Format("var password = '******';", _config.Password));
            _engine.Evaluate(string.Format("var g_password_type = '4';"));

            var jsResult =
                _engine.Evaluate(
                    "psd = base64encode(SHA256(name + base64encode(SHA256(password)) + g_requestVerificationToken[0]));");

            //_engine.Evaluate("console.log(psd);");

            var requestJs = @"
var request = {
Username: name,
Password: psd,
password_type: g_password_type
};
var xmlDate = object2xml('request', request);";

            _engine.Evaluate(requestJs);

            // Show the xmlDate in console
            //_engine.Evaluate("console.log(xmlDate);");


            //var rsaData = engine.Evaluate("doRSAEncrypt(xmlDate)");
            var rsaData = _engine.Evaluate("xmlDate");



            /*
             * encstring = base64_encode(encstring);
             * var num = encstring.length / 245;
             * var restotal = '';
             * for (i = 0; i < num; i++) {
             * var encdata = encstring.substr(i * 245, 245);
             * var res = rsa.encrypt(encdata);
             * restotal += res;
             * }
             * return restotal;
             *
             */

            // Get the RSA encryption for login
            var data     = EncodeData(rsaData.ToString());
            var postData = new PostData(data)
                           .AddHeader("__RequestVerificationToken", _firstCsrf)
                           .AddHeader("encrypt_transmit", "encrypt_transmit");

            var postResult = _website.PostPage(_loginPageUrl, postData);

            if (postResult.Contains("OK"))
            {
                _logger.Debug("Login... Done!");
                return(true);
            }

            var errorMessage = ProcessErrorMessages(postResult);

            _logger.Error("Logging in failed: {0}", errorMessage);

            return(false);
        }
예제 #41
0
 public void ExposingANETClass3()
 {
     var engine = new Jurassic.ScriptEngine();
     engine.SetGlobalValue("Random", new RandomConstructor(engine));
     Assert.AreEqual(0.15155745910087481, engine.Evaluate<double>("var rand = new Random(1000); rand.nextDouble()"));
 }
예제 #42
0
        public static string analysis(string s)
        {
            ScriptEngine engine = new Jurassic.ScriptEngine();

            engine.Evaluate(@"var _0xdd02 = ['host', 'javjunkies.com', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', '', 'substr', 'charAt', 'indexOf', 'fromCharCode', 'length', 'join', 'charCodeAt'];
function jj(_0x95d8x2) {
	var _0x95d8x3 = _0xdd02[2];
	var _0x95d8x4, _0x95d8x5, _0x95d8x6, _0x95d8x7, _0x95d8x8, _0x95d8x9, _0x95d8xa, _0x95d8xb, _0x95d8xc = 0, _0x95d8xd = 0, _0x95d8xe = _0xdd02[3], _0x95d8xf = [];
	if (!_0x95d8x2) {
		return _0x95d8x2
	}
	;
	_0x95d8x2 = _0x95d8x2[_0xdd02[4]](3);
	_0x95d8x2 += _0xdd02[3];
	do {
		_0x95d8x7 = _0x95d8x3[_0xdd02[6]](_0x95d8x2[_0xdd02[5]](_0x95d8xc++));
		_0x95d8x8 = _0x95d8x3[_0xdd02[6]](_0x95d8x2[_0xdd02[5]](_0x95d8xc++));
		_0x95d8x9 = _0x95d8x3[_0xdd02[6]](_0x95d8x2[_0xdd02[5]](_0x95d8xc++));
		_0x95d8xa = _0x95d8x3[_0xdd02[6]](_0x95d8x2[_0xdd02[5]](_0x95d8xc++));
		_0x95d8xb = _0x95d8x7 << 18 | _0x95d8x8 << 12 | _0x95d8x9 << 6
				| _0x95d8xa;
		_0x95d8x4 = _0x95d8xb >> 16 & 0xff;
		_0x95d8x5 = _0x95d8xb >> 8 & 0xff;
		_0x95d8x6 = _0x95d8xb & 0xff;
		if (_0x95d8x9 == 64) {
			_0x95d8xf[_0x95d8xd++] = String[_0xdd02[7]](_0x95d8x4)
		} else {
			if (_0x95d8xa == 64) {
				_0x95d8xf[_0x95d8xd++] = String[_0xdd02[7]](_0x95d8x4,
						_0x95d8x5)
			} else {
				_0x95d8xf[_0x95d8xd++] = String[_0xdd02[7]](_0x95d8x4,
						_0x95d8x5, _0x95d8x6)
			}
		}
	} while (_0x95d8xc < _0x95d8x2[_0xdd02[8]]);
	_0x95d8xe = _0x95d8xf[_0xdd02[9]](_0xdd02[3]);
	return utf8d(_0x95d8xe)
}

function utf8d(_0x95d8x11) {
	var _0x95d8x12 = _0xdd02[3], _0x95d8xc = 0, _0x95d8x13 = c1 = c2 = 0;
	while (_0x95d8xc < _0x95d8x11[_0xdd02[8]]) {
		_0x95d8x13 = _0x95d8x11[_0xdd02[10]](_0x95d8xc);
		if (_0x95d8x13 < 128) {
			_0x95d8x12 += String[_0xdd02[7]](_0x95d8x13);
			_0x95d8xc++
		} else {
			if ((_0x95d8x13 > 191) && (_0x95d8x13 < 224)) {
				c2 = _0x95d8x11[_0xdd02[10]](_0x95d8xc + 1);
				_0x95d8x12 += String[_0xdd02[7]](((_0x95d8x13 & 31) << 6)
						| (c2 & 63));
				_0x95d8xc += 2
			} else {
				c2 = _0x95d8x11[_0xdd02[10]](_0x95d8xc + 1);
				c3 = _0x95d8x11[_0xdd02[10]](_0x95d8xc + 2);
				_0x95d8x12 += String[_0xdd02[7]](((_0x95d8x13 & 15) << 12)
						| ((c2 & 63) << 6) | (c3 & 63));
				_0x95d8xc += 3
			}
		}
	}
	;
	return _0x95d8x12
}");
            string res = engine.CallGlobalFunction <string>("jj", s);

            //Regex r2 = new Regex(@"Vídeo Id: .*<br>Sìze:");
            //Item.id = r2.Matches(res)[0].Value.Split(new string[] { "Vídeo Id: ", "<br>Sìze:" }, StringSplitOptions.RemoveEmptyEntries)[0];
            //Item.id = "<a>" + Item.torrent.Replace(">", "/>")+"</a>";
            //XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.LoadXml(Item.id);
            //string id="";
            //foreach (XmlNode x in xmlDoc.GetElementsByTagName("a")[0].ChildNodes)
            //{
            //    string key = x.Attributes["style"].Value;
            //    key = key.Substring(0, key.IndexOf(";") + 1);
            //    key = dictionary[key];
            //    id += key;
            //}
            res = res.Replace(">", "/>");
            Regex r1 = new Regex("<img src=\".*?px;\"/>");

            MatchCollection mc = r1.Matches(res);

            foreach (Match m in mc)
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(m.ToString());
                string key = xmlDoc.GetElementsByTagName("img")[0].Attributes["style"].Value;
                key = key.Substring(0, key.IndexOf(";"));
                string cha = dictionary[key];
                res = res.Replace(m.ToString(), cha);
            }
            Item.info = res;
            Regex r2 = new Regex("Vídeo Id: .*?<br/>");

            try
            {
                Item.id = r2.Matches(res)[0].ToString().Split(new string[] { "Vídeo Id: ", "<br/>" }, StringSplitOptions.RemoveEmptyEntries)[0];
            }
            catch
            {
                Item.id = "";
            }
            return(Item.id);
        }
예제 #43
0
        public void EvaluateExpression2()
        {
            var engine = new Jurassic.ScriptEngine();

            Assert.AreEqual(3, engine.Evaluate <int>("1.5 + 2.4"));
        }