static void Main(string[] args) { IocContainerContext.Create().UserAutofac().UseDapper().BuildContainer(); string connectString = "Data Source=101.200.33.140;Initial Catalog=bslm;Persist Security Info=True;User ID=bslm;Password=bslm123!@#;MultipleActiveResultSets=True;Integrated Security=false"; IDbConnection connection = new SqlConnection(connectString); DynamicParameters dp = new DynamicParameters(); dp.Add("masterType", "LV_SysMenus", DbType.String); //var items = SqlDapperExtensions.QuereyProcedure<LabelValue>(connection, dp, "usp_lv"); dapper = IocContainerInvoker.Resolve <IDapper>(); int count = dapper.GetCount(connection, null, "Sys_User"); Console.WriteLine(count.ToString()); Console.ReadKey(); //foreach (var i in items) //{ // Console.WriteLine(i.ToString()); //} }
static void Main(string[] args) { IocContainerContext .Create() .UserAutofac() .UseLog4Net() .UseRepository() .UseDapper() .BuildContainer(); _logger = IocContainerInvoker.Resolve <ILoggerFactory>().Create(typeof(Program).Name); _logger.Debug("This is a Debug message."); }
/// <summary>Use Log4Net as the logger. /// </summary> /// <returns></returns> public static IocContainerContext UseLog4Net(this IocContainerContext configuration) { return(UseLog4Net(configuration, "log4net.config")); }
/// <summary>Use Log4Net as the logger. /// </summary> /// <returns></returns> public static IocContainerContext UseLog4Net(this IocContainerContext configuration, string configFile, string loggerRepository = "NetStandardRepository") { configuration.Register <ILoggerFactory, Log4NetLoggerFactory>(new Log4NetLoggerFactory(configFile, loggerRepository)); return(configuration); }
public static IocContainerContext UserAutofac(this IocContainerContext iocContainerContext, ContainerBuilder containerBuilder) { IocContainerInvoker.SetContainer(new AutofacObjectContainer(containerBuilder)); return(iocContainerContext); }
public static IocContainerContext UserAutofac(this IocContainerContext iocContainerContext) { return(UserAutofac(iocContainerContext, new ContainerBuilder())); }
public static IocContainerContext UserJsonNet(this IocContainerContext iocContainerContext) { iocContainerContext.Register <IJsonSerializer, NewtonsoftJsonSerializer>(new NewtonsoftJsonSerializer()); return(iocContainerContext); }
public static IocContainerContext UseDapper(this IocContainerContext configuration) { configuration.Register <IDapper, DapperInstance>(new DapperInstance()); return(configuration); }
public static IocContainerContext UseRepository(this IocContainerContext configuration) { configuration.RegisterType(typeof(IRepository <>), typeof(RepositoryInvoker <>)); return(configuration); }