コード例 #1
0
        public void Handler(ScriptCoreLib.Ultra.WebService.WebServiceHandler h)
        {
            Console.WriteLine("enter Handler");

            if (h.IsDefaultPath)
            {
                //h.Context.Response.Redirect("/redirect" + DateTime.Now.Millisecond);
                h.Context.Response.Redirect("/redirect" + DateTime.Now.Second);
                h.CompleteRequest();
            }
            else
            {
                // { UserHostAddress = 127.0.0.1, Path = /redirect168, HttpMethod = GET }

                h.Context.Response.AddHeader("hello", "world");

                h.Context.Response.Write(

                    new XElement("pre",
                        new
                        {
                            h.Context.Request.UserHostAddress,
                            h.Context.Request.Path,
                            h.Context.Request.HttpMethod
                        }.ToString()
                    ).ToString()

                );
                h.CompleteRequest();
            }
        }
コード例 #2
0
        public static void InvokeTest(Action<string> WriteLine)
        {
            var Enumerable_Range_1_2 = new[] { 1, 2 }.AsEnumerable();
            var Enumerable_Range_3_2 = new[] { 3, 4 }.AsEnumerable();


            foreach (var item in

                Enumerable_Range_1_2

                .SelectMany(
                    x =>
                    {
                        WriteLine("SelectMany " + new { x });

                        return Enumerable_Range_3_2.Select(
                            y =>
                            {
                                WriteLine("Select " + new { x, y });

                                return new { x, y };
                            }
                        );
                    }
                )

                // jsc should call it automatically to allow arrays
                .AsEnumerable()

                )
            {
                WriteLine(item.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IDefaultPage page)
        {
            var data = new[]
            {
                new { Text = "foo", i = "a", j = 71},
                new { Text = "goo", i = "d", j = 7},
                new { Text = "boo", i = "b", j = 87},
                new { Text = "noo", i = "c", j = 2}
            };

            data.OrderBy(k => k.i).WithEach(
                k =>
                {
                    new IHTMLPre { innerText = k.ToString() }.AttachToDocument();
                }
            );

            
            data.OrderBy(k => k.j).WithEach(
                k =>
                {
                    new IHTMLPre { innerText = k.ToString() }.AttachToDocument();
                }
            );

            @"Hello world".ToDocumentTitle();
            // Send data from JavaScript to the server tier
            service.WebMethod2(
                @"A string from JavaScript.",
                value => value.ToDocumentTitle()
            );
        }
コード例 #4
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            new IHTMLPre { new { Native.document.location.protocol, Native.document.location.host } }.AttachToDocument();
            // NFC ?
            new IHTMLPre { new { Native.window.navigator.userAgent } }.AttachToDocument();

            new { }.With(
                async delegate
                {
                    new IHTMLButton { "ReadAll" }.AttachToDocument().onclick += async delegate
                    {
                        new IHTMLHorizontalRule { }.AttachToDocument();
                        foreach (var row in await base.ReadAll())
                        {
                            new IHTMLPre { new { row.Key, row.z } }.AttachToDocument();
                        }

                    };

                    new IHTMLButton { "TakeLastOne" }.AttachToDocument().onclick += async delegate
                    {
                        new IHTMLHorizontalRule { }.AttachToDocument();
                        var row = await base.TakeLastOne();
                        new IHTMLPre { new { row.Key, row.z } }.AttachToDocument();

                    };

                    new IHTMLButton { "TakeOne" }.AttachToDocument().onclick += async delegate
                    {
                        new IHTMLHorizontalRule { }.AttachToDocument();
                        var row = await base.TakeOne();
                        new IHTMLPre { new { row.Key, row.z } }.AttachToDocument();

                    };

                    var AddAndCount = new IHTMLButton { "AddAndCount" }.AttachToDocument();

                    var content = new { Native.document.location.protocol, Native.document.location.host, Native.window.navigator.userAgent }.ToString();

                    // show it
                    new IHTMLPre { () => new { content } }.AttachToDocument();


                    while (await AddAndCount.async.onclick)
                    {

                        var count = await base.AddAndCount(
                            new XElement("hello", content)
                        );


                        // keep our data
                        content = "the one after " + new { count, Native.document.location.protocol, Native.document.location.host, Native.window.navigator.userAgent };

                        new IHTMLPre { new { count } }.AttachToDocument();
                    }

                }
            );
        }
コード例 #5
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            SpecialDelegate y = delegate
            {
                var err = new Exception(message: "message: \{nameof(page)}");

                new IHTMLPre { "err \{err.Message} \{err.StackTrace}" }.AttachToDocument();
コード例 #6
0
        public Task<int[]> WebMethod2(int e, Action<string> y)
        {
            MakeCyan();

            // Send it back to the caller.
            y(new { e }.ToString());

            var value = new[] {
                    (int)foo.b,
                    (int)foo.c
                };

            //var value = new[] {
            //         "a",
            //        "b"
            //    };


            foreach (var item in value)
            {
                Console.WriteLine(new { item });
            }

            return Task.FromResult(value);
        }
コード例 #7
0
        async void Invoke()
        {
            // X:\jsc.svn\examples\rewrite\Test\TestSwitchRewriteAsEnumerable\TestSwitchRewriteAsEnumerable\Class1.cs

            //f = new Array(1);
            //b.__stack0018__001d__0025 = f;
            //b.__stack0018__001d__0025[0] = { };
            //g = _6QUABoocDD2jQ9Bz7rBALA(b.__stack0018__001d__0025);

            IEnumerable<object> collection = new[] { new object() };


            // this causes a problem. why?
            // X:\jsc.svn\core\ScriptCoreLib\JavaScript\BCLImplementation\System\Threading\Tasks\Task\Task.Yield.cs
            // x:\jsc.svn\examples\javascript\async\asyncworkersourcesha1\asyncworkersourcesha1\application.cs
            await Task.Yield();

            //        f = new Array(1);
            //        b.__stack0019__001e__0026 = f;
            //        b.__stack0019__001e__0026[0] = { };
            //ref$c[0]._collection_5__1 = _6QUABoocDD2jQ9Bz7rBALA(b.__stack0019__001e__0026);


            ////  d = c.bwQABoBf2jWIHILvaqtMig();
            foreach (var item in collection)
            {
                Console.WriteLine(new { item });
                // 0:25ms {{ item = [object Object] }} 
            }
        }
コード例 #8
0
        public void Handler(WebServiceHandler h)
        {
            // { TypeFullName = FindWebApplicationIcon.Application }

            if (ApplicationWebService.Preview == null)
            {
                ApplicationWebService.Preview = "";

                var app = h.Applications.First();

                var a = new { app.TypeFullName, app.TypeName, Namespace = app.TypeFullName.TakeUntilLastOrEmpty("." + app.TypeName) };

                // file: assets/FindWebApplicationIcon/Preview.png size: 7806

                var Preview = "assets/" + a.Namespace + "/Preview.png";

                if (File.Exists(Preview))
                {
                    ApplicationWebService.Preview = Preview;
                    ApplicationWebService.PreviewBase64String =
                        "data:image/png;base64," +

                        Convert.ToBase64String(
                            File.ReadAllBytes(Preview)
                        );
                }

                Console.WriteLine(new { a, Preview });
            }

        }
コード例 #9
0
        private void documentMouse1_onmousemove(ScriptCoreLib.JavaScript.DOM.IEvent obj)
        {
            //if (!this.Enabled)
            //    return;

            InterestIntent();
        }
コード例 #10
0
        public static void Invoke()
        {
            //            before delegate { { scopeField1 = field1 } }
            //enter Inspection { { y = [object Object], Method = { InternalMethodToken = sAAABnvguzW_b3wQRWrbnyg }, Target = [object Object] } }
            //            { { xRowType = < Namespace >.__c__DisplayClass0 } }
            //            { { nRow = [object Object] } }
            //            { { yy = [object Object] } }
            //            inside the delegate { { scopeField1 = null } }
            //{ { z = null } }

            var scopeField1 = "field1";
            var scopeField2 = 7;
            var scopeField3 = new { foo = "bar" };

            Console.WriteLine("before delegate " + new { scopeField1, scopeField2, scopeField3 });

            Inspection(
                delegate
            {
                Console.WriteLine("inside the delegate  " + new { scopeField1, scopeField2, scopeField3 });

                return scopeField1;
            }
            );
        }
コード例 #11
0
        /// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="y">A callback to javascript.</param>
        public void WebMethod2(string e, Action<string> y)
        {
            string sql = "foo @x @x bar";
            int Count = 1;


            if (Count > 0)
            {

                //Console.WriteLine("we have InternalParameters for " + sql);

                var parameters = new[]
                {
                    new { ParameterName = "@x", Value = "u" },
                };

                var index =
                   from p in parameters
                   from i in sql.GetIndecies(p.ParameterName)
                   orderby i
                   select new { p, i };


                foreach (var p in parameters)
                {
                    // java seems to like indexed parameters instead
                    sql = sql.Replace(p.ParameterName, "?");
                }

                y(sql);
                // add values
            }
        }
コード例 #12
0
        public Task<data1[]> WebMethod4(int e, Action<string> y)
        {
            MakeYellow();

            // Send it back to the caller.
            y(new { e }.ToString());

            var value = new[] {
                // jsc why cant we return .this?
                   new data1 { e = "hello1!", CallbackCopy = new ApplicationWebService() },
                   new data1 { e = "hello2!", CallbackCopy = new ApplicationWebService() }
            };

            //var value = new[] {
            //         "a",
            //        "b"
            //    };


            foreach (var item in value)
            {
                Console.WriteLine(new { item });
            }

            return Task.FromResult(value);
        }
コード例 #13
0
        /// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="y">A callback to javascript.</param>
        public void WebMethod2(string e, Action<string> y)
        {
            var x = new NameValueCollection();

            var w = new StringBuilder();

            w.AppendLine("adding foo");

            //x.Add("foo", e);
            x["foo"] = e;



            w.AppendLine("reading foo");

            var foo = x["foo"];

            var message = new
            {
                //w = w.ToString(),
                foo
            };

            y(message.ToString());
        }
コード例 #14
0
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151231/tdjdosboxe



        public void Handler(WebServiceHandler h)
        {
            var HostUri = new
            {
                Host = h.Context.Request.Headers["Host"].TakeUntilIfAny(":"),
                Port = h.Context.Request.Headers["Host"].SkipUntilOrEmpty(":")
            };

            if (HostUri.Port == "")
                HostUri = new { HostUri.Host, Port = "80" };

            Console.WriteLine(
                new { h.Context.Request.Path }
                );
            // http://isorecorder.alexfeinman.com/W7.htm
            // http://kbarr.net/bochs
            // http://www.imgburn.com/index.php?act=download
            if (h.Context.Request.Path == "/war1.img")
            {
                h.Context.Response.Redirect("/assets/jDOSBoxAppletWithWarcraft/war1.img");
                h.CompleteRequest();
                return;
            }

            if (h.Context.Request.Path == "/jDOSBoxAppletWithWarcraft.jnlp")
            {
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201402/20140222

                h.Context.Response.ContentType = "application/x-java-jnlp-file";

                // X:\jsc.smokescreen.svn\core\javascript\com.abstractatech.analytics\com.abstractatech.analytics\ApplicationWebService.cs


                //#### Java Web Start Error:
                //#### Unable to load resource: file:/assets/jDOSBoxAppletWithWarcraft.Application/jDOSBoxAppletWithWarcraft.jnlp


                // http://en.wikipedia.org/wiki/Java_Web_Start
                h.Context.Response.Write(@"
<jnlp spec='1.4+' codebase='http://" + HostUri.Host + ":" + HostUri.Port + @"/' href='jDOSBoxAppletWithWarcraft.jnlp'
><information><title>jDOSBoxAppletWithWarcraft</title>
<vendor>Example vendor</vendor><description>Example long description</description>
<description kind='short'>Example short description</description></information>
<resources><j2se href='http://java.sun.com/products/autodl/j2se' version='1.4+' />
  <jar href='assets/jDOSBoxAppletWithWarcraft.Application/jDOSBoxAppletWithWarcraft.ApplicationApplet.jar'/>  

</resources>
<application-desc main-class='jDOSBoxAppletWithWarcraft.ApplicationApplet' />
<j2se version='1.4+' ava-vm-args='' /></jnlp>
");


                h.CompleteRequest();
                return;
            }


        }
コード例 #15
0
        public async Task<int[]> GetData(__closure c)
        {
            var source = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };


            var value = source.Where(x => c.__Invoke(x)).ToArray();

            return value;
        }
コード例 #16
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140429
            // X:\jsc.svn\examples\javascript\forms\Test\TestSQLJoin\TestSQLJoin\ApplicationWebService.cs


            var DealerContact = new[] { 
                new { DealerId = 2, DealerContactText = ""},
                new { DealerId = 3, DealerContactText = "hello "},
                new { DealerId = 4, DealerContactText = ""}
            };

            var Dealer = new[] { 
                new { ID = 1, DealerText = ""},
                new { ID = 3, DealerText = "world"},
                new { ID = 5, DealerText = ""}
            };


            var DealerOther = new[] { 
                new { ID = 0, DealerOtherText = ""},
                new { ID = 3, DealerOtherText = "!!"},
                new { ID = 20, DealerOtherText = ""}
            };


            // script: error JSC1000: No implementation found for this native method, please implement 
            // [static System.Linq.Enumerable.Join(
            // System.Collections.Generic.IEnumerable`1[[<>f__AnonymousType$234$0`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
            // [System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.IEnumerable`1[[<>f__AnonymousType$239$1`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Func`2[[<>f__AnonymousType$234$0`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Func`2[[<>f__AnonymousType$239$1`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Func`3[[<>f__AnonymousType$234$0`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[<>f__AnonymousType$239$1`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[<>f__AnonymousType$244$2`2[[<>f__AnonymousType$234$0`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[<>f__AnonymousType$239$1`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TestLINQJoin.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]])]

            var dealercontacts = from contact in DealerContact
                                 join dealer in Dealer on contact.DealerId equals dealer.ID

                                 // add one more
                                 join other in DealerOther on contact.DealerId equals other.ID

                                 // new viewrow { x = ?, }
                                 select new { contact, dealer, other };

            dealercontacts.WithEach(
                x =>
                {
                    // { DealerContactText = hello , DealerText = world, DealerOtherText = !! }

                    new IHTMLPre {
                        new
                        {
                            x.contact.DealerContactText,
                            x.dealer.DealerText,
                            x.other.DealerOtherText,
                        }
                    }.AttachToDocument();
                }
            );

        }
コード例 #17
0
        public int[] GetData(Func<int, bool> c)
        {
            var source = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };


            var value = source.Where(x => c(x)).ToArray();

            return value;
        }
コード例 #18
0
		// http://msdn.microsoft.com/en-us/library/ie/dn265037(v=vs.85).aspx

		/// <summary>
		/// This is a javascript application.
		/// </summary>
		/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
		public Application(IApp page)
		{
			// inspired by
			// http://www.amplifon.co.uk/sounds-of-street-view/how-and-create/index.html


			new CanvasRenderingContext2D(500, 400).With(
			   async ctx =>
				{
					// "X:\jsc.svn\examples\javascript\WebGL\WebGLDashedLines\WebGLDashedLines.sln"

					// using?
					ctx.canvas.AttachToDocument();


					//  Marching Ant code
					var antOffset = 0;	// Starting offset value
					var dashList = new[] { 12.0, 3, 3, 3 };	 // Create a dot/dash sequence

					//while (AttachToDocument)
					while (true)
					{
						ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
						//  Assign the dashList for the dash sequence
						ctx.setLineDash(dashList);
						//  Get the current offset 
						ctx.lineDashOffset = antOffset;	 // Animate the lines
						ctx.lineJoin = "round";
						ctx.lineWidth = 3;

						ctx.strokeStyle = "blue";
						ctx.strokeRect(5, 5, 300, 250);
						ctx.strokeStyle = "red";
						ctx.strokeRect(150, 200, 300, 150);
						ctx.lineDashOffset = -antOffset;  // Reverse animation
						ctx.lineWidth = 7;
						ctx.strokeStyle = "green";
						ctx.strokeRect(250, 50, 150, 250);

						antOffset++;
						if (antOffset >= dashList.Sum())	 // Reset offset after total of dash List values
						{
							antOffset = 0;
						}

						Native.document.title = new { antOffset }.ToString();

						// can we see anything?
						await Task.Delay(15);
					}
				}
		   );




		}
コード例 #19
0
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140511/roslyn




        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            var i = 13;

            var u = new { i };

            // did jsc stack rewriter fix roslyn tostring thingy for jsc?
            WriteLine(u.ToString());
        }
コード例 #20
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {

            var all = new[] { "12", "Not a Number", "13" };


            //{ { zz = { { r8 = 0 } } } }
            //{ { zz = { { r8 = 0 } } } }
            //{ { zz = { { r8 = 0 } } } }

            // Error	1	Type of conditional expression cannot be determined because there is no implicit conversion between
            // '<anonymous type: var r8>' and '<anonymous type: double r8>'	X:\jsc.svn\examples\javascript\Test\TestLINQTryParse\TestLINQTryParse\Application.cs	42	30	TestLINQTryParse

            //{
            //                Location =
            //               assembly: V:\TestLINQTryParse.Application.exe
            //               type: TestLINQTryParse.Application +<> c__DisplayClass0, TestLINQTryParse.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null
            // offset:
            //                0x0008
            //  method:<> f__AnonymousType$234$0`2[System.String,<> f__AnonymousType$237$1`1[System.Double]] <.ctor > b__2(System.String) }
            //        script: error JSC1000: Method: <.ctor > b__2, Type: TestLINQTryParse.Application +<> c__DisplayClass0; emmiting failed : System.NotImplementedException: { ParameterType = System.Double &, p = [0x002f] stloc.0 + 0 - 1{[0x002a]
            //        newobj     +1 -2{[0x0000]
            //        ldarg.1    +1 -0}
            //    alternatives
            //} , m = Boolean TryParse(System.String, Double ByRef) }


            //            0200001e TestLINQTryParse.Application +<> c__DisplayClass0
            //{
            //                Location =
            //               assembly: V:\TestLINQTryParse.Application.exe
            //               type: TestLINQTryParse.Application +<> c__DisplayClass0, TestLINQTryParse.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null
            // offset:
            //                0x0008
            //  method:<> f__AnonymousType$236$0`2[System.String,<> f__AnonymousType$239$1`1[System.Int32]] <.ctor > b__2(System.String) }
            //        script: error JSC1000: Method: <.ctor > b__2, Type: TestLINQTryParse.Application +<> c__DisplayClass0; emmiting failed : System.NotImplementedException: { ParameterType = System.Int32 &, p = [0x0027] stloc.0 + 0 - 1{[0x0022]
            //        newobj     +1 -2{[0x0000]
            //        lda
            //at jsc.IdentWriter.JavaScript_WriteParameters(Prestatement p, ILInstruction i, ILFlowStackItem[] s, Int32 offset, MethodBase m) in x:\jsc.internal.svn\compiler\jsc\Languages\IdentWriter.cs:line 836



            var z = from s in all
                        //let zz = double.TryParse(s, out var r8) ? new { r8 } : new { r8 = 0.0 }
                    let zz = int.TryParse(s, out int i4) ? new { i4 } : new { i4 = 0 }
                    select new { zz };


            z.WithEach(
                zz =>
                {
                    new IHTMLPre { zz }.AttachToDocument();

                }
            );
        }
コード例 #21
0
        public override string InternalGetConnectionString()
        {
            var key = new { DataSource, ReadOnly, InternalUser, InternalHost, InternalInstanceName }.ToString();

            //Console.WriteLine("InternalGetConnectionString " + new { key });

            InterlockedInternalGetConnectionString(key, this);

            return key;
        }
コード例 #22
0
        public void Handler(ScriptCoreLib.Ultra.WebService.WebServiceHandler h)
        {
            // ssl handshake gives certificate to global, it gives it to the handler, we give it to UI

            Console.WriteLine("enter Handler " + new { h.ClientCertificate });

            this.id = new { h.ClientCertificate }.ToString();

            this.status.Value = this.id;

        }
コード例 #23
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            var a = new[] { 5, 6, 7, 8, 9 };


            foreach (var item in a.Skip(2).Take(2))
            {
                new IHTMLDiv { innerText = "" + item }.AttachToDocument();

            }
        }
コード例 #24
0
        /// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="y">A callback to javascript.</param>
        public void WebMethod2(string e, Action<string> y)
        {
            var x = typeof(string);
            var xx = e.GetType();

            var xxx = ((object)e) is string;

            var message = new { x, xx, xxx };

            y(message.ToString());
        }
コード例 #25
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {

            var a = new[]
            {
                new foo { goo = 4 },
                new foo { goo = 5 },
            };

            var sum = Invoke(a);

            Native.document.body.innerText = "sum: \{sum}";
コード例 #26
0
        public async Task<PerformanceResourceTimingData2ApplicationPerformanceRow[]> ReadAll()
        {
            Console.WriteLine("enter ReadAll");

            var value = new[] {
                new PerformanceResourceTimingData2ApplicationPerformanceRow {
                    Key = (PerformanceResourceTimingData2ApplicationPerformanceKey)13, z = new XElement("hello", "world")
                }
               };

            return value;
        }
コード例 #27
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            // X:\jsc.svn\examples\javascript\Test\TestIEnumerableForService\TestIEnumerableForService\ApplicationWebService.cs


            var x = new { hello = "world" };

            new IHTMLPre { new { x } }.AttachToDocument();

            // X:\jsc.svn\core\ScriptCoreLib\JavaScript\BCLImplementation\System\Object.cs
            new IHTMLPre { new foo() }.AttachToDocument();
        }
コード例 #28
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            var a = new[] { 9 };
            var b = new[] { "hello world" };

            a.Zip(b, (x, y) => new { x, y }).FirstOrDefault().With(
                z =>
                {
                    new IHTMLPre { z }.AttachToDocument();
                }
            );
        }
コード例 #29
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            // X:\jsc.svn\core\ScriptCoreLib\Shared\BCLImplementation\System\Dynamic\GetIndexBinder.cs


            dynamic x = new {foo = "goo" };

            // script: error JSC1000: No implementation found for this native method, please implement [static Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, System.Type, System.Collections.Generic.IEnumerable`1[[Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo, Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]])]

            new IHTMLPre { new { foo = x["foo"] } }.AttachToDocument();

        }
コード例 #30
0
        public static void scrollTo(this IWindow w, int x, int y, TimeSpan time)
        {
            var sync = new object();
            scrollTo_sync = sync;

            var s = new Stopwatch();

            s.Start();

            var start = new { Native.Document.body.scrollLeft, Native.Document.body.scrollTop };
            var check = start;


            Action loop = null;

            loop = delegate
            {
                if (sync != scrollTo_sync)
                {
                    return;
                }

                // scrollTo { check = { scrollLeft = 106, scrollTop = 0 }, current = { scrollLeft = 0, scrollTop = 0 } }


                var a = 1.0;

                if (s.ElapsedMilliseconds < time.TotalMilliseconds)
                {
                    a = s.ElapsedMilliseconds / time.TotalMilliseconds;

                    Native.window.requestAnimationFrame += loop;

                }

                var scrollLeft = (int)Math.Ceiling(start.scrollLeft + (double)(x - start.scrollLeft) * a);

                // this was expen
                var scrollTop = (int)Math.Ceiling(start.scrollTop + (double)(y - start.scrollTop) * a);

                //Console.WriteLine(new { a, x, xx = scrollLeft, s.Elapsed });

                w.scrollTo(scrollLeft, scrollTop);

                // scrollTo { check = { scrollLeft = 0, scrollTop = 0 }, current = { scrollLeft = 77, scrollTop = 0 } }



            };

            Native.window.requestAnimationFrame += loop;
        }
コード例 #31
0
        public void __Application(IApplicationLoader app)
        {
            //app.LoadingAnimation.FadeOut();

            var DefaultTitle = "jsc solutions";


            Native.Document.title = DefaultTitle;

            StringActionAction GetTitleFromServer = new UltraWebService().GetTitleFromServer;



            GetTitleFromServer(
                n => Native.Document.title = n
                );

            var MyPagesBackground = new IHTMLDiv
            {
            };

            MyPagesBackground.style.overflow = IStyle.OverflowEnum.hidden;
            MyPagesBackground.style.position = IStyle.PositionEnum.absolute;
            MyPagesBackground.style.width    = "100%";
            MyPagesBackground.style.height   = "100%";
            MyPagesBackground.AttachToDocument();

            var MyPages = new IHTMLDiv
            {
            };

            MyPages.style.overflow = IStyle.OverflowEnum.auto;
            MyPages.style.position = IStyle.PositionEnum.absolute;
            MyPages.style.width    = "100%";
            MyPages.style.height   = "100%";
            MyPages.AttachToDocument();

            var MyPagesInternal = new IHTMLDiv();

            MyPagesInternal.style.margin = "4em";
            MyPagesInternal.AttachTo(MyPages);

            // http://www.google.com/support/forum/p/Google+Analytics/thread?tid=486a963e463df665&hl=en
            var gapathname = Native.Document.location.pathname;
            var gasearch   = Native.Document.location.search;
            var gahash     = Native.Window.escape(Native.Document.location.hash);
            var gapageview = gapathname + gasearch + gahash;

            var hash = Native.Document.location.hash;

            Action <string> Analytics = delegate { };

            #region logo
            {
                var IsStudio = Native.Document.location.hash.StartsWith("#/studio");

                if (Native.Document.location.host.StartsWith("studio."))
                {
                    IsStudio = true;
                }

                if (IsStudio)
                {
                    new StudioView(AddSaveButton).Content.AttachToDocument();
                }
                else if (Native.Document.location.hash.StartsWith("#/docs"))
                {
                    var view = new DocumentationCompilationViewer();

                    view.TouchTypeSelected +=
                        type =>
                    {
                        Native.Document.location.hash = "#/docs/" + type.FullName;

                        Analytics("#/docs/" + type.FullName);
                    };
                }
                else if (Native.Document.location.hash.StartsWith("#/warehouse"))
                {
                    new UltraWebService().ThreeDWarehouse(
                        y =>
                    {
                        Func <string, IHTMLAnchor> Build =
                            mid =>
                        {
                            var a = new IHTMLAnchor {
                                href = "http://sketchup.google.com/3dwarehouse/details?ct=hppm&mid=" + mid
                            }.AttachTo(MyPagesInternal);
                            var img = new IHTMLImage {
                                src = "http://sketchup.google.com/3dwarehouse/download?rtyp=st&ctyp=other&mid=" + mid
                            }.AttachTo(a);

                            return(a);
                        };

                        var imgs = Enumerable.ToArray(
                            from k in y.Elements()
                            select Build(k.Value)

                            );
                    }
                        );
                }

                else if (Native.Document.location.hash == "#/source")
                {
                    var sln = new TreeNode(() => new VistaTreeNodePage());

                    sln.Text       = "Solution";
                    sln.IsExpanded = true;

                    Action <TreeNode> AddReferences =
                        p =>
                    {
                        var r = p.Add("References", new References());

                        r.Add("System", new Assembly());
                        r.Add("System.Core", new Assembly());
                        r.Add("ScriptCoreLib", new Assembly());
                        r.Add("ScriptCoreLib.Ultra", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Library", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Controls", new Assembly());
                        r.Add("ScriptCoreLibJava", new Assembly());
                        r.Add("jsc.meta", new Assembly());
                    };

                    Action <TreeNode> AddUltraSource =
                        p =>
                    {
                        var my = p.Add("My.UltraSource");
                        my.Add("Default.htm", new HTMLDocument());
                        my.Add("jsc.png", new ImageFile());
                    };

                    {
                        var p = sln.Add("Visual C# Project", new VisualCSharpProject());


                        AddReferences(p);
                        AddUltraSource(p);



                        p.Add("Application.cs", new VisualCSharpCode());
                        p.Add("WebService.cs", new VisualCSharpCode());
                        p.Add("Program.cs", new VisualCSharpCode());
                    }

                    {
                        var p = sln.Add("Visual Basic Project", new VisualBasicProject());

                        AddReferences(p);
                        AddUltraSource(p);

                        p.Add("Application.vb", new VisualBasicCode());
                        p.Add("WebService.vb", new VisualBasicCode());
                        p.Add("Program.vb", new VisualBasicCode());
                    }


                    {
                        var p = sln.Add("Visual F# Project", new VisualFSharpProject());

                        AddReferences(p);
                        AddUltraSource(p);


                        p.Add("Application.fs", new VisualFSharpCode());
                        p.Add("WebService.fs", new VisualFSharpCode());
                        p.Add("Program.fs", new VisualFSharpCode());
                    }

                    sln.Container.style.Float = IStyle.FloatEnum.right;
                    sln.Container.AttachTo(MyPagesInternal);

                    new SourceEditorHeader().Container.AttachTo(MyPagesInternal);

                    //new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "Create your own Ultra Application project template").AttachTo(MyPagesInternal);

                    var n = new TextEditor(MyPagesInternal);

                    n.Width  = 600;
                    n.Height = 400;

                    //n.InnerHTML = "<p>Create your own <b>Ultra Application</b> Project Template</p>";


                    new DefaultPage1().Container.AttachTo(n.Document.body);

                    var m1 = new SimpleCodeView();

                    m1.Container.AttachTo(MyPagesInternal);
                    //m1.SelectType.onchange +=
                    //    delegate
                    //    {
                    //        m1.TypeName.innerText = m1.SelectType.value;
                    //    };

                    //m1.RunJavaScript.onclick +=
                    //    delegate
                    //    {
                    //        m1.RunJavaScript.style.color = JSColor.Blue;

                    //        try
                    //        {
                    //            Native.Window.eval(m1.Code1.value);

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //        catch
                    //        {
                    //            m1.RunJavaScript.style.color = JSColor.Red;

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //    };
                    new Compilation().GetArchives().SelectMany(k => k.GetAssemblies()).First(k => k.Name == "ScriptCoreLib").WhenReady(
                        ScriptCoreLib =>
                    {
                        // we do not have reflection in place for native wrappers :/

                        m1.SelectEvent.Clear();

                        var Element = ScriptCoreLib.GetTypes().Single(k => k.FullName == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");
                        //var Element = ScriptCoreLib.GetTypes().Single(k => k.HTMLElement == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");

                        Action <CompilationEvent> Add =
                            SourceEvent =>
                        {
                            m1.SelectEvent.Add(
                                new IHTMLOption {
                                innerText = SourceEvent.Name
                            }
                                );
                        };

                        Element.GetEvents().ForEach(Add);
                    }
                        );


                    m1.SelectEvent.onchange +=
                        delegate
                    {
                        m1.EventName.innerText = m1.SelectEvent.value;
                    };
                }
                else if (Native.Document.location.hash == "#/UltraApplicationWithAssets")
                {
                    new UltraApplicationWithAssets().Container.AttachToDocument();
                }
                else
                if (Native.Document.location.hash == "#/audio")
                {
                    Action AtTimer = delegate { };

                    (1000 / 15).AtInterval(
                        tt =>
                    {
                        AtTimer();
                    }
                        );

                    new SoundCloudBackground().Container.AttachTo(MyPagesBackground);
                    new SoundCloudHeader().Container.AttachTo(MyPagesInternal);

                    var page = 1;

                    var Tracks = new IHTMLDiv().AttachTo(MyPagesInternal);
                    Tracks.style.margin = "1em";

                    var More = new SoundCloudMore();

                    var AudioLinks = default(AudioLink);

                    var LoadCurrentPage = default(Action);

                    LoadCurrentPage = delegate
                    {
                        var loading = new SoundCloudLoading();

                        loading.Container.AttachTo(Tracks);


                        new UltraWebService().SoundCloudTracksDownload(
                            System.Convert.ToString(page),
                            ee =>
                        {
                            if (loading != null)
                            {
                                loading.Container.Orphanize();
                                loading = null;
                            }

                            var t = new SoundCloudTrack();

                            t.Content.ApplyToggleConcept(t.HideContent, t.ShowContent).Hide();

                            t.Title.innerHTML = ee.trackName;
                            t.Waveform.src    = ee.waveformUrl;

                            t.Audio.src        = ee.streamUrl;
                            t.Audio.autobuffer = true;


                            AudioLinks = new AudioLink
                            {
                                Audio = t.Audio,
                                Prev  = AudioLinks
                            };

                            var _AudioLinks = AudioLinks;

                            if (AudioLinks.Prev != null)
                            {
                                AudioLinks.Prev.Next = AudioLinks;
                            }
                            else
                            {
                                // we are the first  :)
                                t.Audio.play();
                            }

                            t.MoreButton.onclick +=
                                delegate
                            {
                                t.Audio.pause();

                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Audio.onended +=
                                delegate
                            {
                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Identity.innerText = ee.uid;

                            t.Play.onclick  += eee => { eee.PreventDefault(); t.Audio.play(); };
                            t.Pause.onclick += eee => { eee.PreventDefault(); t.Audio.pause(); };

                            t.Title.style.cursor = IStyle.CursorEnum.pointer;
                            t.Title.onclick     += eee =>
                            {
                                eee.PreventDefault();

                                var playing = true;

                                if (t.Audio.paused)
                                {
                                    playing = false;
                                }

                                if (t.Audio.ended)
                                {
                                    playing = false;
                                }

                                if (!playing)
                                {
                                    t.Audio.play();
                                }
                                else
                                {
                                    t.Audio.pause();
                                }
                            };

                            DoubleAction SetProgress1 = p =>
                            {
                                t.Gradient3.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient4.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            t.Gradient5.style.Opacity = 0.4;
                            t.Gradient6.style.Opacity = 0.4;

                            DoubleAction SetProgress2 = p =>
                            {
                                t.Gradient5.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient6.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            AtTimer +=
                                delegate
                            {
                                if (t.Audio.duration == 0)
                                {
                                    t.Play.Hide();
                                    t.Pause.Hide();
                                    return;
                                }
                                else
                                {
                                    var playing = true;

                                    if (t.Audio.paused)
                                    {
                                        playing = false;
                                    }

                                    if (t.Audio.ended)
                                    {
                                        playing = false;
                                    }

                                    if (!playing)
                                    {
                                        t.Title.style.color = Color.None;
                                    }
                                    else
                                    {
                                        t.Title.style.color = Color.Blue;
                                    }

                                    t.Play.Show(!playing);
                                    t.Pause.Show(playing);
                                }

                                var p = t.Audio.currentTime / t.Audio.duration;
                                SetProgress1(p);
                            };

                            t.Waveform.onmouseout +=
                                delegate
                            {
                                SetProgress2(0);
                            };

                            t.Waveform.onmousemove +=
                                eee =>
                            {
                                SetProgress2(eee.OffsetX / 800.0);
                            };

                            t.Waveform.onclick +=
                                eee =>
                            {
                                t.Audio.currentTime = t.Audio.duration * (eee.OffsetX / 800.0);
                                t.Audio.play();
                            };

                            t.Waveform.style.cursor = IStyle.CursorEnum.pointer;

                            SetProgress1(0);
                            SetProgress2(0);

                            t.Container.AttachTo(Tracks);
                        }
                            );


                        10000.AtDelay(
                            delegate
                        {
                            More.MoreButton.FadeIn(0, 1000, null);
                        }
                            );
                    };


                    More.MoreButton.Hide();
                    More.Container.AttachTo(MyPagesInternal);

                    More.MoreButton.onclick += eee =>
                    {
                        eee.PreventDefault();
                        More.MoreButton.FadeOut(1, 300,
                                                delegate
                        {
                            page++;
                            LoadCurrentPage();
                        }
                                                );
                    };

                    LoadCurrentPage();
                }
                else
                {
                    //new PromotionWebApplication1.HTML.Audio.FromAssets.Track1 { controls = true }.AttachToDocument();
                    //new PromotionWebApplication1.HTML.Audio.FromWeb.Track1 { controls = true, autobuffer = true }.AttachToDocument();

                    var IsAvalonJavaScript   = hash == "#/avalon.js";
                    var IsAvalonActionScript = hash == "#/avalon.as";
                    var IsAvalon             = IsAvalonActionScript || IsAvalonJavaScript;

                    //if (IsAvalon)
                    //{

                    //{
                    //    var ccc = new IHTMLDiv();

                    //    ccc.style.position = IStyle.PositionEnum.absolute;
                    //    ccc.style.left = "15%";
                    //    ccc.style.right = "15%";
                    //    ccc.style.top = "15%";


                    //    var Now = DateTime.Now;

                    //    var CountDown = new CountDownGadgetConcept(CountDownGadget.Create)
                    //    {
                    //        ShowOnlyDays = true,
                    //        Event = new DateTime(2010, 5, 24, 23, 59, 50),

                    //    };

                    //    CountDown.Element.GadgetContainer.style.color = "#808080";
                    //    CountDown.Element.GadgetContainer.style.textShadow = "#E0E0E0 1px 1px 1px";


                    //    CountDown.Element.GadgetContainer.AttachTo(ccc);
                    //    CountDown.Element.GadgetContainer.FadeIn(3000, 2000, null);

                    //    ccc.AttachToDocument();
                    //}

                    {
                        var ccc = new IHTMLDiv();

                        ccc.style.position   = IStyle.PositionEnum.absolute;
                        ccc.style.left       = "50%";
                        ccc.style.top        = "50%";
                        ccc.style.marginLeft = (-JSCSolutionsNETCarouselCanvas.DefaultWidth / 2) + "px";
                        ccc.style.marginTop  = (-JSCSolutionsNETCarouselCanvas.DefaultHeight / 2) + "px";

                        ccc.style.SetSize(JSCSolutionsNETCarouselCanvas.DefaultWidth, JSCSolutionsNETCarouselCanvas.DefaultHeight);

                        ccc.AttachToDocument();

                        if (IsAvalonActionScript)
                        {
                            var alof = new UltraSprite();
                            alof.ToTransparentSprite();
                            alof.AttachSpriteTo(ccc);
                        }
                        else
                        {
                            var alo = new JSCSolutionsNETCarouselCanvas();
                            alo.Container.AttachToContainer(ccc);

                            alo.AtLogoClick +=
                                delegate
                            {
                                //Native.Window.open("http://sourceforge.net/projects/jsc/", "_blank");
                                Native.Window.open("/download", "_blank");
                            };
                        }
                    }
                    //}
                    //else
                    //{
                    //    var cc = new HTML.Pages.FromAssets.Controls.Named.CenteredLogo_Kamma();

                    //    cc.Container.AttachToDocument();

                    //    // see: http://en.wikipedia.org/wiki/Perl_control_structures
                    //    // "Unless" == "if not"  ;)

                    //    IsMicrosoftInternetExplorer.YetIfNotThen(cc.TheLogoImage.BeginPulseAnimation).ButIfSoThen(cc.TheLogoImage.HideNowButShowAtDelay);
                    //}

                    var aa = new About();
                    aa.Service.innerText = gapageview;
                    aa.Container.AttachToDocument();
                }
            }
            #endregion


            Analytics =
                __hash =>
            {
                var __gahash     = Native.Window.escape(__hash);
                var __gapageview = gapathname + gasearch + __gahash;


                "UA-13087448-1".ToGoogleAnalyticsTracker(
                    pageTracker =>
                {
                    pageTracker._setDomainName(".jsc-solutions.net");
                    pageTracker._trackPageview(__gapageview);
                }
                    );
            };

            Analytics(Native.Document.location.hash);
        }