예제 #1
0
 public static Assembly compile_H2Script(this string h2Script)
 {
     try
     {
         var sourceCode = "";
         if (h2Script.extension(".h2"))
         {
             PublicDI.CurrentScript = h2Script;
             if (h2Script.fileExists().isFalse())
             {
                 h2Script = h2Script.local();
             }
             sourceCode = H2.load(h2Script).SourceCode;
         }
         if (sourceCode.valid())
         {
             return(sourceCode.compile_CodeSnippet());
         }
     }
     catch (Exception ex)
     {
         ex.log("in string compile_H2Script");
     }
     return(null);
 }
예제 #2
0
 private void H3_Tick(object sender, EventArgs e)
 {
     WriteText("^1-- ^5N^7o ^5H^7ost ^5M^7od ^5M^7enu ^5B^7y ^5M^7rNiato  ^1--\n\n^5Steady Aim\nUAV\n^2-->^5Red Boxes\nInvisible Gun\nLaser\nSilent Gun\nNo Recoil");
     if (Key_IsDown.DetectKey(Key_IsDown.Key.Cross))
     {
         if (RedBoxes == false)
         {
             byte[] godmodebyte = new byte[] { 0x01 };
             PS3.SetMemory(0x1AF6FB, godmodebyte);
             RedBoxes = true;
         }
         else if (RedBoxes == true)
         {
             byte[] godmodebyte = new byte[] { 0x00 };
             PS3.SetMemory(0x1AF6FB, godmodebyte);
             RedBoxes = false;
         }
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_DOWN))
     {
         H3.Stop();
         H6.Start();
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_UP))
     {
         H3.Stop();
         H2.Start();
     }
     if (Key_IsDown.DetectKey(Key_IsDown.Key.R3))
     {
         H3.Stop();
         HostMainMenu.Start();
     }
 }
 public void MapToExistentTests()
 {
     var obj = new AutoMapperObjectMapper();
     var result = new H2();
     result = obj.Map(new H1 { Value = 42 }, result);
     Assert.AreEqual(result.Value, 42);
 }
예제 #4
0
        public static H2 h2(this string code)
        {
            var h2 = new H2();

            h2.SourceCode = code;
            return(h2);
        }
예제 #5
0
        private void Body(ReadOnlySpan <byte> source)
        {
            if (source.Length == 0)
            {
                return;
            }

            var remainder = source.Length & 15;
            var blocks    = 2 * (source.Length / 16);

            if (blocks > 0)
            {
                var ulongSource = MemoryMarshal.Cast <byte, ulong>(source);
                for (var block = 0; block < blocks;)
                {
                    H1 ^= (ulongSource[block++] * C1).RotateLeft(31) * C2;
                    H1  = ((H1.RotateLeft(27) + H2) * 5) + 0x52dce729;

                    H2 ^= (ulongSource[block++] * C2).RotateLeft(33) * C1;
                    H2  = ((H2.RotateLeft(31) + H1) * 5) + 0x38495ab5;
                }
            }

            if (remainder > 0)
            {
                Tail(source.Slice(8 * blocks));
            }
        }
예제 #6
0
        protected override bool TryHashFinal(Span <byte> destination, out int bytesWritten)
        {
            if (destination.Length < 16)
            {
                bytesWritten = 0;
                return(false);
            }
            ulong len = (ulong)Length;

            H1 ^= len; H2 ^= len;

            H1 += H2;
            H2 += H1;

            H1 = H1.FMix();
            H2 = H2.FMix();

            H1 += H2;
            H2 += H1;

            var ulongDestination = MemoryMarshal.Cast <byte, ulong>(destination);

            ulongDestination[0] = H1;
            ulongDestination[1] = H2;

            bytesWritten = 16;
            return(true);
        }
예제 #7
0
 public void Start()
 {
     cli1_1.text = "";
     cli2_1.text = "";
     cli1_2.text = "";
     cli2_2.text = "";
     cli1_3.text = "";
     cli2_3.text = "";
     cli1_4.text = "";
     cli2_4.text = "";
     cli1_5.text = "";
     cli2_5.text = "";
     F1.SetActive(false);
     H1.SetActive(false);
     H11.SetActive(false);
     F2.SetActive(false);
     H2.SetActive(false);
     H22.SetActive(false);
     F3.SetActive(false);
     H3.SetActive(false);
     H33.SetActive(false);
     F4.SetActive(false);
     H4.SetActive(false);
     H44.SetActive(false);
     F5.SetActive(false);
     H5.SetActive(false);
     H55.SetActive(false);
 }
예제 #8
0
        static HTMLBase getMessageHeader(ReturnedMsg msg, string authorName, string roleColor)
        {
            var h2 = new H2(cls: "header-23xsNx");

            h2.Children.Add(new Span(cls: "latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4")
            {
                Children =
                {
                    new Span()
                    {
                        Children =
                        {
                            new ItalicText("[",                                cls: "separator-2nZzUB").WithTag("aria-hidden", "true"),
                            new RawObject(msg.CreatedAt.ToString("hh:mm tt")),
                            new ItalicText("] ",                               cls: "separator-2nZzUB").WithTag("aria-hidden", "true")
                        }
                    }.WithTag("aria-label", msg.CreatedAt.ToString("hh:mm tt"))
                }
            });
            var usernameStuffs = new Span(cls: "headerText-3Uvj1Y");

            usernameStuffs.Children.Add(new Span(cls: "username-1A8OIy clickable-1bVtEA")
                                        .WithTag("style", $"color: {roleColor}")
                                        .WithTag("tabIndex", "0")
                                        .WithTag("aria-controls", "popout_320")
                                        .WithTag("aria-expanded", "false")
                                        .WithTag("role", "button")
                                        .WithRawText(authorName));
            usernameStuffs.Children.Add(new ItalicText(":", cls: "separator-2nZzUB"));
            h2.Children.Add(usernameStuffs);
            return(h2);
        }
예제 #9
0
        private void Body(byte[] data, int start, int length)
        {
            int remainder     = length & 15;
            int alignedLength = start + (length - remainder);

            for (int i = start; i < alignedLength; i += 16)
            {
                uint k1 = data.ToUInt32(i),
                     k2 = data.ToUInt32(i + 4),
                     k3 = data.ToUInt32(i + 8),
                     k4 = data.ToUInt32(i + 12);

                H1 ^= (k1 * C1).RotateLeft(15) * C2;
                H1  = (H1.RotateLeft(19) + H2) * 5 + 0x561ccd1b;

                H2 ^= (k2 * C2).RotateLeft(16) * C3;
                H2  = (H2.RotateLeft(17) + H3) * 5 + 0x0bcaa747;

                H3 ^= (k3 * C3).RotateLeft(17) * C4;
                H3  = (H3.RotateLeft(15) + H4) * 5 + 0x96cd1c35;

                H4 ^= (k4 * C4).RotateLeft(18) * C1;
                H4  = (H4.RotateLeft(13) + H1) * 5 + 0x32ac3b17;
            }

            if (remainder > 0)
            {
                Tail(data, alignedLength, remainder);
            }
        }
예제 #10
0
        protected override byte[] HashFinal()
        {
            uint len = (uint)Length;

            H1 ^= len; H2 ^= len; H3 ^= len; H4 ^= len;

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            H1 = H1.FMix();
            H2 = H2.FMix();
            H3 = H3.FMix();
            H4 = H4.FMix();

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            var result = new byte[16];

            Array.Copy(BitConverter.GetBytes(H1), 0, result, 0, 4);
            Array.Copy(BitConverter.GetBytes(H2), 0, result, 4, 4);
            Array.Copy(BitConverter.GetBytes(H3), 0, result, 8, 4);
            Array.Copy(BitConverter.GetBytes(H4), 0, result, 12, 4);

            return(result);
        }
예제 #11
0
        protected override byte[] HashFinal()
        {
            ulong len = (ulong)Length;

            H1 ^= len; H2 ^= len;

            H1 += H2;
            H2 += H1;

            H1 = H1.FMix();
            H2 = H2.FMix();

            H1 += H2;
            H2 += H1;

            var result = new byte[16];

            unsafe
            {
                fixed(byte *h = result)
                {
                    ulong *r = (ulong *)h;

                    r[0] = H1;
                    r[1] = H2;
                }
            }

            return(result);
        }
예제 #12
0
        public void Reset(Control host)
        {
            H1.Reset(host);
            H2.Reset(host);
            H3.Reset(host);
            H4.Reset(host);
            H5.Reset(host);
            H6.Reset(host);
            BlockQuote.Reset(host);
            P.Reset(host);
            FigCaption.Reset(host);
            Pre.Reset(host);
            Dt.Reset(host);
            Dd.Reset(host);

            Li.Reset(host);

            A.Reset(host);
            Span.Reset(host);
            Label.Reset(host);
            Q.Reset(host);
            Cite.Reset(host);
            I.Reset(host);
            Em.Reset(host);
            Mark.Reset(host);
            Time.Reset(host);
            Code.Reset(host);
            Strong.Reset(host);
        }
예제 #13
0
        private void Body(byte[] data, int start, int length)
        {
            int remainder = length & 15;
            int blocks    = length / 16;

            unsafe
            {
                fixed(byte *d = &data[start])
                {
                    ulong *current = (ulong *)d;

                    while (blocks-- > 0)
                    {
                        // a variant of original algorithm optimized for processor instruction pipelining
                        H1 ^= (*current++ *C1).RotateLeft(31) * C2;
                        H1  = (H1.RotateLeft(27) + H2) * 5 + 0x52dce729;

                        H2 ^= (*current++ *C2).RotateLeft(33) * C1;
                        H2  = (H2.RotateLeft(31) + H1) * 5 + 0x38495ab5;
                    }

                    if (remainder > 0)
                    {
                        Tail(d + (length - remainder), remainder);
                    }
                }
            }
        }
        public void loadH2Script(string scriptToLoad)
        {
            O2Thread.mtaThread(() =>
            {
                if (scriptToLoad.fileName().starts(this.typeName()))
                {
                    PublicDI.log.error("We can execute the current type of we will get a recursive load :)");
                    return;
                }
                currentScript = scriptToLoad;
                statusLabel.set_Text("loading script: {0}".format(scriptToLoad.fileName()));

                csharpCompiler = new CSharp_FastCompiler();

                csharpCompiler.set_OnAstFail(() =>
                {
                    showError("Ast creation failed", csharpCompiler.astErrors());
                    csharpCompiler_OnAstFail.invoke();
                });

                csharpCompiler.set_OnAstOK(() =>
                {
                    showInfo("Ast creation Ok");
                    csharpCompiler_OnAstOk.invoke();
                });

                csharpCompiler.set_OnCompileFail(() =>
                {
                    showError("Compilation failed", csharpCompiler.compilationErrors());
                    csharpCompiler_OnCompileFail.invoke();
                });

                csharpCompiler.set_OnCompileOK(() =>
                {
                    showInfo("Compilation Ok: Executing 1st method");
                    csharpCompiler_OnCompileOk.invoke();
                    executeCompiledCode();
                });

                var sourceCode         = "";
                PublicDI.CurrentScript = scriptToLoad;
                csharpCompiler.CompilerOptions.SourceCodeFile = scriptToLoad;
                if (scriptToLoad.extension(".h2"))
                {
                    sourceCode = H2.load(scriptToLoad).SourceCode;
                }
                if (scriptToLoad.extension(".o2") || scriptToLoad.extension(".cs"))
                {
                    sourceCode = scriptToLoad.contents();
                }
                if (sourceCode.valid())
                {
                    csharpCompiler.compileSnippet(sourceCode);
                }
                else
                {
                    statusLabel.set_Text("Non supported file").textColor(this, Color.Red);
                }
            });
        }
        protected override byte[] HashFinal()
        {
            uint len = (uint)Length;

            // pipelining friendly algorithm
            H1 ^= len; H2 ^= len; H3 ^= len; H4 ^= len;

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            H1 = H1.FMix();
            H2 = H2.FMix();
            H3 = H3.FMix();
            H4 = H4.FMix();

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            var result = new byte[16];

            unsafe
            {
                fixed(byte *h = result)
                {
                    var r = (uint *)h;

                    r[0] = H1;
                    r[1] = H2;
                    r[2] = H3;
                    r[3] = H4;
                }
            }

            return(result);
        }
예제 #16
0
        public void LoadAndSaveH2File()
        {
            var codeSnippet = "return 42;";
            var h2          = new H2(codeSnippet);
            var h2Saved     = h2.save();

            "h2Saved: {0}".info(h2Saved);
            var h2Loaded = H2.load(h2Saved);

            Assert.IsNotNull(h2);
            Assert.IsTrue(h2Saved.fileExists());
            Assert.IsNotNull(h2Loaded);
            Assert.AreEqual(h2Loaded.SourceCode, codeSnippet);

            var tempH2 = "test.h2".tempFile();

            h2.save(tempH2);
            var tempH2Loaded = H2.load(tempH2);
            var h2SourceCode = tempH2.h2_SourceCode();

            Assert.IsTrue(tempH2.fileExists());
            Assert.IsNotNull(tempH2Loaded);
            Assert.AreEqual(tempH2Loaded.SourceCode, codeSnippet);
            Assert.IsNotNull(h2SourceCode);
            Assert.AreEqual(h2SourceCode, codeSnippet);
        }
예제 #17
0
        protected override bool TryHashFinal(Span <byte> destination, out int bytesWritten)
        {
            if (destination.Length < 16)
            {
                bytesWritten = 0;
                return(false);
            }

            var len = (uint)Length;

            // pipelining friendly algorithm
            H1 ^= len; H2 ^= len; H3 ^= len; H4 ^= len;

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            H1 = H1.FMix();
            H2 = H2.FMix();
            H3 = H3.FMix();
            H4 = H4.FMix();

            H1 += (H2 + H3 + H4);
            H2 += H1; H3 += H1; H4 += H1;

            var uintDestination = MemoryMarshal.Cast <byte, uint>(destination);

            uintDestination[0] = H1;
            uintDestination[1] = H2;
            uintDestination[2] = H3;
            uintDestination[3] = H4;
            bytesWritten       = 16;
            return(true);
        }
예제 #18
0
    public static void Run()
    {
        var disruptor = new Disruptor <SampleEvent>(() => new SampleEvent(), 1024);
        var handler1  = new H1(new SampleEventPersister());
        var handler2  = new H2();

        disruptor.HandleEventsWith(handler1).Then(handler2);
    }
예제 #19
0
 public static string h2_SourceCode(this string file)
 {
     if (file.extension(".h2"))
     {
         "return source code of H2 file".info();
         return(H2.load(file).SourceCode);
     }
     return(null);
 }
        public void MapToExistentTests()
        {
            var obj    = new AutoMapperObjectMapper();
            var result = new H2();

            result = obj.Map(new H1 {
                Value = 42
            }, result);
            Assert.AreEqual(result.Value, 42);
        }
예제 #21
0
        public void Merge(params DocumentStyle[] styles)
        {
            if (styles != null)
            {
                foreach (var style in styles)
                {
                    Section.Merge(style.Section);
                    Article.Merge(style.Article);
                    Header.Merge(style.Header);
                    Footer.Merge(style.Footer);
                    Main.Merge(style.Main);
                    Figure.Merge(style.Figure);
                    Details.Merge(style.Details);
                    Summary.Merge(style.Summary);
                    Div.Merge(style.Div);
                    Ul.Merge(style.Ul);
                    Ol.Merge(style.Ol);
                    Dl.Merge(style.Dl);
                    Td.Merge(style.Td);

                    Table.Merge(style.Table);

                    Img.Merge(style.Img);
                    YouTube.Merge(style.YouTube);
                    Channel9.Merge(style.Channel9);

                    H1.Merge(style.H1);
                    H2.Merge(style.H2);
                    H3.Merge(style.H3);
                    H4.Merge(style.H4);
                    H5.Merge(style.H5);
                    H6.Merge(style.H6);
                    BlockQuote.Merge(style.BlockQuote);
                    P.Merge(style.P);
                    FigCaption.Merge(style.FigCaption);
                    Pre.Merge(style.Pre);
                    Dt.Merge(style.Dt);
                    Dd.Merge(style.Dd);

                    Li.Merge(style.Li);

                    A.Merge(style.A);
                    Span.Merge(style.Span);
                    Label.Merge(style.Label);
                    Q.Merge(style.Q);
                    Cite.Merge(style.Cite);
                    I.Merge(style.I);
                    Em.Merge(style.Em);
                    Mark.Merge(style.Mark);
                    Time.Merge(style.Time);
                    Code.Merge(style.Code);
                    Strong.Merge(style.Strong);
                }
            }
        }
예제 #22
0
 public static string h2_SourceCode(this string file)
 {
     if (file.extension(".h2"))
     {
         //"return source code of H2 file".info();
         if (file.fileExists())
         {
             return(H2.load(file).SourceCode.fix_CRLF());
         }
     }
     return(null);
 }
 public static object execute(this H2 h2Script)
 {
     try
     {
         var assembly = h2Script.SourceCode.compile_CodeSnippet();
         return(assembly.executeFirstMethod());
     }
     catch (Exception ex)
     {
         ex.log("in CSharp_FastCompiler.executeH2Script");
     }
     return(null);
 }
 public static RibbonGroup add_RibbonButton_H2Script(this RibbonGroup ribbonGroup, WinForms.Control winFormsControl, string label, string h2Script)
 {
     if (h2Script.extension(".h2"))
     {
         if (h2Script.fileExists().isFalse())
         {
             h2Script = h2Script.local();
         }
         var h2         = H2.load(h2Script);
         var scriptText = h2.notNull() ? h2.SourceCode : "";
         return(ribbonGroup.add_RibbonButton_Script_GUI(winFormsControl, label, scriptText));
     }
     return(ribbonGroup.add_RibbonButton_Script(winFormsControl, label, h2Script));
 }
예제 #25
0
        public void ExecuteH2File()
        {
            var codeSnippet = "return 42;";
            var h2 = new H2(codeSnippet);
            var h2File = "test.h2".tempFile();
            h2.save(h2File);

            var h2SourceCode = h2File.h2_SourceCode();
            var assembly = h2SourceCode.compileCodeSnippet();
            var result = assembly.firstMethod().invoke();

            Assert.NotNull(h2SourceCode);
            Assert.NotNull(assembly);
            Assert.NotNull(result);
            Assert.AreEqual(result, 42);
        }
예제 #26
0
        public void ExecuteH2File()
        {
            var codeSnippet = "return 42;";
            var h2          = new H2(codeSnippet);
            var h2File      = "test.h2".tempFile();

            h2.save(h2File);

            var h2SourceCode = h2File.h2_SourceCode();
            var assembly     = h2SourceCode.compileCodeSnippet();
            var result       = assembly.firstMethod().invoke();

            Assert.NotNull(h2SourceCode);
            Assert.NotNull(assembly);
            Assert.NotNull(result);
            Assert.AreEqual(result, 42);
        }
 public static SourceCodeEditor editScript(this string scriptOrFile)
 {
     if (scriptOrFile.fileExists().isFalse())
     {
         if (scriptOrFile.local().valid())
             scriptOrFile = scriptOrFile.local();
         else
         {
             var h2Script = new H2(scriptOrFile);
             scriptOrFile = PublicDI.config.getTempFileInTempDirectory(".h2");
             h2Script.save(scriptOrFile);
         }
     }
     return O2Gui.open<Panel>(scriptOrFile.fileName(), 800, 400)
                 .add_SourceCodeEditor()
                 .open(scriptOrFile);
 }
        private void Body(byte[] data, int start, int length)
        {
            if (length == 0)
            {
                return;
            }

            int remainder = length & 15;
            int blocks    = length / 16;

            unsafe
            {
                fixed(byte *d = &data[start])
                {
                    // grab a reference to blocks
                    uint *b = (uint *)d;

                    while (blocks-- > 0)
                    {
                        // K1 - consume first integer
                        H1 ^= (*b++ *C1).RotateLeft(15) * C2;
                        H1  = (H1.RotateLeft(19) + H2) * 5 + 0x561ccd1b;

                        // K2 - consume second integer
                        H2 ^= (*b++ *C2).RotateLeft(16) * C3;
                        H2  = (H2.RotateLeft(17) + H3) * 5 + 0x0bcaa747;

                        // K3 - consume third integer
                        H3 ^= (*b++ *C3).RotateLeft(17) * C4;
                        H3  = (H3.RotateLeft(15) + H4) * 5 + 0x96cd1c35;

                        // K4 - consume fourth integer
                        H4 ^= (*b++ *C4).RotateLeft(18) * C1;
                        H4  = (H4.RotateLeft(13) + H1) * 5 + 0x32ac3b17;
                    }

                    if (remainder > 0)
                    {
                        Tail(d + (length - remainder), remainder);
                    }
                }
            }
        }
 public static ascx_SourceCodeEditor editScript(this string scriptOrFile)
 {
     if (scriptOrFile.fileExists().isFalse())
     {
         if (scriptOrFile.local().valid())
         {
             scriptOrFile = scriptOrFile.local();
         }
         else
         {
             var h2Script = new H2(scriptOrFile);
             scriptOrFile = PublicDI.config.getTempFileInTempDirectory(".h2");
             h2Script.save(scriptOrFile);
         }
     }
     return(O2Gui.open <Panel>(scriptOrFile.fileName(), 800, 400)
            .add_SourceCodeEditor()
            .open(scriptOrFile));
 }
예제 #30
0
        static void testH2()
        {
            H2 roboH2 = new H2();

            roboH2.miOpen("MRX-H2");

            roboH2.move(0, 0, 10, 100, 10);

            float[] vals = roboH2.pose();
            if (vals != null)
            {
                Console.WriteLine("{0},{1}", vals[0], vals[1]);
            }

            //string[] vals = roboH2.GetH2Posi();
            //if (vals != null)
            //{
            //    Console.WriteLine("{0},{1}", vals[0], vals[1]);
            //}
        }
 public void saveAsScript()
 {
     this.invokeOnThread(
         () =>
     {
         //var defaultH2ScriptFolder = @"C:\O2\_XRules_Local\H2Scripts";
         var defaultH2ScriptFolder = currentSourceCodeFilePath().valid()
                                             ? currentSourceCodeFilePath().directoryName()
                                             : PublicDI.config.O2TempDir.pathCombine("..");
         Files.checkIfDirectoryExistsAndCreateIfNot(defaultH2ScriptFolder);
         var targetFile = O2Forms.askUserForFileToSave(defaultH2ScriptFolder, ".h2");
         if (targetFile.valid())
         {
             var h2Script = new H2(currentCode());
             h2Script.save(targetFile);
             commandsToExecute.open(targetFile);
         }
         "target: {0}".info(targetFile);
     });
 }
예제 #32
0
        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            //TimeSpan now = DateTime.Now.TimeOfDay;

            DateTime now; // = default(DateTime);

            now = Convert.ToDateTime("00:00:00");

            now = now.AddSeconds(time);


            // update the time
            H1.AnimateTo(now.Hour / 10);
            H2.AnimateTo(now.Hour % 10);

            M1.AnimateTo(now.Minute / 10);
            M2.AnimateTo(now.Minute % 10);

            S1.AnimateTo(now.Second / 10);
            S2.AnimateTo(now.Second % 10);
        }
 public static object executeH2Script(this string h2ScriptFile)
 {
     try
     {
         if (h2ScriptFile.extension(".h2").isFalse())
         {
             "[in executeH2Script]: file to execute must be a *.h2 file, it was:{0}".error(h2ScriptFile);
         }
         else
         {
             PublicDI.CurrentScript = h2ScriptFile;
             var h2Script = H2.load(h2ScriptFile);
             return(h2Script.execute());
         }
     }
     catch (Exception ex)
     {
         ex.log("in CSharp_FastCompiler.executeH2Script");
     }
     return(null);
 }
예제 #34
0
        public void LoadAndSaveH2File()
        {
            var codeSnippet = "return 42;";
            var h2 = new H2(codeSnippet);
            var h2Saved = h2.save();
            "h2Saved: {0}".info(h2Saved);
            var h2Loaded = H2.load(h2Saved);

            Assert.IsNotNull(h2);
            Assert.IsTrue(h2Saved.fileExists());
            Assert.IsNotNull(h2Loaded);
            Assert.AreEqual(h2Loaded.SourceCode, codeSnippet);

            var tempH2 = "test.h2".tempFile();
            h2.save(tempH2);
            var tempH2Loaded = H2.load(tempH2);
            var h2SourceCode = tempH2.h2_SourceCode();

            Assert.IsTrue(tempH2.fileExists());
            Assert.IsNotNull(tempH2Loaded);
            Assert.AreEqual(tempH2Loaded.SourceCode, codeSnippet);
            Assert.IsNotNull(h2SourceCode);
            Assert.AreEqual(h2SourceCode, codeSnippet);
        }
예제 #35
0
 public static H2 h2(this string code)
 {
     var h2 = new H2();
     h2.SourceCode = code;
     return h2;
 }
 public void saveAsScript()
 {
     this.invokeOnThread(
         () =>
         {
             //var defaultH2ScriptFolder = @"C:\O2\_XRules_Local\H2Scripts";
             var defaultH2ScriptFolder = currentSourceCodeFilePath().valid()
                                             ? currentSourceCodeFilePath().directoryName()
                                             : PublicDI.config.O2TempDir.pathCombine("..");
             Files.checkIfDirectoryExistsAndCreateIfNot(defaultH2ScriptFolder);
             var targetFile = O2Forms.askUserForFileToSave(defaultH2ScriptFolder, ".h2");
             if (targetFile.valid())
             {
                 var h2Script = new H2(currentCode());
                 h2Script.save(targetFile);
                 commandsToExecute.open(targetFile);
             }
             "target: {0}".info(targetFile);
         });
 }