private static IConfiguration GetDriverConfig(TestTarget target) { IConfigurationRoot config = GetConfigurationRoot(); var configModel = new DefaultConfig(target, config); return(configModel); }
public void Register(ContainerBuilder builder, ITypeFinder typeFinder, DefaultConfig config) { //common factories builder.RegisterType <AclSupportedModelFactory>().As <IAclSupportedModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <TenantMappingSupportedModelFactory>().As <ITenantMappingSupportedModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <StoreMappingSupportedModelFactory>().As <IStoreMappingSupportedModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <AppliedStoreSupportedModelFactory>().As <IAppliedStoreSupportedModelFactory>().InstancePerLifetimeScope(); //admin factories builder.RegisterType <ReportModelFactory>().As <IReportModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <ActivityLogModelFactory>().As <IActivityLogModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <BaseModelFactory>().As <IBaseModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <UserModelFactory>().As <IUserModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <UserAccountModelFactory>().As <IUserAccountModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <RoleModelFactory>().As <IRoleModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <StoreModelFactory>().As <IStoreModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <CommonModelFactory>().As <ICommonModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <DeviceModelFactory>().As <IDeviceModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <OrderLimitModelFactory>().As <IOrderLimitModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <SettingModelFactory>().As <ISettingModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <ReplenishmentModelFactory>().As <IReplenishmentModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <PushNotificationModelFactory>().As <IPushNotificationModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <ManagementModelFactory>().As <IManagementModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <LocationModelFactory>().As <ILocationModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <FormatSettingModelFactory>().As <IFormatSettingModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <SecurityModelFactory>().As <ISecurityModelFactory>().InstancePerLifetimeScope(); builder.RegisterType <LogModelFactory>().As <ILogModelFactory>().InstancePerLifetimeScope(); }
public void Can_configure_logging_plugin_file() { var tracingService = Substitute.For <ITracingService>(); var serviceProvider = Substitute.For <IServiceProvider>(); serviceProvider.GetService(Arg.Is(typeof(ITracingService))).Returns(tracingService); serviceProvider.GetService(Arg.Is(typeof(IPluginExecutionContext))).Returns(Substitute.For <IPluginExecutionContext>()); var container = new Container(serviceProvider); var pluginConfig = Substitute.For <IPluginConfiguration <xts_entity> >(); pluginConfig.Container.Returns(container); pluginConfig.ServiceDecorators.Returns(new List <Func <IOrganizationService, IServiceProvider, IOrganizationService> >()); pluginConfig.LogOption.Returns(PluginLogOption.File); pluginConfig.LogDirPath.Returns("log-dir"); DefaultConfig.PluginConfigureLogging(pluginConfig); var actualTracingService = container.GetService <ITracingService>(); Assert.NotSame(tracingService, actualTracingService); Assert.IsType <FilePluginTracingService>(actualTracingService); Assert.NotEmpty(pluginConfig.ServiceDecorators); var actualDecoratedService = pluginConfig.ServiceDecorators[1].Invoke(Substitute.For <IOrganizationService>(), container); Assert.IsType <LogOrganizationService>(actualDecoratedService); }
public static IServiceCollection AddRepositoryDefinition <TContext>(this IServiceCollection services, Type repoType) where TContext : DbContext { services.TryAddSingleton(typeof(IRepository <>), repoType); services.AddDbContextPool <TContext>(DefaultConfig.ConfigureDbContextOptionsBuilder("coworker-db", repoType.Assembly.GetName().Name)); return(services); }
public static List <ImageModel> selectImgList(DefaultConfig config) { string sql = "SELECT * FROM images WHERE 1=1"; if (!(config.author == null || config.author.Length == 0)) { sql += string.Format(" and author LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.author); } for (int i = 0; i < config.tags.Count; i++) { if (i == 0) { sql += string.Format(" and tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[0]); } else { sql += string.Format(" or tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[i]); } } if (config.fileSize != 0) { sql += " and file_size <=" + config.fileSize; } if (config.eTime != 0) { sql += " and images.created_at >=" + config.eTime; } sql += " and width >= " + config.w_min + " and width <= " + config.w_max + " and height>= " + config.h_min + " and height <=" + config.h_max; switch (config.order) { case 3: sql += " ORDER BY created_at"; break; case 2: sql += " ORDER BY height"; break; case 1: sql += " ORDER BY width"; break; case 0: sql += " ORDER BY score"; break; default: sql += " ORDER BY created_at"; break; } switch (config.sort) { case 1: sql += " DESC"; break; default: sql += " ASC"; break; } sql += string.Format(" limit {0}", config.limit); DataSet ds = MySQLTool.getDataSet(sql); List <ImageModel> list = new List <ImageModel>(); foreach (DataRow row in ds.Tables[0].Rows) { list.Add(toImage(row)); } return(list); }
public JsonResult SelectImgJson() { String id = Request["id"]; List <ImageModel> list = new List <ImageModel>(); if (!(id == null || id.Equals(""))) { list.Add(ImgService.selectImgById(Convert.ToInt64(id))); } else { DefaultConfig config = setConfig(); if (Request["limit"] != null) { config.limit = Convert.ToInt32(Request["limit"]); } if (config.order == StaticVal.Order.ORDER_BY_RANDOM) { list.AddRange(ImgService.random(config)); } else { list.Add(ImgService.selectImg(config)); } } DataTool.addHis("json", IPAddress(), list); return(Json(list, JsonRequestBehavior.AllowGet)); }
public DefaultConfig setConfig() { DefaultConfig config = new DefaultConfig(); String order = Request["order"]; String days = Request["days"]; String w_max = Request["w_max"]; String w_min = Request["w_min"]; String h_max = Request["h_max"]; String h_min = Request["h_min"]; config.tags.Add(Request["tag"]); config.author = Request["author"]; String limit = Request["limit"]; String desc = Request["desc"]; String size = Request["size"]; string username = Request["username"]; if (!(username == null || username.Equals(""))) { config.username = username; } if (!(size == null || size.Equals(""))) { config.fileSize = Convert.ToInt64(size); } if (!(order == null || order.Equals(""))) { config.order = Convert.ToInt32(order); } if (!(days == null || days.Equals(""))) { config.days = Convert.ToInt32(days); config.eTime = DateUtil.zeroTime(config.days); } if (!(h_max == null || h_max.Equals(""))) { config.h_max = Convert.ToInt32(h_max); } if (!(h_min == null || h_min.Equals(""))) { config.h_min = Convert.ToInt32(h_min); } if (!(w_max == null || w_max.Equals(""))) { config.w_max = Convert.ToInt32(w_max); } if (!(w_min == null || w_min.Equals(""))) { config.w_min = Convert.ToInt32(w_min); } if (!(limit == null || limit.Equals(""))) { config.limit = Convert.ToInt32(limit); } if (!(desc == null || desc.Equals(""))) { config.sort = Convert.ToInt32(desc); } return(config); }
public override DefaultConfig Prep(DefaultConfig cfg) { lock (ilock) { cfg.id = id++; } Task <MediaPlayer> tsk = new Task <MediaPlayer>(() => { var request = (HttpWebRequest)WebRequest.Create($"http://{Program.config.tts_ip}:{Program.config.tts_port}/api/tts?text={HttpUtility.UrlEncode(cfg.msg.Text)}"); HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException) { Console.WriteLine("Error connecting to TTS server!"); return(null); } if (response.ContentType != "audio/wav") { Console.WriteLine("Invalid content type!"); return(null); } using (var stream = response.GetResponseStream()) { return(new MediaPlayer(stream)); } }); tsk.Start(); cfg.obj = tsk; return(cfg); }
private static void Main() { Console.Title = "Confirmer by sne4kyFox"; Console.WriteLine("This program will accept any and ALL mobile auth confirmations, use with extreme caution."); Console.WriteLine( "By using this software you agree to the terms in \"license.txt\"."); _config = ConfigHandler.Reload(); if (string.IsNullOrEmpty(_config.ApiKey)) { Console.WriteLine("Fatal error: API key is missing. Please fill in the API key field in \"configuration.xml\""); Console.ReadLine(); Environment.Exit(-1); } Console.WriteLine("Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _config.Username, _config.Password, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); while (!File.Exists("account.maFile")) { SteamAuthLogin(); } var sgAccount = JsonConvert.DeserializeObject <SteamGuardAccount>(File.ReadAllText("account.maFile")); AcceptConfirmationsLoop(sgAccount); }
public TestInit(string ddd) { if (ddd == "") { } IConfigSource configSource = new DefaultConfig(); configSource.Config.Application.AppProvider = "CommonFrameWork.Application.DefaultApp,CommonFrameWork"; configSource.Config.Application.ObjectContainer = "CommonFrameWork.Extensions.Autofac.AutofacObjectContainer,CommonFrameWork.Extensions.Autofac"; //configSource.Config.Application.SerializationProvider = "CommonFrameWork.Extensions.NewTonSoft.NewTonSoftSerializer,CommonFrameWork.Extensions.NewTonSoft"; configSource.Config.Application.Assemblies = Utils.GetAllAssemblies("Project.Domain.ModuleManager"); configSource.Config.Application.LogProvider = "CommonFrameWork.Extensions.Log4Net.Log4NetLoggerFactory,CommonFrameWork.Extensions.Log4Net"; var application = AppRuntime.Create(configSource).UseMassTransit(); //application.Starting += Add; //application.Started += Add2; //application.Stopping += Add3; application.Start(); }
private static void Main() { Console.Title = "Exchange Bot by sne4kyFox"; Console.WriteLine("Welcome to the exchange bot!"); Console.WriteLine( "By using this software you agree to the terms in \"license.txt\"."); _config = ConfigHandler.Reload(); ConfigErrorResult errors = _config.CheckForErrors(); if (!errors.Valid) { Console.WriteLine(errors.ErrorMessage); Console.ReadLine(); Environment.Exit(-1); } Console.WriteLine("Attempting web login..."); _account = Web.RetryDoLogin(TimeSpan.FromSeconds(5), 10, _config.Username, _config.Password, _config.SteamMachineAuth); if (!string.IsNullOrEmpty(_account.SteamMachineAuth)) { _config.SteamMachineAuth = _account.SteamMachineAuth; ConfigHandler.WriteChanges(_config); } Console.WriteLine("Login was successful!"); PollOffers(); }
/// <summary> /// Register dependencies using Autofac /// </summary> /// <param name="services">Collection of service descriptors</param> /// <param name="typeFinder">Type finder</param> protected virtual IServiceProvider RegisterDependencies(DefaultConfig defaultConfig, IServiceCollection services, ITypeFinder typeFinder) { var containerBuilder = new ContainerBuilder(); //register engine containerBuilder.RegisterInstance(this).As <IEngine>().SingleInstance(); //register type finder containerBuilder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); //find dependency registrars provided by other assemblies var dependencyRegistrars = typeFinder.FindClassesOfType <IDependencyRegistrar>(); var instances = dependencyRegistrars .Select(dependencyRegistrar => (IDependencyRegistrar)Activator.CreateInstance(dependencyRegistrar)) .OrderBy(dependencyRegistrar => dependencyRegistrar.Order); //register all provided dependencies foreach (var dependencyRegistrar in instances) { dependencyRegistrar.Register(containerBuilder, typeFinder, defaultConfig); } //populate Autofac container builder with the set of registered service descriptors containerBuilder.Populate(services); //create service provider _serviceProvider = new AutofacServiceProvider(containerBuilder.Build()); return(_serviceProvider); }
public IConfiguration GetDriverConfig(TestTarget target) { IConfigurationRoot config = GetConfigurationRoot(); //create a IConfiguration using DefaultConfig. Create your own if needed but first explore the options in Microsoft's ConfigurationBuilder var configModel = new DefaultConfig(target, config); return configModel; }
public IConfiguration GetDriverConfig(TestTarget target) { IConfigurationRoot config = GetConfigurationRoot(); //create a IConfiguration using DefaultConfig. Create your own if needed but first explore the options in Microsoft's ConfigurationBuilder var configModel = new DefaultConfig(target, config); return(configModel); }
public override DefaultConfig Prep(DefaultConfig cfg) { lock (ilock) { cfg.id = id++; } return(cfg); }
internal static int DefaultMain(DefaultConfig !config) { SourceFilter = config.SourceFilter; DumpAll = config.DumpAll; ListActiveSources(); return(0); }
protected override void LoadDefaultConfig() { PrintWarning("Creating a new configuration file"); Config.Clear(); config = new DefaultConfig(); Config.WriteObject(config, true); SaveConfig(); }
public static int selectImgListCount(DefaultConfig config) { string sql = selectImgListSql(config, -1, -1, config.username); sql = "select count(*) as count from (" + sql + ") as newTable"; DataSet ds = MySQLTool.getDataSet(sql); return(Convert.ToInt32(ds.Tables[0].Rows[0]["count"].ToString())); }
public static string selectImgListSql(DefaultConfig config, int index, int num, string username) { string sql = "SELECT *,ifnull(ff.status,0) as tstatus FROM images LEFT JOIN (SELECT kid AS fkid, COUNT( * ) AS num FROM favor GROUP BY fkid) AS f ON f.fkid = images.kid "; sql += string.Format("left join(select kid as ffkid, status from favor where uid = (select uid from user where username = '******')) as ff on ff.ffkid = images.kid WHERE 1 = 1", username); if (!(config.author == null || config.author.Length == 0)) { sql += string.Format(" and author LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.author); } for (int i = 0; i < config.tags.Count; i++) { if (i == 0) { sql += string.Format(" and tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[0]); } else { sql += string.Format(" or tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[i]); } } if (config.fileSize != 0) { sql += " and file_size <=" + config.fileSize; } if (config.eTime != 0) { sql += " and images.created_at >=" + config.eTime; } sql += " and width >= " + config.w_min + " and width <= " + config.w_max + " and height>= " + config.h_min + " and height <=" + config.h_max; switch (config.order) { case 3: sql += " ORDER BY created_at"; break; case 2: sql += " ORDER BY height"; break; case 1: sql += " ORDER BY width"; break; case 0: sql += " ORDER BY score"; break; default: sql += " ORDER BY created_at"; break; } switch (config.sort) { case 1: sql += " DESC"; break; default: sql += " ASC"; break; } if (index != -1 && num != -1) { sql += string.Format(" limit {0},{1}", index, num); } return(sql); }
public static void Init(CompositionContainer container) { Container = new MefContainer(container); loginManager = Container.GetInstance <ILoginManager>(); Config = new DefaultConfig(); //Start the job engine. Container.GetInstance <JobEngine>().Start(); }
public void GetClickBehavior(DefaultConfig config) { string TableName = "Styles"; string PartitionName = "DefaultAds"; string RowNameAdsDiv = "ClicBehavior"; DefaultHtmlEntity styleClicBehavior = TableManager.GetClicBehavior(TableName, PartitionName, RowNameAdsDiv); config.ClicBehavior = string.Format(styleClicBehavior.Html); }
public override int GetHashCode() { int hashcode = 157; unchecked { hashcode = (hashcode * 397) + DefaultConfig.GetHashCode(); hashcode = (hashcode * 397) + TCollections.GetHashCode(ServiceConfigs); } return(hashcode); }
public void selectImgListTest() { DefaultConfig defaultConfig = new DefaultConfig(); defaultConfig.author = TestContext.DataRow["author"].ToString(); defaultConfig.w_max = Convert.ToInt32(TestContext.DataRow["width"].ToString()); defaultConfig.h_max = Convert.ToInt32(TestContext.DataRow["height"].ToString()); Assert.IsNotNull(selectImgList(defaultConfig)); }
private void OptionsGet(string key) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); } key = key.Trim(); string defaultValue = ""; string value = ""; string type = ""; string values = ""; switch (key) { case "MaxBranchingFactor": DefaultConfig.GetMaxBranchingFactorValue(out type, out defaultValue, out values); Config.GetMaxBranchingFactorValue(out type, out value, out values); break; case "MaxHelperThreads": DefaultConfig.GetMaxHelperThreadsValue(out type, out defaultValue, out values); Config.GetMaxHelperThreadsValue(out type, out value, out values); break; case "PonderDuringIdle": DefaultConfig.GetPonderDuringIdleValue(out type, out defaultValue, out values); Config.GetPonderDuringIdleValue(out type, out value, out values); break; case "TranspositionTableSizeMB": DefaultConfig.GetTranspositionTableSizeMBValue(out type, out defaultValue, out values); Config.GetTranspositionTableSizeMBValue(out type, out value, out values); break; case "ReportIntermediateBestMoves": DefaultConfig.GetReportIntermediateBestMovesValue(out type, out defaultValue, out values); Config.GetReportIntermediateBestMovesValue(out type, out value, out values); break; default: throw new ArgumentException(string.Format("The option \"{0}\" is not valid.", key)); } if (string.IsNullOrWhiteSpace(values)) { ConsoleOut(string.Format("{0};{1};{2};{3}", key, type, value, defaultValue)); } else { ConsoleOut(string.Format("{0};{1};{2};{3};{4}", key, type, value, defaultValue, values)); } }
public static void AddBlazorGrid(this IServiceCollection services, Action <IBlazorGridConfig> configuration) { services.AddSingleton <IBlazorGridConfig>(_ => { var config = new DefaultConfig(); configuration?.Invoke(config); return(config); }); }
public void Start(IBundleContext context) { Bundle = context.Bundle; PageFlowServiceTracker = new ServiceTracker <IPageFlowService>(context); BundleManagementServiceTracker = new ServiceTracker <IBundleManagementService>(context); //初始化菜单数据 NavigationModel = new NavigationModel(context.Bundle); DefaultConfig.RegisterBundleNamespaces(context.Bundle.SymbolicName, GetType().Assembly); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public override string ToString() { var sb = new StringBuilder("ThrottlingResponse("); sb.Append(", DefaultConfig: "); sb.Append(DefaultConfig == null ? "<null>" : DefaultConfig.ToString()); sb.Append(", ServiceConfigs: "); sb.Append(ServiceConfigs); sb.Append(")"); return(sb.ToString()); }
public static DataSet selectImgList(DefaultConfig config) { string sql = "SELECT * FROM images WHERE 1=1"; if (!(config.author == null || config.author.Length == 0)) { sql += string.Format(" and author LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.author); } for (int i = 0; i < config.tags.Count; i++) { if (i == 0) { sql += string.Format(" and tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[0]); } else { sql += string.Format(" or tags LIKE CONCAT(CONCAT('%', '{0}'),'%')", config.tags[i]); } } if (config.fileSize != 0) { sql += " and file_size <=" + config.fileSize; } if (config.eTime != 0) { sql += " and images.created_at >=" + config.eTime; } sql += " and width >= " + config.w_min + " and width <= " + config.w_max + " and height>= " + config.h_min + " and height <=" + config.h_max; switch (config.order) { case 3: sql += " ORDER BY created_at"; break; case 2: sql += " ORDER BY height"; break; case 1: sql += " ORDER BY width"; break; case 0: sql += " ORDER BY score"; break; default: sql += " ORDER BY created_at"; break; } switch (config.sort) { case 1: sql += " DESC"; break; default: sql += " ASC"; break; } sql += string.Format(" limit {0}", config.limit); DataSet ds = DBhelper.getDS(sql); return(ds); }
public static List <ImageModel> selectImgList(DefaultConfig config, int index, int num, string username) { string sql = selectImgListSql(config, index, num, username); DataSet ds = MySQLTool.getDataSet(sql); List <ImageModel> list = new List <ImageModel>(); foreach (DataRow row in ds.Tables[0].Rows) { list.Add(toImageWithLikes(row)); } return(list); }
void Init() { try { config = Config.ReadObject <DefaultConfig>(); } catch { PrintWarning("Could not read config, creating new default config"); LoadDefaultConfig(); } }
//load config static void LoadConfig() { _config = ConfigHandler.Reload(_config); if (!string.IsNullOrEmpty(_config.ApiKey)) { return; } Console.WriteLine("Fatal error: API key is missing. Please fill in the API key field in \"configuration.xml\""); Console.ReadLine(); Environment.Exit(-1); }
private static IConfiguration GetDriverConfig(TestTarget target) { IConfigurationRoot config = GetConfigurationRoot(); var configModel = new DefaultConfig(target, config); return configModel; }