Пример #1
0
        public void BindContext <T>(string key, T obj)
        {
            if (contextDictionary.ContainsKey(key))
            {
                Waring($"[{RCL.Wrap("Context", ConsoleColor.Cyan)}] '{key}' is already defined.");
                return;
            }
            contextDictionary.Add(key, obj);
            jsEngine.SetValue(key, obj);

            if (typeof(T) == typeof(Action <string>))
            {
                this.BindDelegate((Action <string>)(object) obj, key);
            }
            if (typeof(T) == typeof(Action <int>))
            {
                this.BindDelegate((Action <int>)(object) obj, key);
            }
            if (typeof(T) == typeof(Action <bool>))
            {
                this.BindDelegate((Action <bool>)(object) obj, key);
            }
            if (typeof(T) == typeof(Action <object>))
            {
                this.BindDelegate((Action <object>)(object) obj, key);
            }
            if (typeof(T) == typeof(Action <byte>))
            {
                this.BindDelegate((Action <byte>)(object) obj, key);
            }
        }
Пример #2
0
        public void Start()
        {
            var sq = (Func <object, Task <object> >)(async(i) => {
                Terminal.WriteLine($"[{RCL.Wrap("Core", ConsoleColor.DarkMagenta)}]: result:{i}!");
                return(null);
            });

            var qwe0 = EngineVM.Execute(
                @"return function(data, callback) 
            {
                Log('sqe0 execute!');
                exports.nure = 1;

                data(exports.nure++, true);
                callback(null, null);
            }  
            ");
            var qwe1 = EngineVM.Execute(@"
            return function(data, callback) 
            {
                Log('sqe1 execute!');
                data(exports.nure++, true);
                callback(null, null);
            }  
            ");

            qwe0(sq).Wait();
            qwe1(sq).Wait();
            qwe1(sq).Wait();
            qwe1(sq).Wait();
            qwe1(sq).Wait();

            var    func = EngineVM.Execute(@"
            let ts = require('typescript');
            let TCSResult = '';
            let compilerOptions = { module: ts.ModuleKind.None, removeComments: true };


            return function(data, callback) 
            {
                TCSResult = ts.transpile(data, compilerOptions, undefined, undefined,'FlameScript');
                callback(null, TCSResult);
            }
            ");
            string tsc  = (string)func(File.ReadAllText(mainTS)).Result;



            //try
            //{
            //    jsEngine.Execute(tsc);
            //    jsEngine.Execute("YRes = Dummy.TestClass.testMethod2();");
            //    //jsEngine.Execute("TCSResult = TypeScript.compile(TSSource, null, function(e) { VMError(e); });");
            //}
            //catch (JavaScriptException e)
            //{
            //    e.Print();
            //}
        }
Пример #3
0
        public static string ToRCLString(this Exception e)
        {
            string ex = e.ToString();

            ex = types.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.DarkGreen)));
            ex = typesEnum.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.DarkYellow)));
            ex = typesNameSpace.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.Gray)));
            return(ex);
        }
Пример #4
0
 public static void Print(this JavaScriptException e)
 {
     Terminal.WriteLine($"+==============================================+");
     Terminal.WriteLine($"+=|           {RCL.Wrap("JavaScript Exception", ConsoleColor.DarkRed)}");
     Terminal.WriteLine($"+=| Column   :{e.Column}");
     Terminal.WriteLine($"+=| Location :{e.Location}");
     Terminal.WriteLine($"+=| Line     :{e.LineNumber}");
     Terminal.WriteLine($"+=| Error    :{e.Error}");
     Terminal.WriteLine($"+=| Exception:{e.Message}");
     Terminal.WriteLine($"+==============================================+");
 }
Пример #5
0
 public static int Main(string[] args)
 {
     Console.Title = "builder";
     try
     {
         Assembler.Asm();
     }
     catch (Exception e)
     {
         Assembler.Error($"{RCL.Wrap("!!!", ConsoleColor.Red)} CATCHING EXCEPTION WARIOUT {RCL.Wrap("!!!", ConsoleColor.Red)}");
         Assembler.Error(e.ToRCLString());
         Assembler.Error($"{RCL.Wrap("!!!", ConsoleColor.Red)} STOP {RCL.Wrap("!!!", ConsoleColor.Red)}");
         Console.ReadKey();
         return(-1);
     }
     return(1);
 }
Пример #6
0
 public static void VMFlameInternalFatalLog(string s)
 {
     Terminal.WriteLine($"{Header}[{RCL.Wrap("INF", ConsoleColor.Gray)}]: {s}");
 }
Пример #7
0
 public static void VMVMInfo(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("INF", ConsoleColor.Gray)      }]: {s}");
Пример #8
0
 public static void VMWaring(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("WAR", ConsoleColor.DarkYellow)}]: {s}");
Пример #9
0
 public static void VMError(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("ERR", ConsoleColor.DarkRed)   }]: {s}");
Пример #10
0
 public static void VMLog(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("LOG", ConsoleColor.DarkGray)  }]: {s}");
Пример #11
0
 public static void Waring(string s)
 {
     Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("WAR", ConsoleColor.DarkYellow)}]: {s}");
 }
Пример #12
0
 public static void Error(string s)
 {
     Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("ERR", ConsoleColor.DarkRed)}]: {s}");
 }
Пример #13
0
 public static void Log(string s)
 {
     Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("LOG", ConsoleColor.DarkGray)}]: {s}");
 }
Пример #14
0
 /// <summary>
 /// Colored string [RCL]
 /// </summary>
 public static string To(this string s, Color c) => RCL.Wrap(s, c);
        public void tMain(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            RCL.EnablingVirtualTerminalProcessing();
            Screen.Title = "KeyGen";

            Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Version SuperChanger: ");
            Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}]     Business          - 3 ");
            Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}]     Individual Pro    - 4 ");
            Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}]     Individual        - 5 ");

            var Type = TypeProduct.AxTools;

TR_0:
            Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter type of product :>");
            if (int.TryParse(Console.ReadLine(), out var i))
            {
                if (!(i >= 0 && i <= 5))
                {
                    Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Product type is incorrect!");
                    goto TR_0;
                }
            }
            else
            {
                Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Product type is not a number!");
                goto TR_0;
            }
            //
            var TypeLic = i;
            var coding  = Encoding.UTF8;
            //
            var ad = new ProfileLicense();

            ad.ID = $"AxTools License ID Code";


            switch (TypeLic)
            {
            case 0:
            case 1:
            case 2: Type = TypeProduct.AxTools; break;

            case 3:
            case 4:
            case 5: Type = TypeProduct.SuperChanger; break;
            }

            Screen.Title = "KeyGen " + Type;


TR_1:
            Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter your name :>");
            var name = Console.ReadLine();

            if (name.Length > 20)
            {
                Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Your name is too long!");
                goto TR_1;
            }
            Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter your surname :>");
            var family = Console.ReadLine();

            if (family.Length > 20)
            {
                Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Your surname is too long!");
                goto TR_1;
            }
            if (Type == TypeProduct.AxTools)
            {
                ad.LName = $"{name} {family}{new string('~', 50 - (name.Length + family.Length + 1))}";
            }
            else
            {
                ad.LName = $"{name} {family}";
                ad.EDate = DateTime.Now.AddYears(50);
            }


            var key = "";



            switch (TypeLic)
            {
            case 0:
            case 1:
            case 2:
                key = LicenseDecryptor.Encrypt(TypeLic, ad); break;

            case 5:
                key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.Business, ad); break;

            case 4:
                key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.ProInv, ad); break;

            case 3:
                key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.Inv, ad); break;
            }

            Clipboard.SetText(key);
            Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] The key will be copied to the clipboard.");
            var qqq = new Licenser().Update(key);

            Screen.WriteLine("");
            Screen.WriteLine("");

            if (Type == TypeProduct.AxTools)
            {
                var profile = new AlhoritmAxTools(TypeLic).StrToAd(key);

                if (profile != null)
                {
                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Is key correct: {RCL.Wrap(true, Color.CadetBlue)}");
                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License type: {Type}");
                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License identifier: {profile.ID}");
                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Name of the license owner: {profile.LName}");

                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Count: {profile.SCount}");
                    Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License end date: {profile.EDate}");
                }
                else
                {
                    Screen.WriteLine($"Верен ли ключ: {RCL.Wrap(false, Color.CadetBlue)}");
                }
            }
            else
            {
                var profile = ad;
                Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Is key correct: {RCL.Wrap(true, Color.CadetBlue)}");
                Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License type: {Type}");
                Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License identifier: {profile.ID}");
                Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Name of the license owner: {profile.LName}");
                Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License end date: {profile.EDate}");
            }

            Console.ReadKey();
        }