public DatabaseApiClientService( MyConfiguration configuration, IFactoryService factoryService) { _configuration = configuration; _factoryService = factoryService; }
public void LoadFromSettings_should_return_valid_session_after_checking_specified_assembly_by_AssemblyFrom() { using (new IndirectionsContext()) { // Arrange var myConfiguration = new MyConfiguration(); myConfiguration.AssemblyFrom = typeof(object).Assembly.Location; myConfiguration.Settings = Guid.NewGuid().ToString("N") + ".my"; var assemblyMock = new PAssemblyMock(); assemblyMock.SetupLoadFromString(myConfiguration.AssemblyFrom); var configurationMock = new PProxyConfigurationMock(); configurationMock.SetupGetSectionString("my"); var configurationManagerMock = new PConfigurationManagerMock(); configurationManagerMock.SetupOpenMappedExeConfigurationExeConfigurationFileMapConfigurationUserLevel(myConfiguration.Settings, configurationMock); // Act var section = myConfiguration.LoadFromSettings(); // Assert assemblyMock.VerifyLoadString(); configurationMock.VerifyGetSectionString(); configurationManagerMock.VerifyOpenMappedExeConfigurationExeConfigurationFileMapConfigurationUserLevel(); Assert.IsNotNull(section); } }
public JsonResult UploadPicture() { ViewModel.BaseJsonData json = new ViewModel.BaseJsonData(); var file = Request.Files["data"]; if (file == null) { json.state = 0; json.msg_text = "没有文件,请重新上传。"; } if (Path.GetExtension(file.FileName).ToLower() != ".jpg") { json.state = 0; json.msg_text = "请上传jpg格式文件。"; } string photoTempDir = MyConfiguration.GetTempPhotoPath(); if (!Directory.Exists(photoTempDir)) { Directory.CreateDirectory(photoTempDir); } string guid = Guid.NewGuid().ToString("N"); string file_name = string.Format("{0}{1}.jpg", photoTempDir, guid); string file_name_temp = string.Format("{0}{1}_temp.jpg", photoTempDir, guid); file.SaveAs(file_name); ImageFun.MakeThumbnail(file_name, file_name_temp, 106, 0, "W"); json.state = 1; json.data = Path.GetFileName(file_name_temp); return(Json(json)); }
public CampaignSyncService(ICompanyRepository companyRepository, MyConfiguration configuration, ICampaignRepository campaignRepository, ICustomExceptionService customExceptionService) { this._companyRepository = companyRepository; this._settings = configuration.settings; this._campaignRepository = campaignRepository; _customExceptionService = customExceptionService; }
private void InitDatabase() { //初始化数据库 using (var database = new SqlServerDb()) //新增 { database.Database.EnsureDeleted(); database.Database.EnsureCreated(); } var services = new ServiceCollection(); services.AddSummerBoot(); var connectionString = MyConfiguration.GetConfiguration("sqlServerDbConnectionString"); if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentNullException("Sqlserver connectionString must not be null"); } services.AddSummerBootRepository(it => { it.DbConnectionType = typeof(SqlConnection); it.ConnectionString = connectionString; }); serviceProvider = services.BuildServiceProvider(); serviceProvider = serviceProvider.CreateScope().ServiceProvider; }
private static IEnumerable <Type> GetBrainSimUIExtensionTypes() { var ret = new List <Type>(); foreach (FileInfo assemblyFile in MyConfiguration.ListModules()) { try { Assembly assembly = Assembly.LoadFrom(assemblyFile.FullName); string xml; if (MyResources.TryGetTextFromAssembly(assembly, MyModuleConfig.MODULE_CONFIG_FILE, out xml)) { continue; } MyLog.INFO.WriteLine("UI module loaded: " + assemblyFile.Name); ret.AddRange(assembly.GetTypes().Where(IsUIExtension)); } catch (Exception ex) { MyLog.DEBUG.WriteLine("Error when looking for UI modules: " + ex.Message); } } return(ret); }
private static string GetRequestFlickerUrl() { string url; string configuredUrl = MyConfiguration.GetString(ConfigurationKeys.RequestFlickerUrl.ToString(), "ws://localhost:8181/"); if (configuredUrl.StartsWith("http://")) { //Dynamic retrieval! string urlRequest = string.Format("{0}?get=RequestFlicker", configuredUrl); var result = WebRequest.Create(urlRequest).GetResponse().GetResponseStream(); var stream = new StreamReader(result); String ContenuPageWeb = stream.ReadToEnd(); logger.Info(string.Format("Response : {0}", ContenuPageWeb)); url = String.Format("ws://{0}/", ContenuPageWeb.Trim()); logger.Info(String.Format("Dynamic Url found: {0}", url)); } else { if (configuredUrl.StartsWith("ws://")) { url = configuredUrl; logger.Info(String.Format("Url found in configuration {0}", url)); } else { throw new ApplicationException(string.Format("Invalid RequestFlicker Url : {0}", configuredUrl)); } } return(url); }
private void insertCompanyData() { Persistence pers = new PersistenceImpl(); var myconf = new MyConfiguration(); myconf.currentBatch = "2012-16"; myconf.currentDegree = "B.TECH"; var compList = new List <Object>(); for (int i = 108; i < 109; i++) { var compObj = new Entity_Company(); compObj.companyId = i; compObj.companyName = "COMPANY" + i; var compDetail = new Entity_CompanyDetails(); compDetail.DOR = DateTime.Now.AddDays(20 + i); compDetail.host = "ACET"; compDetail.myConfigObj = myconf; compDetail.staffId = 1; compDetail.status = 1; compDetail.type = 0; compDetail.companyObj = compObj; compList.Add(compDetail); } pers.bulkInsert(compList); }
public void LoadFromAppConfig_should_return_valid_session_after_checking_specified_assembly() { using (new IndirectionsContext()) { // Arrange var myConfiguration = new MyConfiguration(); myConfiguration.Assembly = typeof(object).Assembly.FullName; var assemblyMock = new PAssemblyMock(); assemblyMock.SetupLoadString(myConfiguration.Assembly); var configurationManagerMock = new PConfigurationManagerMock(); configurationManagerMock.SetupGetSectionString("my"); // Act var section = myConfiguration.LoadFromAppConfig(); // Assert assemblyMock.VerifyLoadString(); configurationManagerMock.VerifyGetSectionString(); Assert.IsNotNull(section); } }
public Startup(IConfiguration configuration, IWebHostEnvironment environment) { Configuration = configuration; Environment = environment; _myConfiguration = Configuration.GetSection("MyConfiguration").Get <MyConfiguration>(); }
public void ItShouldBeResolvableByInterfaceAndItsWrappedType() { var configurationInstanceHolder = new ConfigurationInstanceHolder(); var configuration = new MyConfiguration(123); var namedInstance = new NamedInstance <MyConfiguration>(configuration, "myInstance"); configurationInstanceHolder.Add(namedInstance); ServiceProvider serviceProvider = new ServiceCollection() .AddConfigurationInstanceHolder(configurationInstanceHolder) .BuildServiceProvider(); var myConfiguration = serviceProvider.GetService <MyConfiguration>(); Assert.NotNull(myConfiguration); Assert.Equal(123, myConfiguration.Id); var namedFromProviderInstance = serviceProvider.GetService <INamedInstance <MyConfiguration> >(); Assert.NotNull(namedFromProviderInstance); Assert.Equal(123, namedFromProviderInstance.Value.Id); Assert.Equal("myInstance", namedFromProviderInstance.Name); Assert.Equal(namedInstance, namedFromProviderInstance); }
private void updateConfiguration() { if (!Utility.isNetworkAvailable()) { Dialog_MyMessageBox.Show(Validations.VALIDATION_NO_NETWORK, 1, UiColors.MESSAGE_ERROR); } else { string batch = dropdown_batch.SelectedItem.ToString(); string degree = dropDown_degree.SelectedItem.ToString(); MyConfiguration configObjCopy = Common.loggedUser.myConfigObj; if (isValidated(batch, degree)) { Common.loggedUser.myConfigObj.currentBatch = batch; Common.loggedUser.myConfigObj.currentDegree = degree; if (new StaffManagerImpl().updateStaffDetails(Common.loggedUser)) { result = DialogResult.Yes; } else { Common.loggedUser.myConfigObj = configObjCopy; result = DialogResult.Retry; } this.Dispose(); } } }
public void LoadFromSettings_should_throw_InvalidOperationException_if_Assembly_and_AssemblyFrom_are_not_specified() { // Arrange var myConfiguration = new MyConfiguration(); // Act, Assert Assert.Throws <InvalidOperationException>(() => myConfiguration.LoadFromSettings()); }
private IEnumerable <string> FindTestAssemblies() { List <string> fileList = FindBrainTestAssemblies().ToList(); fileList.AddRange(MyConfiguration.ListModules().Select(fileInfo => fileInfo.FullName)); return(fileList); }
public MessageController(IMsgRepository msgRepository, UserManager <ApplicationUser> userManager, IWebHostEnvironment hostingEnvironment, ILogger <MessageController> logger, MyConfiguration myConfiguration) { this.msgRepository = msgRepository; this.userManager = userManager; this.hostingEnvironment = hostingEnvironment; this.logger = logger; this.myConfiguration = myConfiguration; }
protected override void LoadFromDatabase() { if (MyConfiguration.GetBool("loadAllBattlesFromDatabase", false)) { string query = String.Format("{0};", SqlBattlesAllSelect); GetFromQuery(query); } }
public QRCodeService( ScmcDbContext dbContext, MyConfiguration myConfiguration ) { _dbContext = dbContext; _myConfiguration = myConfiguration; }
public LoginModel(SignInManager <AppUser> signInManager, ILogger <LoginModel> logger, UserManager <AppUser> userManager, IEmailSender emailSender, IOptions <MyConfiguration> options) { _signInManager = signInManager; _logger = logger; _userManager = userManager; _emailSender = emailSender; _myConfig = options.Value; }
public string Get(string reqType, string inputValue) { DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); try { if (reqType == "lookups") { CoreDbContext dbcontext = new CoreDbContext(connString); List <LookupsModel> allLookups = dbcontext.LookUps.ToList(); List <LookupsModel> retList = new List <LookupsModel>(); if (!string.IsNullOrEmpty(inputValue)) { retList = allLookups.Where(a => a.ModuleName.ToLower() == inputValue.ToLower()).ToList(); } else { retList = allLookups; } responseData.Results = retList; } else if (reqType == "appSettings-limited") { //Return only limited properties to client. //DO NOT return SECURE INFORMATION LIKE: CONNECTIONSTRINGS, FILELOCATIONS, etc.. MyConfiguration retValue = new MyConfiguration(); retValue.ApplicationVersionNum = this._appSettings.ApplicationVersionNum; retValue.highlightAbnormalLabResult = this._appSettings.highlightAbnormalLabResult; retValue.CacheExpirationMinutes = this._appSettings.CacheExpirationMinutes; responseData.Results = retValue; } //if (reqType == "engToNepDate") //{ // NepaliDate ndate = new NepaliDate(connString); // string retNepDate = ndate.NepaliLongDate(DateTime.Parse(value)); // responseData.Results = retNepDate; //} //else if (reqType == "nepToEngDate") //{ // NepaliDate ndate = new NepaliDate(connString); // string retEngDate = ndate.NeptoEnglishDate(value).ToString("yyyy-MM-dd"); // responseData.Results = retEngDate; //} responseData.Status = "OK"; } catch (Exception ex) { responseData.Status = "Failed"; responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString(); } return(DanpheJSONConvert.SerializeObject(responseData, true)); }
internal PoDAL() { //读配置文件 MyConfiguration cfg = new MyConfiguration(false); cfg.Load(settingFile); baseUrl = cfg.ReadString("BaseUrl"); token = TokenDAL.GetToken(); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var connectionString = MyConfiguration.GetConfiguration("sqlServerDbConnectionString"); if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentNullException("sqlServer connectionString must not be null"); } optionsBuilder.UseSqlServer(connectionString); }
//private readonly ILoggedUserService _loggedUserService; public DatabaseApiClientService( MyConfiguration configuration, IFactoryService factoryService//, //ILoggedUserService loggedUserService ) { _configuration = configuration; _factoryService = factoryService; //_loggedUserService = loggedUserService; }
public UsersController( IUserService userService, IMapper mapper, IOptions <AppSettings> appSettings, IOptions <MyConfiguration> myConfiguration) { _userService = userService; _mapper = mapper; _appSettings = appSettings.Value; _myConfiguration = myConfiguration.Value; }
public AdvertisementController(IAdvertisementService advertisementService, IBlockchainService blockchainService, ICurrencyService currencyService, IBankService bankService, ICountryService countryService, IOptions <MyConfiguration> options, MySessionManager mySessionManager, UserManager <AppUser> userManager) { _advertisementService = advertisementService; _blockchainService = blockchainService; _currencyService = currencyService; _bankService = bankService; _countryService = countryService; _mySessionManager = mySessionManager; _userManager = userManager; _myConfig = options.Value; }
public static DbAccessor CreateDbAccessor(string name) { var connectionString = MyConfiguration.Get().GetConnectionString(name); var providerName = MyConfiguration.Get().GetConnectionStringProviderName(name); if (string.IsNullOrEmpty(connectionString)) { throw new Exception(string.Format("请检查配置文件的数据库连接配置,找不到名称为{0}的ConnectionString!", name)); } return(CreateDbAccessor(connectionString, providerName)); }
private void insertStudentData() { Persistence p = new PersistenceImpl(); var conf = new MyConfiguration(); conf.currentBatch = "2012-16"; conf.currentDegree = "B.TECH"; string[] branch = new string[5] { "Software", "COMPUTER SCIENCE", "MECHANICAL", "ECE", "CIVIL" }; string[] gender = new string[2] { "MALE", "FEMALE" }; int studentId = 1704; long scoreID = 247; var mylist = new List <Object>(); var scoreList = new List <Object>(); for (int i = 200; i < 2201; i++) { var student = new Entity_Student(); student.branch = branch[i % branch.Length]; student.collegeId = studentId.ToString(); student.email = "*****@*****.**"; student.gender = gender[i % gender.Length]; student.myConfigObj = conf; student.phone = "111111111"; student.studentName = "Student" + i; mylist.Add(student); studentId++; var score = new Entity_StudentScore(); score.arrears = 0; score.cgpa = 7.6; score.X = 85; score.XII = 78; score.studentId = scoreID; scoreList.Add(score); scoreID++; } if (p.bulkInsert(mylist)) { p.bulkInsert(scoreList); } }
public void AddItemToList() { DateTime now = DateTime.Now.Date; System.Random r = new System.Random(); int rInt = r.Next(0, 100); MyConfiguration myConfiguration = new MyConfiguration(now.ToShortDateString(), model.text, rInt.ToString()); menuManager.myConfigs.Add(myConfiguration); ItemSaveIO.SaveItems(menuManager.myConfigs, "configurations"); WriteData(rInt); }
public MyProjectRunner(MyLogLevel level = MyLogLevel.DEBUG) { // why not to directly ask for TypeMap.GetInstance<MySimulation> ? // because in Typemap configuration, MySimulation is set to be singleton - this causes problems when MyProjectRunner // is instantiated multiple times - second and following instances obtain an instance of MySimulation from the first // MyProjectRunner instance. If the first MyProjectRunner instance was Shutdown-ed, the MySimulation instance is also // cleared and any following Shutdown on other MyProjectRunner instances will cause freeze/inifnite hang. // This code creates new MySimulation instance for each MyProjectRunner instance. // Other solution could be to not have a MySimulation as a singleton in TypeMap configuration - and it could work just OK, // because in BrainSim, the TypeMap's GetInstance on MySimulation is only on one place in MainForm. However, this may change // in future or the change itself may have other consequences, so for now I pick this solution, as it is safer. MySimulation simulation = new MyLocalSimulation(TypeMap.GetInstance <MyValidator>(), TypeMap.GetInstance <IMyExecutionPlanner>()); SimulationHandler = new MySimulationHandler(simulation); m_resultIdCounter = 0; SimulationHandler.ProgressChanged += SimulationHandler_ProgressChanged; SimulationHandler.StepPerformed += SimulationHandler_StepPerformed; m_monitors = new List <Tuple <int, uint, MonitorFunc> >(); m_results = new Hashtable(); Project = new MyProject(); var path = MyResources.GetEntryAssemblyPath(); if (MyConfiguration.ModulesSearchPath.Count == 0) { MyConfiguration.SetupModuleSearchPath(); } MyConfiguration.ProcessCommandParams(); try { if (MyConfiguration.Modules.Count == 0) { MyConfiguration.LoadModules(); } } catch (Exception e) { MyLog.WARNING.WriteLine(e.Message); throw; } MyLog.Level = level; }
public AccountController(UserManager <AppUser> userManager, SignInManager <AppUser> signInManager, IAppUserService appUserService, ILogger <AccountController> logger, //IMemoryCache cache, ISmsHelper smsHelper, IEmailSender emailSender, IOptions <MyConfiguration> options) { _userManager = userManager; _signInManager = signInManager; _appUserService = appUserService; _smsHelper = smsHelper; //_cache = cache; _log = logger; _myConfig = options.Value; _emailSender = emailSender; }
private static void Demo3_Configuration_StronglyTyped() { IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile("Configuration.json") .Build(); IServiceProvider serviceProvider = new ServiceCollection() .AddOptions() .Configure <MyConfiguration>(configuration.GetSection("my:configuration")) .BuildServiceProvider(); // Won't work // MyConfiguration myConfiguration = serviceProvider.GetRequiredService<MyConfiguration>(); IOptions <MyConfiguration> optionsOfMyConfiguration = serviceProvider.GetRequiredService <IOptions <MyConfiguration> >(); MyConfiguration myConfiguration = optionsOfMyConfiguration.Value; Console.WriteLine($"Value = {myConfiguration.Value}"); }