Ejemplo n.º 1
0
 /// <summary>
 /// Registers a component, these become available in reflective procedures for injection. </summary>
 /// <param name="cls"> the type of component to be registered (this is what users 'ask' for in their field declaration) </param>
 /// <param name="provider"> a function that supplies the component, given the context of a procedure invocation </param>
 /// <param name="safe"> set to false if this component can bypass security, true if it respects security </param>
 public virtual void RegisterComponent <T>(Type cls, ComponentRegistry.Provider <T> provider, bool safe)
 {
     cls = typeof(T);
     if (safe)
     {
         _safeComponents.register(cls, provider);
     }
     _allComponents.register(cls, provider);
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInjectLogging() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInjectLogging()
        {
            // Given
            Log log = spy(typeof(Log));

            _components.register(typeof(Log), ctx => log);
            CallableUserFunction function = _procedureCompiler.compileFunction(typeof(LoggingFunction))[0];

            // When
            function.Apply(new BasicContext(), new AnyValue[0]);

            // Then
            verify(log).debug("1");
            verify(log).info("2");
            verify(log).warn("3");
            verify(log).error("4");
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInjectLogging() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInjectLogging()
        {
            // Given
            Log log = spy(typeof(Log));

            _components.register(typeof(Log), ctx => log);
            CallableUserAggregationFunction function = _procedureCompiler.compileAggregationFunction(typeof(LoggingFunction))[0];

            // When
            UserAggregator aggregator = function.Create(new BasicContext());

            aggregator.Update(new object[] {});
            aggregator.Result();

            // Then
            verify(log).debug("1");
            verify(log).info("2");
            verify(log).warn("3");
            verify(log).error("4");
        }