コード例 #1
0
        //[TestMethod]
        public void LinkedMethodsReturnValueTest7()
        {
            CustomImplementation          implementation = new CustomImplementation();
            TypeDefinition <ITestMethods> typeDefinition = TypeDefinition <ITestMethods> .Create(FieldDefinition
                                                                                                 .CreateFromConstructorParameter <BoolContainer>()
                                                                                                 .ImportInMain(),
                                                                                                 LinkedMethodsReturnValue.Create <ITestMethods>(nameof(ITestMethods.OutAndRef))
                                                                                                 .MappedMethod(implementation, nameof(CustomImplementation.OutAndRef)));

            BoolContainer boolContainer  = new BoolContainer();
            ITestMethods  instance       = typeDefinition.CreateNew(boolContainer);
            BoolContainer boolContainer2 = new BoolContainer();

            typeDefinition.CreateNew(boolContainer2);
            string text2 = "wetwt";

            instance.OutAndRef(out string _, ref text2, 5);
            Assert.IsTrue(boolContainer.Value);
            Assert.IsFalse(boolContainer2.Value);
        }
コード例 #2
0
        public void LinkedMethodsReturnValueTest7()
        {
            CustomImplentation            implementation = new CustomImplentation();
            ConstructorParameter          parameter      = ConstructorParameter.Create <BoolContainer>("container");
            TypeDefinition <ITestMethods> typeDefinition = new TypeDefinition <ITestMethods>(
                parameter,
                new LinkedMethodsReturnValue(nameof(ITestMethods.OutAndRef))
                .MappedMethod(implementation, nameof(CustomImplentation.OutAndRef))
                .Action <BoolContainer>(container => container.Value = true, parameter));
            BoolContainer boolContainer  = new BoolContainer();
            ITestMethods  instance       = typeDefinition.Create(boolContainer);
            BoolContainer boolContainer2 = new BoolContainer();

            typeDefinition.Create(boolContainer2);
            string text2 = "wetwt";

            instance.OutAndRef(out string _, ref text2, 5);
            Assert.IsTrue(boolContainer.Value);
            Assert.IsFalse(boolContainer2.Value);
        }