예제 #1
0
        private ComponentRegistry RegistryWithUnsafeAPI()
        {
            ComponentRegistry allComponents = new ComponentRegistry();

            allComponents.Register(typeof(UnsafeAPI), ctx => new UnsafeAPI());
            return(allComponents);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            ComponentRegistry safeComponents = new ComponentRegistry();
            ComponentRegistry allComponents  = new ComponentRegistry();

            safeComponents.Register(typeof(MyAwesomeAPI), ctx => new MyAwesomeAPI());
            allComponents.Register(typeof(MyAwesomeAPI), ctx => new MyAwesomeAPI());
            allComponents.Register(typeof(MyUnsafeAPI), ctx => new MyUnsafeAPI());

            _compiler = new ReflectiveProcedureCompiler(new TypeMappers(), safeComponents, allComponents, _log, ProcedureConfig.Default);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void syntheticsAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SyntheticsAllowed()
        {
            // Given
            ComponentRegistry components = new ComponentRegistry();

            components.Register(typeof(int), ctx => 1337);
            FieldInjections injections = new FieldInjections(components);

            // When
            IList <FieldInjections.FieldSetter> setters = injections.Setters(typeof(Outer.ClassWithSyntheticField));

            // Then
            Outer.ClassWithSyntheticField syntheticField = (new Outer()).ClassWithSyntheticField();
            foreach (FieldInjections.FieldSetter setter in setters)
            {
                setter.Apply(null, syntheticField);
            }

            assertEquals(1337, syntheticField.InnerField);
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void inheritanceIsAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void InheritanceIsAllowed()
        {
            // Given
            ComponentRegistry components = new ComponentRegistry();

            components.Register(typeof(int), ctx => 1337);
            FieldInjections injections = new FieldInjections(components);

            // When
            IList <FieldInjections.FieldSetter> setters = injections.Setters(typeof(ChildProcedure));

            // Then
            ChildProcedure childProcedure = new ChildProcedure();

            foreach (FieldInjections.FieldSetter setter in setters)
            {
                setter.Apply(null, childProcedure);
            }

            assertEquals(1337, childProcedure.ChildField);
            assertEquals(1337, childProcedure.ParentField);
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _components        = new ComponentRegistry();
            _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, NullLog.Instance, ProcedureConfig.Default);
        }
예제 #6
0
 internal FieldInjections(ComponentRegistry components)
 {
     this._components = components;
 }