コード例 #1
0
        public void AppendInstanceComplexGetterTest()
        {
            Type          target  = typeof(TestType1);
            DotNetEmitter emitter = new DotNetEmitter(target);

            string expected =
                "public async Task<object> Get_Child(object _referenceId)" +
                Environment.NewLine +
                "{" + Environment.NewLine +
                "    long _refId = _referenceId is long ? (long)_referenceId : (long)(int)_referenceId;" +
                Environment.NewLine + Environment.NewLine +
                "    DotNetTest.TestType1 _parent = " +
                "(DotNetTest.TestType1)" +
                "ReferenceManager.Instance.PullReference(_refId);" +
                Environment.NewLine +
                "    DotNetTest.TestType2 _result = _parent.Child;" +
                Environment.NewLine +
                "    return ReferenceManager.Instance.EnsureReference(_result);" +
                Environment.NewLine +
                "}" + Environment.NewLine;

            PropertyInfo info = target.GetProperty("Child");

            emitter.AppendGetter(info, false);

            Assert.AreEqual(
                expected,
                emitter.ToString());
        }
コード例 #2
0
        public void AppendInstanceSimpleSetterTest()
        {
            Type          target  = typeof(TestType1);
            DotNetEmitter emitter = new DotNetEmitter(target);

            string expected =
                "public async Task Set_Name(dynamic parameters)" +
                Environment.NewLine +
                "{" + Environment.NewLine +
                "    long _refId = parameters._referenceId is long ? (long)parameters._referenceId : (long)(int)parameters._referenceId;" +
                Environment.NewLine + Environment.NewLine +
                "    DotNetTest.TestType1 _parent = " +
                "(DotNetTest.TestType1)" +
                "ReferenceManager.Instance.PullReference(_refId);" +
                Environment.NewLine +
                "    _parent.Name = parameters.value;" +
                Environment.NewLine +
                "}" + Environment.NewLine;

            PropertyInfo info = target.GetProperty("Name");

            emitter.AppendSetter(info, false);

            Assert.AreEqual(
                expected,
                emitter.ToString());
        }
コード例 #3
0
        public void AppendClassEndTest()
        {
            string expected = "}" + Environment.NewLine;

            DotNetEmitter emitter = new DotNetEmitter(typeof(TestType1));

            // Make sure the indent will be removed before appending.
            emitter.Indent();
            emitter.AppendClassEnd();

            Assert.AreEqual(expected, emitter.ToString());
        }
コード例 #4
0
        public void AppendClassStartTest()
        {
            string expected =
                "public class TestType1Proxy" +
                Environment.NewLine +
                "{" +
                Environment.NewLine;

            DotNetEmitter emitter = new DotNetEmitter(typeof(TestType1));

            emitter.AppendClassStart();

            Assert.AreEqual(expected, emitter.ToString());
        }
コード例 #5
0
        public void AppendStaticSimpleGetterTest()
        {
            Type          target  = typeof(TestType1);
            DotNetEmitter emitter = new DotNetEmitter(target);

            string expected =
                "public async Task<object> Get_SharedData(object unused)" +
                Environment.NewLine +
                "{" + Environment.NewLine +
                "    System.String _result = DotNetTest.TestType1.SharedData;" +
                Environment.NewLine +
                "    return _result;" + Environment.NewLine +
                "}" + Environment.NewLine;

            PropertyInfo info = target.GetProperty("SharedData");

            emitter.AppendGetter(info, true);

            Assert.AreEqual(
                expected,
                emitter.ToString());
        }