Beispiel #1
0
        public JsonResult LoadAllPlugins()
        {
            string fullname = "MicroServices.Alipay.Plugins.AlipayPlugin, MicroServices.Alipay.Plugins";
            var    type     = Type.GetType(fullname);

            if (type == null)
            {
                var typeFinder = EngineContext.Resolve <ITypeFinder>();
                type = typeFinder.FindClassesOfType(typeof(IPlugin)).FirstOrDefault(e => e.FullName.Equals(fullname));

                if (type == null)
                {
                    return(Json(false));
                }
            }

            IPlugin plugin = null;

            if (!EngineContext.TryResolve(type, out object instance))
            {
                instance = EngineContext.BeginLifetimeScope().ResolveUnregistered(type);
            }

            plugin = instance as IPlugin;
            if (plugin == null)
            {
                return(Json(false));
            }

            var executedResult = plugin.Execute();

            return(Json(executedResult));
        }
Beispiel #2
0
        static void Loop()
        {
            Parallel.For(1, 100, i =>
            {
                using (var scope = EngineContext.BeginLifetimeScope())
                {
                    var result = EngineContext.Resolve <UserProcessor>().Add();
                    Console.WriteLine(result);

                    var result2 = EngineContext.Resolve <UserProcessor>().Search();
                    Console.WriteLine(result2);
                }
            });
        }