Exemplo n.º 1
0
 static foo getfoo()
 {
     foo foo1 = new foo();
     foo1.x=10;
     foo1.y="foo";
     return foo1;
 }
Exemplo n.º 2
0
        public void DIContext_InjectByName_MultipleTypeFound_Test()
        {
            //arrange
            Mock <IDependencyMap> mockDependencyMap1 = new Mock <IDependencyMap>();
            Mock <IDependencyMap> mockDependencyMap2 = new Mock <IDependencyMap>();
            Mock <IDIContainer>   mockContainer      = new Mock <IDIContainer>();

            mockContainer.Setup(c => c.SearchDependency(It.IsAny <string>())).Returns(new List <IDependencyMap>()
            {
                mockDependencyMap1.Object, mockDependencyMap2.Object
            });

            Mock <DIContext> mockDIContext = new Mock <DIContext>(typeof(Boot))
            {
                CallBase = true
            };

            mockDIContext.SetupGet(ctx => ctx.Container).Returns(mockContainer.Object);

            //act
            foo foo = mockDIContext.Object.InjectByName <foo>("NotExists");

            //assert
            Assert.IsNull(foo);
        }
    static void Main(string[] args)
    {
        foo aFoo = new foo();

        aFoo.TestMethod();
        //Console.WriteLine(aFoo.ToString()); // if this line is uncommented TestMethod will never return
    }
Exemplo n.º 4
0
 public override bool Equals(object obj){
       if(obj == null) return false;
       foo test = (foo)obj)
       if(test == null) return false;
       
       if(this.H == obj.H && this.K == obj.K) return true;
 }
    public foo Copy()
    {
        foo newc = new foo();

        newc.Bar = this.Bar;
        return(newc);
    }
    static void Main(string[] args)
    {
        var foo = new foo();

        foo.SomeMethod(typeof(string));
        foo.SomeMethod(typeof(foo));
    }
Exemplo n.º 7
0
        public void Test()
        {
            Assert.AreEqual(3, ((Func <int>)() => 1 + 2)());
            Assert.AreEqual(9, ((Func <int, int>)x => x * x)(3));
            Assert.AreEqual(9, (x => x * x)(3));
            foo f = () =>
                    9;

            f += () => 10;
            f += () => 11;
            Console.WriteLine(f());

            foo f1 =
                delegate()
            {
                Console.WriteLine(1);
                return(1);
            };

            f1 +=
                delegate()
            {
                Console.WriteLine(2);
                return(2);
            };
            Console.WriteLine(f1());
        }
        public void PublicFieldAutoInjector_Inject_Test()
        {
            //arrange
            Mock <IDependencyHolder> mockDependencyHolder = new Mock <IDependencyHolder>();

            mockDependencyHolder.Setup(dh => dh.GetInstance(null)).Returns(new bar());

            Mock <IDependencyMap> mockDependencyMap = new Mock <IDependencyMap>();

            mockDependencyMap.Setup(dm => dm.PrimaryDependencyHolder).Returns(mockDependencyHolder.Object);

            Mock <IDIContainer> mockContainer = new Mock <IDIContainer>();

            mockContainer.Setup(c => c.ContainsDependency(It.IsAny <string>())).Returns(true);
            mockContainer.Setup(c => c.GetDependencyMap(It.IsAny <string>())).Returns(mockDependencyMap.Object);

            Mock <PublicFieldAutoInjector> mockPublicFieldAutoInjector = new Mock <PublicFieldAutoInjector>(mockContainer.Object, typeof(foo))
            {
                CallBase = true
            };

            mockPublicFieldAutoInjector.Setup(pa => pa.GetMemberInjectDependency(It.IsAny <MemberInfo>())).Returns((string)null);

            foo afoo = new foo();

            //act
            mockPublicFieldAutoInjector.Object.Inject(afoo);


            //assert
            Assert.IsNotNull(afoo.FieldBar);
        }
Exemplo n.º 9
0
        public void PropertyAutoInjector_Inject_PrimaryOrPreferredTargetDependencyNotFound_Test()
        {
            //arrange
            Mock <IDependencyMap> mockDependencyMap = new Mock <IDependencyMap>();

            mockDependencyMap.Setup(dm => dm.PrimaryDependencyHolder).Returns((IDependencyHolder)null);

            Mock <IDIContainer> mockContainer = new Mock <IDIContainer>();

            mockContainer.Setup(c => c.ContainsDependency(It.IsAny <string>())).Returns(true);
            mockContainer.Setup(c => c.GetDependencyMap(It.IsAny <string>())).Returns(mockDependencyMap.Object);

            Mock <PropertyAutoInjector> mockPropertyAutoInjector = new Mock <PropertyAutoInjector>(mockContainer.Object, typeof(foo))
            {
                CallBase = true
            };

            mockPropertyAutoInjector.Setup(pa => pa.GetMemberInjectDependency(It.IsAny <MemberInfo>())).Returns((string)null);

            foo afoo = new foo();

            //act
            mockPropertyAutoInjector.Object.Inject(afoo);


            //assert
            Assert.IsNull(afoo.PropBar);
        }
Exemplo n.º 10
0
        public static void Main(string[] e)
        {
            {
                foo[] z = new foo[0];
                // Error	1	Cannot implicitly convert type 'object[]' to 'TestGenericArray.Activities.foo[]'. An explicit conversion exists (are you missing a cast?)	Y:\jsc.svn\examples\java\android\Test\TestGenericArray\TestGenericArray\Program.cs	24	23	TestGenericArray
                // Unable to cast object of type 'System.Object[]' to type 'TestGenericArray.Activities.foo[]'.
                object[] y = z;
            }

            //{
            //    var x = new __List<foo>
            //    {
            //        Item1 = new foo(),
            //        Item2 = new foo(),
            //    };

            //    object[] z = new object[0];
            //    // Error	1	Cannot implicitly convert type 'object[]' to 'TestGenericArray.Activities.foo[]'. An explicit conversion exists (are you missing a cast?)	Y:\jsc.svn\examples\java\android\Test\TestGenericArray\TestGenericArray\Program.cs	24	23	TestGenericArray
            //    // Unable to cast object of type 'System.Object[]' to type 'TestGenericArray.Activities.foo[]'.
            //    foo[] y = (foo[])/* recreate array? */(object)z;
            //    var a = x.ToArray();
            //}

            global::jsc.AndroidLauncher.Launch(
                typeof(TestGenericArray.Activities.ApplicationActivity)
                );
        }
Exemplo n.º 11
0
 public static int Main()
 {
     ArrayList
     list
     =
     new
     ArrayList
     ();
     Thread.SetData(dataslot,
     "ID is wibble");
     Environment.ExitCode
     =
     2;
     while(true)
     {
     foo
     instance
     =
     new
     foo();
     list.Add
     (new
     WeakReference(instance));
     }
     return
     1;
 }
Exemplo n.º 12
0
        public void DIContext_Inject_Test()
        {
            //arrange
            Mock <IDependencyHolder> mockDependencyHolder = new Mock <IDependencyHolder>();

            mockDependencyHolder.Setup(dh => dh.GetInstance(It.IsAny <object[]>())).Returns(new foo());

            Mock <IDependencyMap> mockDependencyMap = new Mock <IDependencyMap>();

            mockDependencyMap.Setup(dm => dm.PrimaryDependencyHolder).Returns(mockDependencyHolder.Object);

            Mock <IDIContainer> mockContainer = new Mock <IDIContainer>();

            mockContainer.Setup(c => c.ContainsDependency(It.IsAny <string>())).Returns(true);
            mockContainer.Setup(c => c.GetDependencyMap(It.IsAny <string>())).Returns(mockDependencyMap.Object);

            Mock <DIContext> mockDIContext = new Mock <DIContext>(typeof(Boot))
            {
                CallBase = true
            };

            mockDIContext.SetupGet(ctx => ctx.Container).Returns(mockContainer.Object);

            //act
            foo objFoo = mockDIContext.Object.Inject <foo>();

            //assert
            mockContainer.Verify(c => c.ContainsDependency(It.IsAny <string>()));
            mockContainer.Verify(c => c.GetDependencyMap(It.IsAny <string>()));
            mockDependencyMap.Verify(dm => dm.PrimaryDependencyHolder);
            mockDependencyHolder.Verify(dh => dh.GetInstance(It.IsAny <object[]>()));
            Assert.IsInstanceOfType(objFoo, typeof(foo));
            Assert.IsNotNull(objFoo);
        }
Exemplo n.º 13
0
    static void Main(string[] args)
    {
        System.IntPtr p;
        {
            GCHandle handle;
            Object   obj = new foo();
            handle = GCHandle.Alloc(obj);
            p      = GCHandle.ToIntPtr(handle);
            obj    = new Object();
        }

        for (int i = 0; i < 100; ++i)
        {
            GC.Collect();
            System.Threading.Thread.Sleep(0);
        }

        Console.WriteLine("Freeing");

        GCHandle.FromIntPtr(p).Free();

        for (int i = 0; i < 100; ++i)
        {
            GC.Collect();
            System.Threading.Thread.Sleep(0);
        }


        Console.WriteLine("End.");
    }
Exemplo n.º 14
0
        public void DIContext_InjectByName_Test()
        {
            //arrange
            Mock <IDependencyHolder> mockDependencyHolder = new Mock <IDependencyHolder>();

            mockDependencyHolder.Setup(dh => dh.GetInstance(It.IsAny <object[]>())).Returns(new foo());

            Mock <IDependencyMap> mockDependencyMap = new Mock <IDependencyMap>();

            mockDependencyMap.Setup(dm => dm.PrimaryDependencyHolder).Returns(mockDependencyHolder.Object);

            Mock <IDIContainer> mockContainer = new Mock <IDIContainer>();

            mockContainer.Setup(c => c.SearchDependency(It.IsAny <string>())).Returns(new List <IDependencyMap>()
            {
                mockDependencyMap.Object
            });

            Mock <DIContext> mockDIContext = new Mock <DIContext>(typeof(Boot))
            {
                CallBase = true
            };

            mockDIContext.SetupGet(ctx => ctx.Container).Returns(mockContainer.Object);

            //act
            foo afoo = mockDIContext.Object.InjectByName <foo>("foo");

            //assert
            Assert.IsInstanceOfType(afoo, typeof(foo));
        }
        public void StaticInstanceLifetimeManager_CreateOrGetInstance_Dont_Create_Test()
        {
            //arrage
            foo afoo = new foo()
            {
                strProp = "state"
            };

            Mock <InstanceFactory> mockFactory = new Mock <InstanceFactory>();
            Mock <StaticInstanceLifetimeManager> mockLifetimeManager = new Mock <StaticInstanceLifetimeManager>(It.IsAny <IDIContainer>(), typeof(foo))
            {
                CallBase = true
            };

            mockLifetimeManager.SetupGet(ltm => ltm.Factory).Returns(mockFactory.Object);
            mockLifetimeManager.SetupGet(ltm => ltm.Instance).Returns(afoo);

            //act
            foo anotherfoo = (foo)mockLifetimeManager.Object.CreateOrGetInstance(It.IsAny <Object[]>());

            //assert
            mockFactory.Verify(factory => factory.CreateInstance(typeof(foo), It.IsAny <Object[]>()), Times.Never());
            Assert.AreSame(afoo, anotherfoo);
            Assert.AreEqual(afoo.strProp, anotherfoo.strProp);
        }
Exemplo n.º 16
0
        public static void Main(string[] e)
        {
            {
            
                foo[] z = new foo[0];
                // Error	1	Cannot implicitly convert type 'object[]' to 'TestGenericArray.Activities.foo[]'. An explicit conversion exists (are you missing a cast?)	Y:\jsc.svn\examples\java\android\Test\TestGenericArray\TestGenericArray\Program.cs	24	23	TestGenericArray
                // Unable to cast object of type 'System.Object[]' to type 'TestGenericArray.Activities.foo[]'.
                object[] y = z;
            }

            //{
            //    var x = new __List<foo>
            //    {
            //        Item1 = new foo(),
            //        Item2 = new foo(),
            //    };

            //    object[] z = new object[0];
            //    // Error	1	Cannot implicitly convert type 'object[]' to 'TestGenericArray.Activities.foo[]'. An explicit conversion exists (are you missing a cast?)	Y:\jsc.svn\examples\java\android\Test\TestGenericArray\TestGenericArray\Program.cs	24	23	TestGenericArray
            //    // Unable to cast object of type 'System.Object[]' to type 'TestGenericArray.Activities.foo[]'.
            //    foo[] y = (foo[])/* recreate array? */(object)z;
            //    var a = x.ToArray();
            //}

            global::jsc.AndroidLauncher.Launch(
                 typeof(TestGenericArray.Activities.ApplicationActivity)
            );
        }
Exemplo n.º 17
0
    static void Main(string[] args)
    {
        foo f = new foo();

        MemoryLeak.ActivateLeak += o => f.bar();
        f.tryCleanup();
    }
Exemplo n.º 18
0
    public foo Clone()        //Cloning is creating a new reference type with same values as old object
    {
        foo newc = new foo();

        newc.Bar = this.Bar;
        return(newc);
    }
Exemplo n.º 19
0
        //反序列化 方法1 定義強型別物件接收資料
        private void Func_1()
        {
            foo f = JsonConvert.DeserializeObject <foo>(jsonSrc);

            Response.Write(string.Format("d:{0}, n:{1}, s:{2}, a:{3}", f.d, f.n, f.s,
                                         string.Join("/", f.a)));
        }
Exemplo n.º 20
0
    public static void Main()
    {
        foo foo1 = getfoo();
        foo foo2 = getfoo();

//        System.Console.WriteLine(foo1==foo2);
        System.Console.WriteLine(foo1.Equals(foo2));
    }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            var f1 = new foo();
            var f2 = new doublefoo();

            someMethod(f1);
            someMethod(f2);
        }
Exemplo n.º 22
0
    static foo getfoo()
    {
        foo foo1 = new foo();

        foo1.x = 10;
        foo1.y = "foo";
        return(foo1);
    }
Exemplo n.º 23
0
    static void Main()
    {
        foo f = new foo();

        f.MyMemory = new System.IO.MemoryStream();

        f.Write("information");
    }
Exemplo n.º 24
0
        public void ParsePlain()
        {
            foo f = EnumParser.Parse <foo>("bar");

            Assert.AreEqual(foo.bar, f);
            f = EnumParser.Parse <foo>("blah");
            Assert.AreEqual(foo.NONE, f);
        }
Exemplo n.º 25
0
    public void test()
    {
        foo <int, int> a = new foo <int, int>();

        a.parse("123", "456");
        string   b = m_DateTime.ToString();
        string   c = s_DateTime.ToString();
        DateTime dt, dt2;
    }
Exemplo n.º 26
0
    private void doEvent(object sender, PropertyChangedEventArgs e)
    {
        foo updated = sender as foo;

        if (object.ReferenceEquals(e.PropertyName, "changed int"))
        {
            ShowWhatChanged(updated.bar);     //show on GUI
        }
    }
Exemplo n.º 27
0
 static void Main(string[] args)
 {
     var b = new BaseClass();
     var d = new DerivedClass();
     var f = new foo(d);
     //prints Derived Constructor
     var e = new foo(b);
     //prints Base Constructor
 }
 public static void Main()
 {
     ArrayList list = new ArrayList ();
     Thread.SetData(dataslot, "ID is wibble");
     while(true) {
         foo instance = new foo();
         list.Add (new WeakReference(instance));
     }
 }
Exemplo n.º 29
0
 public void ObjectComare()
 {
     var f1   = new foo();
     var f2   = new foo();
     var f3   = f2;
     var res1 = f1 == f2;
     var res2 = f1.Equals(f2);
     var res3 = f2.Equals(f3);
 }
    public static void DoSomeWork(foo item, List <bar> bList)
    {
        var query = bList.Where(x => x.prop1 == item.A && x.prop2 == item.B)
                    .ToList();

        if (query.Any())
        {
            DoSomethingElse();
        }
    }
        public void CurrentNamespace_Class_Injection_IntgTests()
        {
            //arrange
            diCtx.Scan();

            //act
            foo objfoo = diCtx.Inject <foo>();

            //assert
            Assert.IsInstanceOfType(objfoo, typeof(foo));
        }
Exemplo n.º 32
0
    static int Main()
    {
        int returnVal = 100;
        foo myFoo     = getfoo();

        if (myFoo.b1 != 0 || myFoo.b2 != 0 || myFoo.b3 != 0 || myFoo.b4 != 0)
        {
            returnVal = -1;
        }
        return(returnVal);
    }
Exemplo n.º 33
0
        public void Null()
        {
            string s = EnumParser.ToString(foo.NONE);

            Assert.IsNull(s);
            foo f = EnumParser.Parse <foo>("");

            Assert.AreEqual(foo.NONE, f);
            bar b = EnumParser.Parse <bar>("");

            Assert.AreEqual(bar.goo, b);
        }
Exemplo n.º 34
0
    private static int Main()
    {

        foo f = new foo();
        f.x = f.y = 1;
        Console.WriteLine(f.x + f.y);

        Console.WriteLine(BitConverter.Int64BitsToDouble(unchecked((long)0x8000000000000000UL)));

        Console.WriteLine("PASS!");
        return 100;
    }
Exemplo n.º 35
0
        //序列化 方法1 使用強型別
        private void Func_4()
        {
            foo f = new foo()
            {
                d = new DateTime(2015, 1, 1),
                n = 32767,
                s = "darkthread",
                a = new int[] { 1, 2, 3, 4, 5 }
            };

            Response.Write(string.Format("JSON:{0}", JsonConvert.SerializeObject(f)));
        }
Exemplo n.º 36
0
        public static void Main(string[] args)
        {
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201409/20140908

            // jsc needs to see args to make Main into main for javac..


            // see also>
            // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs

            System.Console.WriteLine(
               typeof(object).AssemblyQualifiedName
            );

            var f = new foo();
            xKey x = f;
            zKey z = f;


            CLRProgram.CLRMain();
        }
Exemplo n.º 37
0
 static void Invoke(ref foo f, foo value)
 {
     f = value;
 }
Exemplo n.º 38
0
        static void ThreadFunc()
        {
            string masterBedroom = "uuid:RINCON_000E5810848C01400";
            ZonePlayer zonePlayer = new ZonePlayer(masterBedroom);
            Console.WriteLine(zonePlayer.DeviceProperties.Icon);
            //UPnPDevice mediaServer = zonePlayer.MediaServer;
            //UPnPDevice mediaRenderer = zonePlayer.MediaRenderer;
            //AudioIn audioIn = zonePlayer.AudioIn;
            DeviceProperties deviceProperties = zonePlayer.DeviceProperties;
            RenderingControl renderingControl = zonePlayer.RenderingControl;
            AVTransport avTransport = zonePlayer.AVTransport;
            ContentDirectory contentDirectory = zonePlayer.ContentDirectory;
            GroupManagement groupManagement = zonePlayer.GroupManagement;
            //ZoneGroupTopology zoneGroupTopology = zonePlayer.ZoneGroupTopology;
            //ConnectionManager connectionManager = zonePlayer.ConnectionManager;

            foreach (XPathNavigator node in contentDirectory.Browse("0", BrowseFlags.BrowseDirectChildren, "*", ""))
            {
                Console.WriteLine(node.OuterXml);

            #if FOO
                string path = HttpUtility.UrlDecode(node.SelectSingleNode("@id", Sonority.XPath.Globals.Manager).Value);
                path = path.Replace(@"S://", @"\\");
                path = path.Replace('/', '\\');
                string destination = Path.Combine(@"c:\temp\nuevo", Path.GetFileName(path));
                Console.WriteLine("{0}", path);

                File.Copy(path, destination);
            #endif
            }

            foreach (QueueItem node in zonePlayer.Queue)
            {
                Console.WriteLine(node);
            }
            zonePlayer.Queue.ToString();

            avTransport.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
            contentDirectory.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
            renderingControl.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            #if FOO
            using (foo bar = new foo())
            {
                // check updateIDs first
                Queue<string> queue = new Queue<string>();
                queue.Enqueue("S:");
                queue.Enqueue("0");

                while (queue.Count > 0)
                {
                    string currentObject = queue.Dequeue();
                    // box is down, ignore for now.
                    if (currentObject.StartsWith("S://13CFB6DD7F03432", StringComparison.OrdinalIgnoreCase))
                        continue;

                    foreach (XPathNavigator node in contentDirectory.Browse(currentObject, BrowseFlags.BrowseDirectChildren, "*", ""))
                    {
                        if (node.LocalName == "container")
                        {
                            // recurse into container
                            queue.Enqueue(node.SelectSingleNode("@id").Value);
                        }

                        bar.AddRecord(
                            node.SelectSingleNode("@id", XPath.Globals.Manager).Value,
                            node.SelectSingleNode("@parentID", XPath.Globals.Manager).Value,
                            0,
                            node);
                    }
                }
            }

            Thread.Sleep(Timeout.Infinite);

            Console.WriteLine(contentDirectory.ToString());
            Console.WriteLine(avTransport.ToString());

            // avTransport.Play("1");
            #endif

            while (true)
            {
                Thread.Sleep(30000);

                foreach (ZoneGroup zp in disc.Topology)
                {
                    Console.WriteLine("{0} -> {1}", zp.Coordinator.UniqueDeviceName, zp.Coordinator.DeviceProperties.ZoneName);
                }
            }
        }
Exemplo n.º 39
0
        void drawObject(WebGLRenderingContext gl, foo shader, bar @object)
        {
            gl.useProgram(shader.program);

            gl.bindBuffer(gl.ARRAY_BUFFER, @object.vertex_buffer);
            gl.vertexAttribPointer((uint)shader.aVertexPosition, 3, gl.FLOAT, false, 0, 0);

            gl.bindBuffer(gl.ARRAY_BUFFER, @object.texturecoord_buffer);
            gl.vertexAttribPointer((uint)shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);

            gl.activeTexture(gl.TEXTURE0);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture1"]);
            gl.uniform1i(shader.u["uSamplerDiffuse1"], 0);

            gl.activeTexture(gl.TEXTURE1);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture2"]);
            gl.uniform1i(shader.u["uSamplerDiffuse2"], 1);

            gl.activeTexture(gl.TEXTURE2);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture3"]);
            gl.uniform1i(shader.u["uSamplerDiffuse3"], 2);

            gl.activeTexture(gl.TEXTURE3);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture4"]);
            gl.uniform1i(shader.u["uSamplerDiffuse4"], 3);

            gl.activeTexture(gl.TEXTURE4);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture5"]);
            gl.uniform1i(shader.u["uSamplerDiffuse5"], 4);

            gl.activeTexture(gl.TEXTURE5);
            gl.bindTexture(gl.TEXTURE_2D, @object.t["texture6"]);
            gl.uniform1i(shader.u["uSamplerDiffuse6"], 5);

            gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, @object.index_buffer);

            gl.uniformMatrix4fv(shader.u["uProjectionMatrix"], false, shader.PROJECTION_MATRIX);
            gl.uniformMatrix4fv(shader.u["uModelViewMatrix"], false, shader.MV_MATRIX);

            gl.drawElements(gl.TRIANGLES, @object.n_elements, gl.UNSIGNED_SHORT, 0);
        }
Exemplo n.º 40
0
 void renderFrame(WebGLRenderingContext gl, foo shader, bar @object)
 {
     gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
     gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
     drawObject(gl, shader, @object);
 }
Exemplo n.º 41
0
        private void Initialize(IHTMLCanvas c, WebGLRenderingContext gl, IDefault  page)
        {
            // http://cs.helsinki.fi/u/ilmarihe/metatunnel.html
            // http://wakaba.c3.cx/w/puls.html

            Action<string> alert = Native.window.alert;

            c.style.border = "1px solid yellow";

            page.MaxTextures.innerText = "" + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);

            // https://www.khronos.org/webgl/public-mailing-list/archives/1007/msg00034.html

            var vs = "";

            vs += "precision highp float; \n";
            vs += "attribute vec3 aVertexPosition;";
            vs += "attribute vec2 aTextureCoord;";
            vs += "uniform mat4 uModelViewMatrix;";
            vs += "uniform mat4 uProjectionMatrix;";
            vs += "varying vec2 vTextureCoord;";
            vs += "void main(void) {";
            vs += "gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);";
            vs += "vTextureCoord = vec2(aTextureCoord.x, 1.0 - aTextureCoord.y);";
            vs += "}";

           var fs = "";
            
            fs += "precision highp float; \n";
            fs += "varying vec2 vTextureCoord;";
            fs += "uniform sampler2D uSamplerDiffuse1;";
            fs += "uniform sampler2D uSamplerDiffuse2;";
            fs += "uniform sampler2D uSamplerDiffuse3;";
            fs += "uniform sampler2D uSamplerDiffuse4;";
            fs += "uniform sampler2D uSamplerDiffuse5;";
            fs += "uniform sampler2D uSamplerDiffuse6;";
            fs += "void main(void) {";
            fs += "gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * texture2D(uSamplerDiffuse1, vTextureCoord)";
            fs += "+ vec4(0.0, 1.0, 0.0, 1.0) * texture2D(uSamplerDiffuse2, vTextureCoord)";
            fs += "+ vec4(0.0, 0.0, 1.0, 1.0) * texture2D(uSamplerDiffuse3, vTextureCoord)";
            fs += "+ vec4(0.0, 1.0, 1.0, 1.0) * texture2D(uSamplerDiffuse4, vTextureCoord)";
            fs += "+ vec4(1.0, 0.0, 1.0, 1.0) * texture2D(uSamplerDiffuse5, vTextureCoord)";
            fs += "+ vec4(1.0, 1.0, 0.0, 1.0) * texture2D(uSamplerDiffuse6, vTextureCoord);";
            fs += "}";


            var xfs = gl.createShader(gl.FRAGMENT_SHADER);
            gl.shaderSource(xfs, fs);
            gl.compileShader(xfs);
            if ((int)gl.getShaderParameter(xfs, gl.COMPILE_STATUS) != 1)
            {
                // vs: ERROR: 0:2: '' : Version number not supported by ESSL 
                // fs: ERROR: 0:1: '' : No precision specified for (float) 

                var error = gl.getShaderInfoLog(xfs);
                Native.window.alert("fs: " + error);
                return;
            }

            var xvs = gl.createShader(gl.VERTEX_SHADER);
            gl.shaderSource(xvs, vs);
            gl.compileShader(xvs);
            if ((int)gl.getShaderParameter(xvs, gl.COMPILE_STATUS) != 1)
            {
                // vs: ERROR: 0:2: '' : Version number not supported by ESSL 
                // vs: ERROR: 0:10: '-' :  wrong operand types  no operation '-' exists that takes a left-hand operand of type 'const mediump int' and a right operand of type 'float' (or there is no acceptable conversion)


                var error = gl.getShaderInfoLog(xvs);
                Native.window.alert("vs: " + error);
                return;
            }

            var shader = new foo();

            shader.program = gl.createProgram();
            gl.attachShader(shader.program, xvs);
            gl.attachShader(shader.program, xfs);
            gl.linkProgram(shader.program);

            var linked = gl.getProgramParameter(shader.program, gl.LINK_STATUS);
            if (linked == null)
            {
                var error = gl.getProgramInfoLog(shader.program);
                Native.window.alert("Error while linking: " + error);
                return;
            }

            gl.useProgram(shader.program);
            shader.aVertexPosition = gl.getAttribLocation(shader.program, "aVertexPosition");
            shader.aTextureCoord = gl.getAttribLocation(shader.program, "aTextureCoord");
            gl.enableVertexAttribArray((uint)shader.aVertexPosition);
            gl.enableVertexAttribArray((uint)shader.aTextureCoord);

            shader.u["uModelViewMatrix"] = gl.getUniformLocation(shader.program, "uModelViewMatrix");
            shader.u["uProjectionMatrix"] = gl.getUniformLocation(shader.program, "uProjectionMatrix");

            shader.u["uSamplerDiffuse1"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse1");
            shader.u["uSamplerDiffuse2"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse2");
            shader.u["uSamplerDiffuse3"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse3");
            shader.u["uSamplerDiffuse4"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse4");
            shader.u["uSamplerDiffuse5"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse5");
            shader.u["uSamplerDiffuse6"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse6");

            shader.MV_MATRIX = new float[] { 
                1.0f, 0.0f, 0.0f, 0.0f,
                0.0f, 1.0f, 0.0f, 0.0f,
                0.0f, 0.0f, 1.0f, 0.0f,
                0.0f, 0.0f, 0.0f, 1.0f };


            shader.PROJECTION_MATRIX = new float[] { 
                                1.000f, 0.000f, 0.000f, 0.000f,
                                0.000f, 1.000f, 0.000f, 0.000f,
                                0.000f, 0.000f, 0.002f, 0.000f,
                                0.000f, 0.000f, 0.998f, 1.000f };

            var bar = default(bar);

            bar = initObject(
                gl,
                delegate
                {
                    if (bar == null)
                        return;

                    renderFrame(gl, shader, bar);

                    c.style.border = "2px solid green";
                }
            );



        }
Exemplo n.º 42
0
 public Boolean runTest()
   {
   int iCountTestcases = 0;
   int iCountErrors    = 0;
   iCountTestcases++;
   try {
   foo f = new foo();
   Delegate cdel = Delegate.CreateDelegate(Type.GetType("DelA"), f, "bar");
   Object ret = ((DelA) cdel).DynamicInvoke(null);
   if (17 != (int) ret)
     throw new Exception("Wrong return value from delegate");
   }
   catch (Exception ex) {
   ++iCountErrors;
   Console.WriteLine("Err_001a,  Unexpected exception was thrown ex: " + ex.ToString());
   }
   iCountTestcases++;
   try {
   MethodInfo mi = Type.GetType("foo").GetMethod("barprime");
   Delegate cdel = Delegate.CreateDelegate(Type.GetType("DelB"), mi);
   Object[] objs = new Object[1];
   objs[0] = 18;
   Object ret = ((DelB) cdel).DynamicInvoke(objs);
   if (18 != (int) ret)
     throw new Exception("Wrong return value from delegate");	 
   }
   catch (Exception ex) {
   ++iCountErrors;
   Console.WriteLine("Err_002a,  Unexpected exception was thrown ex: " + ex.ToString());
   }
   iCountTestcases++;
   try {
   MethodInfo methInfo = Type.GetType("foo").GetMethod("bar");
   Delegate cdel = Delegate.CreateDelegate(Type.GetType("DelA"), methInfo);
   throw new Exception("Yehx003abc: previous call should have thrown an exception");	    
   }
   catch (System.ArgumentException) {
   if (verbose) {
   Console.WriteLine ("YehExpected000a : Expected exception");
   }
   }
   catch (Exception ex) {
   ++iCountErrors;
   Console.WriteLine("Err_003a,  Unexpected exception was thrown ex: " + ex.ToString());
   }
   iCountTestcases++;
   try {
   foo f = new foo();
   Delegate cdel = Delegate.CreateDelegate(Type.GetType(null), f, "bar");
   throw new Exception("Yehx004abc: previous call should have thrown an exception");	    
   }
   catch (System.ArgumentException) {
   if (verbose){
   Console.WriteLine ("YehExpected000b : Expected exception");
   }
   }
   catch (Exception ex) {
   ++iCountErrors;
   Console.WriteLine("Err_004a,  Unexpected exception was thrown ex: " + ex.ToString());
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("objDelegate"), "meth");
   if (verbose) {
   Object[] objs = new Object[1];
   objs[0] = (String)"Using CreateDelegate(Type, Type, String) correctly";
   staticDelegate.DynamicInvoke (objs);
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_005,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("objDelegate"), "");
   throw new Exception("Yehx001: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected001 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_006,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType(""), "meth");
   throw new Exception("Yehx002: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected002 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_007,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType(""), Type.GetType("objDelegate"), "meth");
   throw new Exception("Yehx003: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected003 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_008,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("objDelegate"), Type.GetType("objDelegate"), "meth");
   throw new Exception("Yehx004: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected004 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_009,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("objDelegate"), "objDelegate");
   throw new Exception("Yehx005: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected005 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_010,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("foo"), "barprime");
   throw new Exception("Yehx006: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected006 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_011,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   MethodInfo methInfo = Type.GetType("objDelegate").GetMethod("meth");
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), methInfo);
   if (verbose) {
   Object[] objs = new Object[1];
   objs[0] = (String)"Running staticDelegate.DynamicInvoke after CreateDelegate (Type, MethodInfo) with correct parameters";
   staticDelegate.DynamicInvoke (objs);
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_012,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), null);
   throw new Exception("Yehx007: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected007 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_013,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   MethodInfo methInfo = Type.GetType("objDelegate").GetMethod("meth");
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType(""), methInfo);
   throw new Exception("Yehx008: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected008 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_014,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   MethodInfo methInfo = Type.GetType("objDelegate").GetMethod("meth");
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("objDelegate"), methInfo);
   throw new Exception("Yehx009: previous call should have thrown an exception");
   }
   catch (System.ArgumentException){
   if (verbose) {
   Console.WriteLine ("YehExpected009 : Expected exception");
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_015,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate instanceDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), instanceDelInst, "meth");
   throw new Exception("Yehx010: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected010 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_016,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate stDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("objDelegate"), "instmeth");
   throw new Exception("Yehx011: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected011 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_017,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), instanceDelInst, "instmeth");
   if (verbose) {
   Object[] objs = new Object[1];
   objs[0] = (String)"Using CreateDelegate(Type, Object, String) correctly";
   staticDelegate.DynamicInvoke (objs);
   }
   }
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_018,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate instanceDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), null, "instmeth");
   throw new Exception("Yehx012: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected012 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_019,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   foo f=new foo();			
   Delegate instanceDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), f, "instmeth");
   throw new Exception("Yehx013: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected013 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_020,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("vvDelegate"), Type.GetType("tryProps"), "strFoo");
   throw new Exception("Yehx016: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected016 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_022,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(null, Type.GetType("objDelegate"), "meth");
   throw new Exception("Yehx016: previous call should have thrown an exception");		
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected016 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_022b,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), null, "meth");
   throw new Exception("Yehx017: previous call should have thrown an exception");		
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected017 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_022,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("staticDelegate"), Type.GetType("objDelegate"), null);
   throw new Exception("Yehx018: previous call should have thrown an exception");		
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected018 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_023,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   MethodInfo methInfo = Type.GetType("objDelegate").GetMethod("meth");
   Delegate staticDelegate = Delegate.CreateDelegate(null, methInfo);
   throw new Exception("Yehx019: previous call should have thrown an exception");		
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected019 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_024,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(null, instanceDelInst, "instmeth");
   throw new Exception("Yehx021: previous call should have thrown an exception");				
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected021 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_026,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), null, "instmeth");
   throw new Exception("Yehx022: previous call should have thrown an exception");				
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected022 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_027,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), instanceDelInst, null);
   throw new Exception("Yehx022: previous call should have thrown an exception");				
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected022 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_027,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType(""), instanceDelInst, "instmeth");
   throw new Exception("Yehx023: previous call should have thrown an exception");				
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected023 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_028,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   objDelegate instanceDelInst= new objDelegate();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("instDelegate"), instanceDelInst, "");
   throw new Exception("Yehx023: previous call should have thrown an exception");				
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected023 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_028,  Unexpected: " + exc.ToString() );
   }
   iCountTestcases++;
   try {
   tryProps instancetryProps= new tryProps();
   Delegate staticDelegate = Delegate.CreateDelegate(Type.GetType("retStrDelegate"), instancetryProps, "strFoo");
   throw new Exception("Yehx024: previous call should have thrown an exception");
   }
   catch (System.ArgumentException)
     {
     if (verbose) {
     Console.WriteLine ("YehExpected024 : Expected exception");
     }
     }	
   catch (Exception exc){
   ++iCountErrors;
   Console.WriteLine( "YehErr_029,  Unexpected: " + exc.ToString() );
   }
   if ( iCountErrors == 0 ) {   return true; }
   else {  return false;}
   }