/// <summary> /// Do the initial setup for the application /// </summary> /// <param name="originalConfig"></param> /// <param name="configSource"></param> /// <param name="cmdParams"></param> /// <param name="configLoader"></param> public virtual void Initialize(IConfigSource originalConfig, IConfigSource configSource, string[] cmdParams, ConfigurationLoader configLoader) { m_commandLineParameters = cmdParams; m_StartupTime = DateTime.Now; m_version = VersionInfo.Version + " (" + Util.GetRuntimeInformation() + ")"; m_original_config = originalConfig; m_config = configSource; m_configurationLoader = configLoader; // This thread will go on to become the console listening thread if (System.Threading.Thread.CurrentThread.Name != "ConsoleThread") { System.Threading.Thread.CurrentThread.Name = "ConsoleThread"; } //Register the interface ApplicationRegistry.RegisterModuleInterface <ISimulationBase>(this); Configuration(configSource); InitializeModules(); RegisterConsoleCommands(); }
void GetLob(String slob) { if (!_lobs.ContainsKey(slob)) { NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); LobSystemInstance l = sysInstances[slob]; IEnumerator it = _cfg.lobCollection.GetEnumerator(); while (it.MoveNext()) { Lob lob = (Lob)it.Current; if (lob.name.Equals(slob)) { _lobInsts.Add(slob, l); //the real lob _lobs.Add(slob, lob); //the config of lob break; } } } _lobInst = (LobSystemInstance)_lobInsts[slob]; _lob = (Lob)_lobs[slob]; if (_lobInst == null) { throw new Exception(slob + " does not exist in this service provider, check the name to make sure it's correct."); } if (_lob == null) { throw new Exception(slob + " is not found in bdc.xml"); } return; }
internal Dictionary <string, BdcLobSysInst> GetLobSystemInstances() { #if SP12 return(ApplicationRegistry.GetLobSystemInstances()); #else INamedLobSystemDictionary dict; Dictionary <string, BdcLobSysInst> result = new Dictionary <string, BdcLobSysInst> (); BdcLobSysInstDict tmp; if (bdcCat == null) { if (bdcService == null) { bdcService = new BdcService(); } bdcCat = bdcService.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current); } if ((dict = bdcCat.GetLobSystems("*")) != null) { foreach (KeyValuePair <string, ILobSystem> kvp in dict) { if ((tmp = kvp.Value.GetLobSystemInstances()) != null) { foreach (KeyValuePair <string, BdcLobSysInst> kvp2 in tmp) { result [kvp2.Key] = kvp2.Value; } } } } return(result); #endif }
public void 定義したカスタムアクセッサを使えるか() { ApplicationRegistry.RegistCustomAccessor("CUSTOM", new CustomAccessor()); Assert.That(ApplicationRegistry.Get <ICustomRegistry>().AssemblyName, Is.EqualTo(Assembly.GetExecutingAssembly().GetName().Name)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services .AddControllers(options => { options.Filters.Add(typeof(ValidationFilter)); options.Filters.Add(typeof(ExceptionFilter)); }) .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }) .AddFluentValidation(options => { options.RegisterValidatorsFromAssembly(ApplicationRegistry.GetAssembly()); }); services.Configure <ServerSettings>( Configuration.GetSection("Server")); services.Configure <MongoConnectionSettings>( Configuration.GetSection("MongoConnection")); services.Configure <MongoContextSettings <RegistryContext> >( Configuration.GetSection("MongoConnection:Registry")); services.Configure <MongoContextSettings <GameContext> >( Configuration.GetSection("MongoConnection:Game")); services.Configure <EmailSenderSettings>( Configuration.GetSection("SmtpServer")); services.Configure <DefaultUsersSettings>( Configuration.GetSection("DefaultUsers")); services.RegisterDomainLayer(Configuration["MongoConnection:ConnectionString"]); services.RegisterApplicationLayer(); }
public void ProductsCanBeFound() { SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP"); NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); LobSystemInstance lobSystemInstance = sysInstances["ContosoProductCatalogService"]; NamedEntityDictionary entities = lobSystemInstance.GetEntities(); Entity productEntity = entities["Product"]; IEntityInstance productInstance = productEntity.FindSpecific("1000000000", lobSystemInstance); Assert.AreEqual("Blood Pressure Kit", productInstance["Name"]); Assert.AreEqual("Blood pressure kit includes cuff with velcro adhesive and easy to read glow in the dark dial.", productInstance["LongDescription"]); Assert.AreEqual("Blood pressure kit includes cuff and easy to read dial.", productInstance["ShortDescription"]); Assert.AreEqual("1000000000", productInstance["Sku"]); Assert.AreEqual("8", productInstance["CategoryId"]); Assert.IsTrue(productInstance["ImagePath"].ToString().EndsWith("images/bloodpressure.jpg")); Assert.IsTrue(productInstance["ThumbnailImagePath"].ToString().EndsWith("images/bloodpressure.jpg")); productInstance = productEntity.FindSpecific("2000000000", lobSystemInstance); Assert.AreEqual("Gurney", productInstance["Name"]); Assert.AreEqual("Gurney includes rubber wheels and extra padding. Meets most federal safety requirements.", productInstance["LongDescription"]); Assert.AreEqual("Gurney includes rubber wheels and extra padding.", productInstance["ShortDescription"]); Assert.AreEqual("2000000000", productInstance["Sku"]); Assert.AreEqual("10", productInstance["CategoryId"]); Assert.IsTrue(productInstance["ImagePath"].ToString().EndsWith("images/gurney.jpg")); Assert.IsTrue(productInstance["ThumbnailImagePath"].ToString().EndsWith("images/gurney.jpg")); }
/// <summary> /// Initialize a new instance of the <c>XData</c> class . /// </summary> /// <param name="appReg">Name of the application associated with the list of extended data records.</param> public XData(ApplicationRegistry appReg) { if (appReg == null) { throw new ArgumentNullException(nameof(appReg)); } this.appReg = appReg; this.xData = new List <XDataRecord>(); }
protected virtual void OnXDataRemoveAppRegEvent(ApplicationRegistry item) { XDataRemoveAppRegEventHandler ae = this.XDataRemoveAppReg; if (ae != null) { ae(this, new ObservableCollectionEventArgs <ApplicationRegistry>(item)); } }
private void OnRemoveAppRegEvent(ApplicationRegistry item) { RemoveAppRegEventHandler ae = this.RemoveAppReg; if (ae != null) { ae(this, new ObservableCollectionEventArgs <ApplicationRegistry>(item)); } }
public void ContosoProductCatalogServiceIsRegistered() { SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP"); NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); Assert.AreEqual(1, sysInstances.Count); Assert.IsNotNull(sysInstances["ContosoProductCatalogService"]); }
private void ShutdownRegion(Scene scene) { m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName); IRegionModulesController controller; if (ApplicationRegistry.TryGet <IRegionModulesController>(out controller)) { controller.RemoveRegionFromModules(scene); } }
public void Test() { var listenPortNo = ApplicationRegistry.Get <IDefaultValueRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80)); var testName = ApplicationRegistry.Get <IDefaultValueRegistry>().TestName; Assert.That(testName, Is.EqualTo("temp")); }
public void データが見つからない場合は例外が発生する() { Assert.Throws <DataNotFoundException>(() => { Environment.SetEnvironmentVariable("ApplicationRegistries2.Test_IEnvironmentVariableRegistry_ListenPortNo", null); // ReSharper disable once UnusedVariable var listenPortNo = ApplicationRegistry.Get <IEnvironmentVariableRegistry>().ListenPortNo; }); }
private static void IterateLOBSystems() { NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); Console.WriteLine("Listing system instances..."); foreach (String name in sysInstances.Keys) { Console.WriteLine(name); } NamedLobSystemDictionary lobSystems = ApplicationRegistry.GetLobSystems(); foreach (LobSystem lobSystem in lobSystems.Values) { Console.WriteLine("Application: " + lobSystem.Name); NamedDataClassDictionary lobClasses = lobSystem.GetDataClasses(); foreach (DataClass dataClass in lobClasses.Values) { Console.WriteLine(" Entities: " + dataClass.Name); } if (lobSystem.Name == "AdventureWorksSample") { // work on a specific class DataClass customers = lobClasses["Customer"]; NamedMethodDictionary methods = customers.GetMethods(); foreach (Method meth in methods.Values) { Console.WriteLine(" Method: " + meth.Name); } } if (lobSystem.Name == "AdventureWorksLOBSystem") { // filter all femalce Employees Entity employees = lobSystem.GetEntities()["HumanResources.Employee"]; FilterCollection filtered = employees.GetFinderFilters(); (filtered[0] as ComparisonFilter).Value = 10; IEntityInstanceEnumerator empEnum = employees.FindFiltered(filtered, ApplicationRegistry.GetLobSystemInstances ()["AdventureWorksInstance"]); while (empEnum.MoveNext()) { DataTable dt = (empEnum.Current as DbEntityInstance).EntityAsDataTable; PrintDataRow(dt.Rows[0]); } } } }
public void ContosoProductCatalogServiceHasCatalogAndProductEntities() { SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP"); NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); LobSystemInstance lobSystemInstance = sysInstances["ContosoProductCatalogService"]; NamedEntityDictionary entities = lobSystemInstance.GetEntities(); Assert.AreEqual(3, entities.Count); Assert.IsNotNull(entities["Category"]); Assert.IsNotNull(entities["Product"]); Assert.IsNotNull(entities["Part"]); }
public void Prefixが変更された場合はそれに従う() { Environment.SetEnvironmentVariable("ApplicationRegistoryTest_PortNo", "81"); var listenPortNo = ApplicationRegistry.Get <IEnvironmentVariableRegistryWithPrefix>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(81)); Environment.SetEnvironmentVariable("ApplicationRegistoryTest_TestName", TestContext.CurrentContext.Test.Name); var testName = ApplicationRegistry.Get <IEnvironmentVariableRegistryWithPrefix>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
private void SetUserData(netDxf.Entities.EntityObject entity, IGeoObject go) { if (entity is null || go is null || go.UserData is null || go.UserData.Count == 0) { return; } foreach (KeyValuePair <string, object> de in go.UserData) { if (de.Value is ExtendedEntityData xData) { ApplicationRegistry registry = new ApplicationRegistry(xData.ApplicationName); XData data = new XData(registry); foreach (var item in xData.Data) { XDataCode code = item.Key; XDataRecord record = new XDataRecord(code, item.Value); data.XDataRecord.Add(record); } entity.XData.Add(data); } else { ApplicationRegistry registry = new ApplicationRegistry(ApplicationRegistry.DefaultName); XData data = new XData(registry); XDataRecord record = null; //TODO: Add more types if (de.Value is string strValue) { record = new XDataRecord(XDataCode.String, strValue); } else if (de.Value is short shrValue) { record = new XDataRecord(XDataCode.Int16, shrValue); } else if (de.Value is int intValue) { record = new XDataRecord(XDataCode.Int32, intValue); } if (record != null) { data.XDataRecord.Add(record); } } } }
public void AddApplication([NotNull] ApplicationRegistry applicationRegistry) { if (memoryCache.TryGetValue(applicationRegistry.Id, out ApplicationRegistry val)) { if (!val.Equals(applicationRegistry)) { memoryCache.Set(applicationRegistry.Id, applicationRegistry, TimeSpan.FromMinutes(20)); } } else { memoryCache.Set(applicationRegistry.Id, applicationRegistry, TimeSpan.FromMinutes(20)); } }
public void デフォルトの挙動() { Environment.SetEnvironmentVariable("ApplicationRegistries2.Test_IEnvironmentVariableRegistry_ListenPortNo", "80"); var listenPortNo = ApplicationRegistry.Get <IEnvironmentVariableRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80)); Environment.SetEnvironmentVariable("ApplicationRegistries2.Test_IEnvironmentVariableRegistry_TestName", TestContext.CurrentContext.Test.Name); var testName = ApplicationRegistry.Get <IEnvironmentVariableRegistry>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void Test() { Accessors.CommandlineArgumentsAccessor.OverrideCommandlineArgumentsForUnitTests(new[] { "--ICommandlineRegistry_ListenPortNo=80", "--ICommandlineRegistry_TestName", TestContext.CurrentContext.Test.Name }); var listenPortNo = ApplicationRegistry.Get <ICommandlineRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80)); var testName = ApplicationRegistry.Get <ICommandlineRegistry>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void プレフィックス付きの場合() { Accessors.CommandlineArgumentsAccessor.OverrideCommandlineArgumentsForUnitTests(new[] { "--Test_PortNo", "81", $"--Test_TestName={TestContext.CurrentContext.Test.Name}", }); var listenPortNo = ApplicationRegistry.Get <ICommandlineRegistryWithPrefix>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(81)); var testName = ApplicationRegistry.Get <ICommandlineRegistryWithPrefix>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void 空のプレフィックスの場合はプロパティの名前だけでアクセスする() { Accessors.CommandlineArgumentsAccessor.OverrideCommandlineArgumentsForUnitTests(new[] { "--PortNo", "82", $"--TestName={TestContext.CurrentContext.Test.Name}", }); var listenPortNo = ApplicationRegistry.Get <ICommandlineRegistryWithNoPrefix>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(82)); var testName = ApplicationRegistry.Get <ICommandlineRegistryWithNoPrefix>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void プレフィックス付きの場合はそのキーと名前から取得する() { using (var key = Registry.CurrentUser.CreateSubKey(@"Software\ApplicationRegistries\Temp")) { // ReSharper disable once PossibleNullReferenceException key.SetValue("ListenPortNo", 81, RegistryValueKind.DWord); key.SetValue("Temp", TestContext.CurrentContext.Test.Name, RegistryValueKind.String); } var listenPortNo = ApplicationRegistry.Get <IUserRegistryRegistryWithPrefix>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(81)); var testName = ApplicationRegistry.Get <IUserRegistryRegistryWithPrefix>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void Test() { using (var key = Registry.CurrentUser.CreateSubKey(@"Software\ApplicationRegistries\ApplicationRegistries2.Test\IUserRegistryRegistry")) { // ReSharper disable once PossibleNullReferenceException key.SetValue("ListenPortNo", 80, RegistryValueKind.DWord); key.SetValue("TestName", TestContext.CurrentContext.Test.Name, RegistryValueKind.String); } var listenPortNo = ApplicationRegistry.Get <IUserRegistryRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80)); var testName = ApplicationRegistry.Get <IUserRegistryRegistry>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void キーが指定されない場合はデフォルトの優先順位になる() { var listenPortNo = ApplicationRegistry.Get <IDefaultAttributeRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80), "外部設定がない場合はデフォルト値が使われる"); var xmlContents = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ApplicationRegisties> <IDefaultAttributeRegistry> <ListenPortNo>81</ListenPortNo> </IDefaultAttributeRegistry> </ApplicationRegisties> "; File.WriteAllText(_defaultXmlFilePath, xmlContents, Encoding.UTF8); listenPortNo = ApplicationRegistry.Get <IDefaultAttributeRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(81), "XMLファイルがあればそれに従う"); using (var key = Registry.CurrentUser.CreateSubKey(@"Software\ApplicationRegistries\ApplicationRegistries2.Test\IDefaultAttributeRegistry")) { // ReSharper disable once PossibleNullReferenceException key.SetValue("ListenPortNo", 82, RegistryValueKind.DWord); } listenPortNo = ApplicationRegistry.Get <IDefaultAttributeRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(82), "ユーザーレジストリがあれば、XMLを上書きする"); Environment.SetEnvironmentVariable("ApplicationRegistries2.Test_IDefaultAttributeRegistry_ListenPortNo", "83"); listenPortNo = ApplicationRegistry.Get <IDefaultAttributeRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(83), "環境変数があれば、ユーザーレジストリを上書きする"); Accessors.CommandlineArgumentsAccessor.OverrideCommandlineArgumentsForUnitTests(new[] { "--IDefaultAttributeRegistry_ListenPortNo=84" }); listenPortNo = ApplicationRegistry.Get <IDefaultAttributeRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(84), "コマンドライン引数があれば、環境変数を上書きする"); }
public void Xmlのルートパスを変える() { var xmlContents = $@"<?xml version=""1.0"" encoding=""utf-8"" ?> <XmlFileRegistryTest> <PortNo>82</PortNo> <TestName>{TestContext.CurrentContext.Test.Name}</TestName> </XmlFileRegistryTest> "; File.WriteAllText(_otherXmlFilePath, xmlContents, Encoding.UTF8); var listenPortNo = ApplicationRegistry.Get <IXmlFileRegistryWithOtherFileAndOtherRoot>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(82)); var testName = ApplicationRegistry.Get <IXmlFileRegistryWithOtherFileAndOtherRoot>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void CategoryCanBeFound() { SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP"); NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances(); LobSystemInstance lobSystemInstance = sysInstances["ContosoProductCatalogService"]; NamedEntityDictionary entities = lobSystemInstance.GetEntities(); Entity categoryEntity = entities["Category"]; IEntityInstance categoryInstance = categoryEntity.FindSpecific("0", lobSystemInstance); Assert.AreEqual("Root Category", categoryInstance["Name"]); Assert.AreEqual("0", categoryInstance["CategoryId"]); Assert.AreEqual(string.Empty, categoryInstance["ParentId"]); categoryInstance = categoryEntity.FindSpecific("1", lobSystemInstance); Assert.AreEqual("Medical Supplies", categoryInstance["Name"]); Assert.AreEqual("1", categoryInstance["CategoryId"]); Assert.AreEqual("0", categoryInstance["ParentId"]); }
public void 別のXmlファイルの指定() { var xmlContents = $@"<?xml version=""1.0"" encoding=""utf-8"" ?> <ApplicationRegisties> <IXmlFileRegistryWithOtherFile> <PortNo>81</PortNo> <TestName>{TestContext.CurrentContext.Test.Name}</TestName> </IXmlFileRegistryWithOtherFile> </ApplicationRegisties> "; File.WriteAllText(_otherXmlFilePath, xmlContents, Encoding.UTF8); var listenPortNo = ApplicationRegistry.Get <IXmlFileRegistryWithOtherFile>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(81)); var testName = ApplicationRegistry.Get <IXmlFileRegistryWithOtherFile>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
public void Test() { var xmlContents = $@"<?xml version=""1.0"" encoding=""utf-8"" ?> <ApplicationRegisties> <IXmlFileRegistry> <ListenPortNo>80</ListenPortNo> <TestName>{TestContext.CurrentContext.Test.Name}</TestName> </IXmlFileRegistry> </ApplicationRegisties> "; File.WriteAllText(_defaultXmlFilePath, xmlContents, Encoding.UTF8); var listenPortNo = ApplicationRegistry.Get <IXmlFileRegistry>().ListenPortNo; Assert.That(listenPortNo, Is.EqualTo(80)); var testName = ApplicationRegistry.Get <IXmlFileRegistry>().TestName; Assert.That(testName, Is.EqualTo(TestContext.CurrentContext.Test.Name)); }
internal BdcLobSysInst GetLobSystemInstanceByName(string name) { #if SP12 return(ApplicationRegistry.GetLobSystemInstanceByName(name)); #else if (bdcCat == null) { if (bdcService == null) { bdcService = new BdcService(); } bdcCat = bdcService.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current); } foreach (KeyValuePair <string, BdcLobSysInst> kvp in GetLobSystemInstances()) { if ((kvp.Value != null) && (kvp.Value.Name == name)) { return(kvp.Value); } } return(null); #endif }