Exemplo n.º 1
0
        public void Initialize(IObjectFactory factory)
        {
            if (!LogCommands)
            {
                return;
            }
            var aspectRegistrator = factory.Resolve <IAspectRegistrator>();

            var processingInterceptor = new ProcessingCommandsIntercepter();
            var tpe = typeof(IProcessingEngine);

            aspectRegistrator.Before(
                tpe,
                tpe.GetMethod("Execute"),
                (e, args) => processingInterceptor.LogCommands((dynamic)(args[0])));
#if !NETSTANDARD2_0
            var restInterceptor = new RestCommandsIntercepter();
            var tcc             = typeof(ICommandConverter);
            var tre             = typeof(IRestApplication);
            aspectRegistrator.Around(
                tcc,
                tcc.GetMethod("PassThrough"),
                (e, args, baseCall) => restInterceptor.PassThrough(args, baseCall));
            aspectRegistrator.Around <IRestApplication, Stream>(
                r => r.Get(),
                restInterceptor.Get);
            aspectRegistrator.Around <IRestApplication, Stream, Stream>(
                r => r.Post(null),
                (_, s, bc) => restInterceptor.Post(s, bc));
#endif
        }
Exemplo n.º 2
0
		public void Initialize(IObjectFactory factory)
		{
			if (!LogCommands)
				return;

			var processingInterceptor = new ProcessingCommandsIntercepter();
			var restInterceptor = new RestCommandsIntercepter();
			var aspectRegistrator = factory.Resolve<IAspectRegistrator>();

			var tpe = typeof(IProcessingEngine);
			var tcc = typeof(ICommandConverter);
			var tre = typeof(IRestApplication);
			aspectRegistrator.Before(
				tpe,
				tpe.GetMethod("Execute"),
				(e, args) => processingInterceptor.LogCommands((dynamic)(args[0])));
			aspectRegistrator.Around(
				tcc,
				tcc.GetMethod("PassThrough"),
				(e, args, baseCall) => restInterceptor.PassThrough(args, baseCall));
			aspectRegistrator.Around<IRestApplication, Stream>(
				r => r.Get(),
				restInterceptor.Get);
			aspectRegistrator.Around<IRestApplication, Stream, Stream>(
				r => r.Post(null),
				(_, s, bc) => restInterceptor.Post(s, bc));
		}