public void ShouldInvokeTheCatalogActionForEachFile() { var assemblies = new List<Assembly>(); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => assemblies.Add(a), c => Enumerable.Empty<Lazy<IModule, IModuleMetadata>>(), _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new[] { "c:\test" }, null, null); assemblies.Count.ShouldEqual(2); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Initialize the IOC container and some of the default services var container = new WindsorContainer(); container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel)); container.Register(Component.For<IWindsorContainer>().Instance(container)); container.Register(Component.For<ILog>().ImplementedBy<DwightsLog>()); container.Register(Component.For<IDispatcher>().Instance(new WpfDispatcher(Dispatcher))); container.Register(Component.For<ShellWindow>().LifeStyle.Transient); container.Register(Component.For<IEventAggregator>().ImplementedBy<EventAggregator>().LifeStyle.Singleton); container.Register(Component.For<IRegionManager>().ImplementedBy<RegionManager>().LifeStyle.Singleton); container.Register(Component.For<IApplicationResourcesManager>().ImplementedBy<ApplicationResourcesManager>().LifeStyle.Singleton); // Setup the region adapter mappings var regionMappings = new RegionAdapterMappings(); regionMappings.RegisterMapping(typeof(ContentControl), new ContentControlRegionAdapter()); regionMappings.RegisterMapping(typeof(ItemsControl), new ItemsControlRegionAdapter()); container.Register(Component.For<RegionAdapterMappings>().Instance(regionMappings)); // Setup the main window MainWindow = container.Resolve<ShellWindow>(); MainWindow.Show(); // Define the modules to load var modules = new StaticModuleEnumerator() .AddModule(typeof(SearchModule)) .AddModule(typeof(AdvertisingModule)) .AddModule(typeof(AdventureWorksSearchModule)); // Load the modules var moduleLoader = new ModuleLoader(new WindsorContainerAdapter(container), new TraceLogger()); moduleLoader.Initialize(modules.GetModules()); }
public static void RegisterComponents(Container container) { _moduleLoader= new ModuleLoader(); container.RegisterSingleton(_moduleLoader); string path = System.Web.Hosting.HostingEnvironment.MapPath("~/pickupmodules"); string deploy = System.Web.Hosting.HostingEnvironment.MapPath("~/deploy"); _moduleLoader.Start(container, path, deploy); }
public void ShouldInitializeModulesThatMatchBasedOnName() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new string[0], null, null, "module3"); _mockModule1.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); _mockModule2.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); _mockModule3.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Once()); }
public void ShouldInitializeModulesTheMatchBasedOnName() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (p, c) => _paths.Add(p), _getModules); loader.Load(null, null, null, "module3"); _mockModule1.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); _mockModule2.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); _mockModule3.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Once()); }
public void ShouldInitializeModulesThatMatchOnExtension() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (p, c) => _paths.Add(p), _getModules); loader.Load(null, new string[0], "ext1"); _mockModule1.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Once()); _mockModule2.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); _mockModule3.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Never()); }
/// <summary> /// Creates a new instance of the <see cref="ManageFilesController"/> class. /// </summary> /// <param name="contentItemService"></param> /// <param name="fileResourceService"></param> /// <param name="userService"></param> /// <param name="categoryService"></param> /// <param name="moduleLoader"></param> /// <param name="fileResourceModelValidator"></param> public ManageFilesController(IContentItemService<FileResource> contentItemService, IFileResourceService fileResourceService, IUserService userService, ICategoryService categoryService, ModuleLoader moduleLoader, FileResourceModelValidator fileResourceModelValidator) { _contentItemService = contentItemService; _fileResourceService = fileResourceService; _userService = userService; _categoryService = categoryService; _moduleLoader = moduleLoader; this.ModelValidator = fileResourceModelValidator; }
public void LoadModulesFromXml_Simple() { var catalog = new XmlModuleCatalog("SimpleModuleCatalog.xml"); var loader = new ModuleLoader(); loader.AddModuleCatalog(catalog); loader.ComposeModules(); Assert.IsTrue(loader.Modules.Count() == 2); }
public PagesController(INodeService nodeService, ITemplateService templateService, IFileService fileService, ISectionService sectionService, IModelValidator<Node> modelValidator, ModuleLoader moduleLoader) { _nodeService = nodeService; _templateService = templateService; _fileService = fileService; _sectionService = sectionService; this.ModelValidator = modelValidator; _moduleLoader = moduleLoader; }
public void LoadModulesFromXml_WithIgnore() { var catalog = new XmlModuleCatalog("IgnoreModuleCatalog.xml"); var loader = new ModuleLoader(); loader.AddModuleCatalog(catalog); loader.ComposeModules(); Assert.IsTrue(loader.Modules.Count() == 1); Assert.IsTrue(loader.Modules.First().GetType() == typeof(TestModule2)); }
public SectionsController(ISectionService sectionService, INodeService nodeService, ModuleLoader moduleLoader, SectionModelValidator modelValidator, ITemplateService templateService, IModuleTypeService moduleTypeService) { _sectionService = sectionService; _templateService = templateService; _moduleTypeService = moduleTypeService; _nodeService = nodeService; _moduleLoader = moduleLoader; ModelValidator = modelValidator; }
public void ShouldIgnoreLoadingNativeAssemblies() { _mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.Is<string>(f => f == "managed.dll"))).Returns(true); _mockAssemblyUtility.Setup(a => a.IsManagedAssembly(It.Is<string>(f => f == "native.dll"))).Returns(false); var mockAssemblies = new List<string> {"managed.dll", "native.dll"}; _mockAssemblyResolver.Setup(a => a.GetAssemblyPaths(It.IsAny<string>(), true)).Returns(mockAssemblies); var assemblies = new List<Assembly>(); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => assemblies.Add(a), c => Enumerable.Empty<Lazy<IModule, IModuleMetadata>>(), _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new[] { "c:\test" }, null, null); assemblies.Count.ShouldEqual(1); }
public void ShouldLoadEngineAssemblyByHandIfItsTheOnlyModule() { var path = Path.Combine("c:\\foo", ModuleLoader.DefaultCSharpModules["csharp"]); _mockAssemblyUtility.Setup(x => x.LoadFile(path)); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _logProvider, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new string[0], "c:\\foo", ModuleLoader.DefaultCSharpExtension, "csharp"); _mockAssemblyUtility.Verify(x => x.LoadFile(path), Times.Once()); }
public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) { HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); return (new HGScene( regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim, m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version)); }
static void Main() { var modules = ModuleLoader.LoadModules(); GlobalData.Modules = modules; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new EditorWindow()); Application.Run(new PostFxUIForm()); }
/// <summary> /// Mains the specified arguments. /// </summary> public static void Main(string[] args) { const string applicationName = "ApiInspector"; const string TargetDirectoryPath = @"d:\boa\server\bin\"; ProcessKiller.KillAll(applicationName); ModuleLoader.Load(); new Launcher(TargetDirectoryPath, applicationName, new Tracer()).Start(); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); var unityContainer = UnityConfig.Initialize(); ModuleLoader.LoadContainer(unityContainer, ".\\bin", "Application.Implementations.dll"); ModuleLoader.LoadContainer(unityContainer, ".\\bin", "Data.Persistence.Implementation.dll"); MapperInitializer.ConfigureMappings(); }
public void ShouldResolveModuleAndInitializeSingleModule() { IContainerFacade containerFacade = new MockContainerAdapter(); var service = new ModuleLoader(containerFacade, new MockLogger()); FirstTestModule.wasInitializedOnce = false; var info = new ModuleInfo(typeof(FirstTestModule).Assembly.Location, typeof(FirstTestModule).FullName, "FirstTestModule"); service.Initialize(new[] { info }); Assert.IsTrue(FirstTestModule.wasInitializedOnce); }
static void Main(string[] input) { IContainer container = ModuleLoader.LoadModule(); ILifetimeScope scope = container.BeginLifetimeScope(); IEnumerable <ICommandModule <ICanvas> > commands = scope.Resolve <IEnumerable <ICommandModule <ICanvas> > >(); IDictionary <string, ICommandModule <ICanvas> > commandMap = new Dictionary <string, ICommandModule <ICanvas> >(); foreach (ICommandModule <ICanvas> command in commands) { commandMap.Add(command.Command.ToUpper(), command); } while (true) { Console.Write("Enter Command: "); string[] args = Console.ReadLine().Split(' '); if (args == null || args.Length == 0) { Console.WriteLine("Parameter format is needed"); } if (!commandMap.ContainsKey(args[0])) { Console.WriteLine("ERROR: Unrecognized command " + args[0]); foreach (ICommandModule <ICanvas> command in commands) { Console.WriteLine(command.Command + " " + string.Join(" ", command.Parameters)); Console.WriteLine("\t" + command.Description); } } else { try { ICommandModule <ICanvas> command = commandMap[args[0].ToUpper()]; string[] param = args.Skip(1).Take(args.Length - 1).ToArray(); if (param.Length != command.Parameters.Length) { Console.WriteLine("ERROR: Invalid command syntax"); Console.WriteLine($"Command syntax: {command.Command} {string.Join(" ", command.Parameters)}"); } else { ICanvas canvas = command.Execute(param); canvas.Render(); } } catch (Exception e) { Console.WriteLine(e.Message); } } } }
public void LoadSourceModule() { ModuleLoader moduleLoader = new ModuleLoader(); moduleLoader.LoadModules(@"Modules\Sources"); if (moduleLoader.Modules.Count == 0) { Assert.Fail("No module was loaded"); } }
public static IEngine ConfigureLmsServices(this IServiceCollection services, IConfiguration configuration, IHostEnvironment hostEnvironment) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; CommonHelper.DefaultFileProvider = new LmsFileProvider(hostEnvironment); var engine = EngineContext.Create(); var moduleLoder = new ModuleLoader(); services.TryAddSingleton <IModuleLoader>(moduleLoder); engine.ConfigureServices(services, configuration); return(engine); }
public PackageOverview(ModuleLoader moduleLoader, ObservableCollection <ConnectionConfigurationBase> connections, Package package) { InitializeComponent(); InitializeCommands(); this.moduleLoader = moduleLoader; this.Connections = connections; this.DataContext = this.Package = package; InitializePackageOverview(); }
public void Load(List <FileInfo> inputFiles) { ModuleLoader.AddPrivatePath(GetInputFileNames(inputFiles)); foreach (string file in GetInputFileNames(inputFiles)) { ModuleLoader.LoadModuleFromFile(file); } Load(TypeSystem.Load(ModuleLoader.CreateMetadata())); }
/// <summary>Integrates Unity when the application starts.</summary> public static void Start() { // create an empty container DIContainer = new UnityContainer(); // register all your components with the container here ModuleLoader.LoadModulesFromAssemblies(new UnityModuleRegistrar(DIContainer), AppDomain.CurrentDomain.BaseDirectory, SettingsManager.ModulesPath); // point the WebAPI to use the container GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(DIContainer); }
public void ShouldLoadSampleModule() { var map = new DependencyMap(); var sampleModule = new SampleModule(); var loader = new ModuleLoader(map); loader.LoadModule(sampleModule); Assert.IsTrue(sampleModule.Invoked); Assert.IsTrue(map.Contains(typeof(IList <int>))); }
public void FailWhenDependingOnMissingModule() { //string assembly = CompilerHelper.GenerateDynamicModule("ModuleK", null, "ModuleL"); // ModuleInfo module = new ModuleInfo(assembly, "ModuleK.TestsModules.ModuleKClass", "ModuleK", "ModuleL"); var module = new ModuleInfo(typeof(MockModuleA).Assembly.FullName, typeof(MockModuleA).FullName, "MockModuleA", "MissingModule"); ModuleLoader loader = new ModuleLoader(new MockContainerAdapter(), new MockLogger()); loader.Initialize(new[] { module }); }
private static int Main(string[] args) { try { var context = new ModuleInitializationContextInternal(args); var modules = ModuleLoader.LoadModules(context); ShowWindow(modules, context); return(0); } catch (Exception e) { MessageBox.Show(e.Message, LanguageData.Current.MainWindow_OFD_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return(e.HResult); } }
private void DynamicAnalysisStep(object prms) { Step step = (Step)prms; try { LogManager.WriteLine(String.Format("Dynamic Analysis: Step started ({0} {1})", step.Path, step.Args), LogManager.EVerboseLevel.Debug); if (step.WaitInit > 0) { Thread.Sleep(step.WaitInit); } vmControlMutex.WaitOne(); vmcontrol.StartVMProcess(step.Path, ParseLine(step.Args), true, step.WaitExit, vmControlMutex); if (!string.IsNullOrEmpty(step.LogPath)) { string logHostPath = Environment.GetEnvironmentVariable("TEMP") + "\\ViniSandbox\\" + Guid.NewGuid(); Thread.Sleep(2000); vmControlMutex.WaitOne(); vmcontrol.CopyFileFromGuest(step.LogPath, logHostPath); vmControlMutex.ReleaseMutex(); if (step.LogAll) { objExtracted(new result_file() { program_name = step.LogAllName, data = File.ReadAllBytes(logHostPath) }); } if (step.LogHandlerAssembly != "" && step.LogHandlerClass != "") { LogHandler logHandler = ModuleLoader <LogHandler> .LoadModule(step.LogHandlerAssembly, step.LogHandlerClass); //ModuleLoader<ILogHandler>.LoadModule(step.LogHandlerAssembly, step.LogHandlerClass); logHandler.ParseLog(logHostPath, objExtracted); } File.Delete(logHostPath); LogManager.WriteLine(String.Format("Dynamic Analysis: Step ended ({0} {1})", step.Path, step.Args), LogManager.EVerboseLevel.Debug); } } catch (Exception ex) { try { vmControlMutex.ReleaseMutex(); } catch (Exception) { } LogManager.WriteLine(String.Format("Dynamic Analysis: Step error ({0} {1}) - {2}", step.Path, step.Args, ex.ToString()), LogManager.EVerboseLevel.Error); Thread.CurrentThread.Abort(); } }
private static void PreparePatches() { ColoredOutput.WriteInformation("Preparing patches..."); _gameAssemblyDefinition = ModuleLoader.LoadGameModule(_gameAssemblyFilename); if (!string.IsNullOrEmpty(_bootstrapAssemblyFilename)) { _bootstrapAssemblyDefinition = ModuleLoader.LoadBootstrapModule(_bootstrapAssemblyFilename); } _patcher = new Patcher(_bootstrapAssemblyDefinition, _gameAssemblyDefinition); _patcher.AddPatch(new CentrifugeInitPatch()); }
private static void Init() { var container = UnityContainerProvider.Initialize(); ModuleLoader.Initialize(container); var catalog = new ModuleCatalog(); container.RegisterInstance <IModuleCatalog>(catalog, new ContainerControlledLifetimeManager()); ModuleLoader.Run(container); FactoryDbContext.InitDatabase(false); }
public void LibraryLoadTest() { var modulePath = Path.Combine(Directory.GetCurrentDirectory(), "MockTest.dll"); using (var moduleLoader = new ModuleLoader(modulePath)) { Assert.True(moduleLoader.GetBATest() != null); Assert.True(moduleLoader.GetBATest() != null); Assert.True(moduleLoader.GetHandTest() != null); Assert.True(moduleLoader.GetLSTMTest() != null); } }
public static IMvcBuilder AddModules(this IMvcBuilder services, params string[] modulePaths) { var loader = new ModuleLoader(modulePaths); loader.Configure(services.Services); foreach (var module in loader.GetModules()) { services.AddApplicationPart(module.GetType().Assembly); } return(services); }
public void InitializationExceptionsAreWrapped() { Assembly asm = CompilerHelper.CompileFileAndLoadAssembly("Microsoft.Practices.Composite.Tests.Mocks.Modules.MockModuleThrowingException.cs", @".\MocksModulesThwrowing\MockModuleThrowingException.dll"); ModuleLoader loader = new ModuleLoader(new MockContainerAdapter(), new MockLogger()); ModuleInfo info = new ModuleInfo(asm.CodeBase.Replace(@"file:///", ""), "Microsoft.Practices.Composite.Tests.Mocks.Modules.MockModuleThrowingException", "MockModuleThrowingException"); loader.Initialize(new[] { info }); }
static void Main() { ModuleLoader moduleLoader = new ModuleLoader( Orion.Core.Module.ModuleAccessMode.Streaming, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.None) + @"\Orion\" ); using (var game = new Game1(moduleLoader, new SQLite.Net.Platform.Win32.SQLitePlatformWin32())) { game.Content.RootDirectory = "Data"; game.Run(); } }
public static IServiceCollection AddModules(this IServiceCollection services) { // load internal/core modules ModuleLoader.LoadInternalModules(); // add modules services ModuleLoader.ConfigureServices(services); // add module container builder services.AddSingleton <IModulesHost, ModulesHost>(); return(services); }
public static IHostBuilder UseBootstrapperFactory(this IHostBuilder builder, IAssemblyCatalog assemblyCatalog, BootstrapperOptions options, IEnumerable <ModuleMetadataValidator> validators = null) { return(builder.UseServiceProviderFactory(context => { var moduleLoader = new ModuleLoader(validators); options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.HostingEnvironment)); options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.Configuration)); return BootstrapperFactory.Create(moduleLoader, assemblyCatalog, options); })); }
public VideoVideoModel(string videoUrl, IVideoFilter[] filters) { this.VideoUrl = videoUrl; _videoFilters = filters; _playCommand = new RelayCommand(_ => Play()); _pauseCommand = new RelayCommand(_ => Stop()); _videoReader = ModuleLoader.Load <IVideoReader>(); _backgroundWorker = new BackgroundWorker() { WorkerSupportsCancellation = true }; _backgroundWorker.DoWork += StartBackgroundJob; }
public HGScene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader, dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) { m_log.Info("[HGScene]: Starting HGScene."); m_assMapper = new HGAssetMapper(this); EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; }
public void ExcludeAssembly_ForFile_ReturnsExpected(string file, bool expected) { // arrange var loggerFactory = LoggerFactory.Create( builder => builder.AddConsole(options => options.FormatterName = "systemd")); var loader = new ModuleLoader(loggerFactory.CreateLogger <ModuleLoader>()); // act var result = loader.ExcludeAssembly(file); // assert Assert.AreEqual(expected, result); }
public static IUnityContainer Configure() { var container = new UnityContainer(); //register dependency injection //container // .RegisterType<Interface1, Class1>(); //load libraries from given folder ModuleLoader.LoadContainer(container, ".\\", "ClassLibrary1.dll"); return(container); }
private static void DeployModeSetup() { DeployParameters dparams = ModuleLoader.GetDeployParametsers(typeof(Program), "Mode=KaoHsiung"); if (dparams["Mode"].ToUpper() == "KaoHsiung".ToUpper()) { Mode = ModuleMode.KaoHsiung; //高雄。 } else { Mode = ModuleMode.HsinChu; //新竹。 } }
/// <summary> /// F*****g MusicPlayer must be in MainView /// </summary> private void InitializeBackgroundMusic() { m_Player = new MikMod(); ModDriver.Mode = (ushort)(ModDriver.Mode | SharpMikCommon.DMODE_NOISEREDUCTION); m_Player.Init <NaudioDriver>(""); //TODO: Modify to stream m_Mod = ModuleLoader.Load("Resources\\music.xm"); #if !DEBUG m_Player.Play(m_Mod); #endif }
public void LoadModulesFromXml_WithParameters() { var catalog = new XmlModuleCatalog("ParameterizedModuleCatalog.xml"); var loader = new ModuleLoader(); loader.AddModuleCatalog(catalog); loader.ComposeModules(); Assert.IsTrue(loader.Modules.Count() == 1); Assert.IsTrue(loader.Modules.First().GetType() == typeof(TestModule1)); var module = loader.Modules.First() as TestModule1; Assert.IsTrue(module.BooleanParameter == true); Assert.IsTrue(module.StringParameter == "Test value"); }
private IContainer CreateContainer() { var builder = new ContainerBuilder(); var loader = new ModuleLoader(); loader.LoadAdminModules(builder); builder.RegisterType<Mediator>().As<IMediator>().SingleInstance(); builder.RegisterType<MainWindow>(); builder.RegisterType<MainWindowViewModel>(); builder.RegisterType<DiskAccessor>().As<IDiskAccessor>().SingleInstance(); builder.RegisterType<ConfigurationCaretaker>(); return builder.Build(); }
public void ShouldInvokeTheCatalogActionForEachFile() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (p, c) => _paths.Add(p), c => Enumerable.Empty<Lazy<IModule, IModuleMetadata>>()); loader.Load(null, "c:\test", null); _paths.Count.ShouldEqual(2); }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) { m_config = config; Random random = new Random(); m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; CommsManager = commsMan; m_sceneGridService = sceneGridService; m_storageManager = storeManager; m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; // Load region settings m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); } //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); m_sceneGraph = new SceneGraph(this, m_regInfo); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; StatsReporter.SetObjectCapacity(objectCapacity); m_simulatorVersion = simulatorVersion + " (OS " + Util.GetOperatingSystemInformation() + ")" + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); try { // Region config overrides global config // IConfig startupConfig = m_config.Configs["Startup"]; //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); m_maxPrimsPerFrame = startupConfig.GetInt("MaxPrimsPerFrame", 200); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) { PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); } catch { m_log.Warn("[SCENE]: Failed to load StartupConfig"); } }
public void ShouldResolvePathsFromTheAssemblyResolver() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (p, c) => { }, c => Enumerable.Empty<Lazy<IModule, IModuleMetadata>>()); loader.Load(null, "c:\test", null); _mockAssemblyResolver.Verify(r => r.GetAssemblyPaths("c:\test", string.Empty)); }
public void ShouldNotLoadEngineAssemblyByHandIfItsTheOnlyModuleButExtensionIsNotDefault() { var path = Path.Combine("c:\\foo", ModuleLoader.DefaultCSharpModules["roslyn"]); _mockAssemblyUtility.Setup(x => x.LoadFile(path)); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new string[0], "c:\\foo", ".fsx", "roslyn"); _mockAssemblyUtility.Verify(x => x.LoadFile(It.IsAny<string>()), Times.Never); }
public ModulesController(IModuleTypeService moduleTypeService, ModuleLoader moduleLoader, ISectionService sectionService) { _moduleTypeService = moduleTypeService; _sectionService = sectionService; _moduleLoader = moduleLoader; }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, SceneCommunicationService sceneGridService, StorageManager storeManager, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) { m_config = config; Random random = new Random(); BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- northBorder.CrossDirection = Cardinals.N; NorthBorders.Add(northBorder); Border southBorder = new Border(); southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> southBorder.CrossDirection = Cardinals.S; SouthBorders.Add(southBorder); Border eastBorder = new Border(); eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- eastBorder.CrossDirection = Cardinals.E; EastBorders.Add(eastBorder); Border westBorder = new Border(); westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> westBorder.CrossDirection = Cardinals.W; WestBorders.Add(westBorder); BordersLocked = false; m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; m_sceneGridService = sceneGridService; m_storageManager = storeManager; m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; #region Region Settings // Load region settings m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); if (m_regInfo.EstateSettings.EstateID == 0) // No record at all { MainConsole.Instance.Output("Your region is not part of an estate."); while (true) { string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"}); if (response == "no") { // Create a new estate m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); m_regInfo.EstateSettings.Save(); break; } else { response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); if (response == "None") continue; List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response); if (estateIDs.Count < 1) { MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); continue; } int estateID = estateIDs[0]; m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) break; MainConsole.Instance.Output("Joining the estate failed. Please try again."); } } } } #endregion Region Settings MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", "reload estate", "Reload the estate data", HandleReloadEstate); //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); m_sceneGraph = new SceneGraph(this, m_regInfo); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; StatsReporter.SetObjectCapacity(objectCapacity); // Old /* m_simulatorVersion = simulatorVersion + " (OS " + Util.GetOperatingSystemInformation() + ")" + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); */ m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; #region Region Config try { // Region config overrides global config // IConfig startupConfig = m_config.Configs["Startup"]; //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) { PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); #region BinaryStats try { IConfig statConfig = m_config.Configs["Statistics.Binary"]; if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) { if (statConfig.Contains("collect_region_stats")) { if (statConfig.GetBoolean("collect_region_stats")) { // if enabled, add us to the event. If not enabled, I won't get called StatsReporter.OnSendStatsResult += LogSimStats; } } if (statConfig.Contains("region_stats_period_seconds")) { m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); } if (statConfig.Contains("stats_dir")) { m_statsDir = statConfig.GetString("stats_dir"); } } } catch { // if it doesn't work, we don't collect anything } #endregion BinaryStats } catch { m_log.Warn("[SCENE]: Failed to load StartupConfig"); } #endregion Region Config #region Interest Management if (m_config != null) { IConfig interestConfig = m_config.Configs["InterestManagement"]; if (interestConfig != null) { string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); try { m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } catch (Exception) { m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); m_priorityScheme = UpdatePrioritizationSchemes.Time; } m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } } m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme"); #endregion Interest Management }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) { m_config = config; Random random = new Random(); BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- northBorder.CrossDirection = Cardinals.N; NorthBorders.Add(northBorder); Border southBorder = new Border(); southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> southBorder.CrossDirection = Cardinals.S; SouthBorders.Add(southBorder); Border eastBorder = new Border(); eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- eastBorder.CrossDirection = Cardinals.E; EastBorders.Add(eastBorder); Border westBorder = new Border(); westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> westBorder.CrossDirection = Cardinals.W; WestBorders.Add(westBorder); BordersLocked = false; m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; m_sceneGridService = sceneGridService; m_SimulationDataService = simDataService; m_EstateDataService = estateDataService; m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; #region Region Settings // Load region settings m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); if (estateDataService != null) m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); #endregion Region Settings MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", "reload estate", "Reload the estate data", HandleReloadEstate); //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(simDataService.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); m_sceneGraph = new SceneGraph(this, m_regInfo); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; // Old /* m_simulatorVersion = simulatorVersion + " (OS " + Util.GetOperatingSystemInformation() + ")" + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); */ m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; #region Region Config try { // Region config overrides global config // IConfig startupConfig = m_config.Configs["Startup"]; //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) { PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); if (m_generateMaptiles) { int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); if (maptileRefresh != 0) { m_mapGenerationTimer.Interval = maptileRefresh * 1000; m_mapGenerationTimer.Elapsed += RegenerateMaptile; m_mapGenerationTimer.AutoReset = true; m_mapGenerationTimer.Start(); } } else { string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); UUID tileID; if (UUID.TryParse(tile, out tileID)) { RegionInfo.RegionSettings.TerrainImageID = tileID; } } Random rnd = new Random(); GenerationSeed = startupConfig.GetLong("TerragenSeed", (long)rnd.Next()); } catch { m_log.Warn("[SCENE]: Failed to load StartupConfig"); } #endregion Region Config #region Interest Management if (m_config != null) { IConfig interestConfig = m_config.Configs["InterestManagement"]; if (interestConfig != null) { string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); try { m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } catch (Exception) { m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); m_priorityScheme = UpdatePrioritizationSchemes.Time; } m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } } m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme"); #endregion Interest Management }
public void ShouldLoadEngineModuleFromFile() { _mockAssemblyUtility.Setup(x => x.LoadFile(It.IsAny<string>())).Returns(typeof (DummyModule).Assembly); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); var config = new ModuleConfiguration(true, string.Empty, false, LogLevel.Debug, true, new Dictionary<Type, object> {{typeof (string), "not loaded"}}); loader.Load(config, new string[0], "c:\\foo", ModuleLoader.DefaultCSharpExtension, "roslyn"); config.Overrides[typeof(string)].ShouldEqual("module loaded"); }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, StorageManager storeManager, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) { m_config = config; Random random = new Random(); BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- northBorder.CrossDirection = Cardinals.N; NorthBorders.Add(northBorder); Border southBorder = new Border(); southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> southBorder.CrossDirection = Cardinals.S; SouthBorders.Add(southBorder); Border eastBorder = new Border(); eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- eastBorder.CrossDirection = Cardinals.E; EastBorders.Add(eastBorder); Border westBorder = new Border(); westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> westBorder.CrossDirection = Cardinals.W; WestBorders.Add(westBorder); BordersLocked = false; m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; CommsManager = commsMan; m_sceneGridService = sceneGridService; m_storageManager = storeManager; m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; // Load region settings m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); } //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); m_sceneGraph = new SceneGraph(this, m_regInfo); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; StatsReporter.SetObjectCapacity(objectCapacity); // Old /* m_simulatorVersion = simulatorVersion + " (OS " + Util.GetOperatingSystemInformation() + ")" + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); */ m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; try { // Region config overrides global config // IConfig startupConfig = m_config.Configs["Startup"]; // Should we try to run loops synchronously or asynchronously? m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false); //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) { PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); IConfig interest_management_config = m_config.Configs["InterestManagement"]; if (interest_management_config != null) { string update_prioritization_scheme = interest_management_config.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); switch (update_prioritization_scheme) { case "time": m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; break; case "distance": m_update_prioritization_scheme = UpdatePrioritizationSchemes.Distance; break; case "simpleangulardistance": m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance; break; case "frontback": m_update_prioritization_scheme = UpdatePrioritizationSchemes.FrontBack; break; default: m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time"); m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; break; } m_reprioritization_enabled = interest_management_config.GetBoolean("ReprioritizationEnabled", true); m_reprioritization_interval = interest_management_config.GetDouble("ReprioritizationInterval", 5000.0); m_root_reprioritization_distance = interest_management_config.GetDouble("RootReprioritizationDistance", 10.0); m_child_reprioritization_distance = interest_management_config.GetDouble("ChildReprioritizationDistance", 20.0); } m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); #region BinaryStats try { IConfig statConfig = m_config.Configs["Statistics.Binary"]; if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) { if (statConfig.Contains("collect_region_stats")) { if (statConfig.GetBoolean("collect_region_stats")) { // if enabled, add us to the event. If not enabled, I won't get called StatsReporter.OnSendStatsResult += LogSimStats; } } if (statConfig.Contains("region_stats_period_seconds")) { m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); } if (statConfig.Contains("stats_dir")) { m_statsDir = statConfig.GetString("stats_dir"); } } } catch { // if it doesn't work, we don't collect anything } #endregion BinaryStats } catch { m_log.Warn("[SCENE]: Failed to load StartupConfig"); } }
public void ShouldResolvePathsFromTheAssemblyResolver() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (p, c) => { }, c => Enumerable.Empty<Lazy<IModule, IModuleMetadata>>(), _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new[] { "c:\test" }, null, null); _mockAssemblyResolver.Verify(r => r.GetAssemblyPaths("c:\test", true)); }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, ModuleLoader moduleLoader, bool dumpAssetsToFile, IConfigSource config, string simulatorVersion) : this(regInfo) { m_config = config; Random random = new Random(); m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; m_sceneGridService = sceneGridService; m_SimulationDataService = simDataService; m_EstateDataService = estateDataService; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; m_asyncInventorySender = new AsyncInventorySender(this); #region Region Settings // Load region settings // LoadRegionSettings creates new region settings in persistence if they don't already exist for this region. // However, in this case, the default textures are not set in memory properly, so we need to do it here and // resave. // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID); bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1; updatedTerrainTextures = true; } if (rs.TerrainTexture2 == UUID.Zero) { rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2; updatedTerrainTextures = true; } if (rs.TerrainTexture3 == UUID.Zero) { rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3; updatedTerrainTextures = true; } if (rs.TerrainTexture4 == UUID.Zero) { rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4; updatedTerrainTextures = true; } if (updatedTerrainTextures) rs.Save(); m_regInfo.RegionSettings = rs; if (estateDataService != null) m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); #endregion Region Settings MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", "reload estate", "Reload the estate data", HandleReloadEstate); MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", "delete object owner <UUID>", "Delete object by owner", HandleDeleteObject); MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", "delete object creator <UUID>", "Delete object by creator", HandleDeleteObject); MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", "delete object uuid <UUID>", "Delete object by uuid", HandleDeleteObject); MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", "delete object name <name>", "Delete object by name", HandleDeleteObject); MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", "delete object outside", "Delete all objects outside boundaries", HandleDeleteObject); //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(simDataService.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); m_sceneGraph = new SceneGraph(this); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; #region Region Config try { // Region config overrides global config // IConfig startupConfig = m_config.Configs["Startup"]; m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); if (!m_useBackup) m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); float fps = startupConfig.GetFloat("SimulationFPS", 45f); m_simframetime = 1000.0f / fps; // limit it from 10 to 50fps if (m_simframetime < 22.0) m_simframetime = 22.0f; else if (m_simframetime > 100f) m_simframetime = 100f; fps = startupConfig.GetFloat("PhysicsSimulationFPS", 45f); // limit it from 2fps to SimulationFPS m_simphysframetime = 1000.0f / fps; if (m_simphysframetime <= m_simframetime) m_simphysframetime = m_simframetime - 2; // the 2 is bc of my bad coding in timing control else if (m_simphysframetime > 500f) m_simphysframetime = 500f; IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) { PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); if (m_generateMaptiles) { int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); if (maptileRefresh != 0) { m_mapGenerationTimer.Interval = maptileRefresh * 1000; m_mapGenerationTimer.Elapsed += RegenerateMaptile; m_mapGenerationTimer.AutoReset = true; m_mapGenerationTimer.Start(); } } else { string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); UUID tileID; if (UUID.TryParse(tile, out tileID)) { RegionInfo.RegionSettings.TerrainImageID = tileID; } } m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); } catch { m_log.Warn("[SCENE]: Failed to load StartupConfig"); } #endregion Region Config #region Interest Management if (m_config != null) { IConfig interestConfig = m_config.Configs["InterestManagement"]; if (interestConfig != null) { string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); try { m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } catch (Exception) { m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); m_priorityScheme = UpdatePrioritizationSchemes.Time; } m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } } m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme"); #endregion Interest Management StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; }
public void ShouldInitializeModulesThatAreSetToAutoload() { var loader = new ModuleLoader(_mockAssemblyResolver.Object, _mockLogger.Object, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new string[0], null, null); _mockModule4.Verify(m => m.Initialize(It.IsAny<IModuleConfiguration>()), Times.Once()); }
public void ShouldLoadEngineAssemblyByHandIfItsTheOnlyModule() { var path = Path.Combine("c:\\foo", ModuleLoader.DefaultCSharpModules["roslyn"]); _mockAssemblyUtility.Setup(x => x.LoadFile(path)); var loader = new ModuleLoader(_mockAssemblyResolver.Object, _logProvider, (a, c) => { }, _getModules, _mockFileSystem.Object, _mockAssemblyUtility.Object); loader.Load(null, new string[0], "c:\\foo", ModuleLoader.DefaultCSharpExtension, "roslyn"); _mockAssemblyUtility.Verify(x => x.LoadFile(path), Times.Once()); }
public Scene(RegionInfo regInfo, AgentCircuitManager authen, SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, ModuleLoader moduleLoader, bool dumpAssetsToFile, IConfigSource config, string simulatorVersion) : this(regInfo) { m_config = config; MinFrameTime = 0.089f; MinMaintenanceTime = 1; Random random = new Random(); m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); m_moduleLoader = moduleLoader; m_authenticateHandler = authen; m_sceneGridService = sceneGridService; m_SimulationDataService = simDataService; m_EstateDataService = estateDataService; m_regionHandle = RegionInfo.RegionHandle; m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); m_asyncSceneObjectDeleter.Enabled = true; m_asyncInventorySender = new AsyncInventorySender(this); #region Region Settings // Load region settings // LoadRegionSettings creates new region settings in persistence if they don't already exist for this region. // However, in this case, the default textures are not set in memory properly, so we need to do it here and // resave. // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID); bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1; updatedTerrainTextures = true; } if (rs.TerrainTexture2 == UUID.Zero) { rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2; updatedTerrainTextures = true; } if (rs.TerrainTexture3 == UUID.Zero) { rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3; updatedTerrainTextures = true; } if (rs.TerrainTexture4 == UUID.Zero) { rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4; updatedTerrainTextures = true; } if (updatedTerrainTextures) rs.Save(); RegionInfo.RegionSettings = rs; if (estateDataService != null) RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); #endregion Region Settings //Bind Storage Manager functions to some land manager functions for this scene EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(simDataService.StoreLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); m_sceneGraph = new SceneGraph(this); // If the scene graph has an Unrecoverable error, restart this sim. // Currently the only thing that causes it to happen is two kinds of specific // Physics based crashes. // // Out of memory // Operating system has killed the plugin m_sceneGraph.UnRecoverableError += RestartNow; RegisterDefaultSceneEvents(); DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; #region Region Config // Region config overrides global config // if (m_config.Configs["Startup"] != null) { IConfig startupConfig = m_config.Configs["Startup"]; StartDisabled = startupConfig.GetBoolean("StartDisabled", false); m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); if (!m_useBackup) m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); if (RegionInfo.NonphysPrimMin > 0) { m_minNonphys = RegionInfo.NonphysPrimMin; } m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); if (RegionInfo.PhysPrimMin > 0) { m_minPhys = RegionInfo.PhysPrimMin; } m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; } // Here, if clamping is requested in either global or // local config, it will be used // m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); if (RegionInfo.ClampPrimSize) { m_clampPrimSize = true; } m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); if (RegionInfo.LinksetCapacity > 0) { m_linksetCapacity = RegionInfo.LinksetCapacity; } m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); m_dontPersistBefore = startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); m_dontPersistBefore *= 10000000; m_persistAfter = startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); if (m_generateMaptiles) { int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); if (maptileRefresh != 0) { m_mapGenerationTimer.Interval = maptileRefresh * 1000; m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; m_mapGenerationTimer.AutoReset = true; m_mapGenerationTimer.Start(); } } else { string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); UUID tileID; if (UUID.TryParse(tile, out tileID)) { RegionInfo.RegionSettings.TerrainImageID = tileID; } } string grant = startupConfig.GetString("AllowedClients", String.Empty); if (grant.Length > 0) { foreach (string viewer in grant.Split('|')) { m_AllowedViewers.Add(viewer.Trim().ToLower()); } } grant = startupConfig.GetString("BannedClients", String.Empty); if (grant.Length > 0) { foreach (string viewer in grant.Split('|')) { m_BannedViewers.Add(viewer.Trim().ToLower()); } } MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); } // FIXME: Ultimately this should be in a module. SendPeriodicAppearanceUpdates = true; IConfig appearanceConfig = m_config.Configs["Appearance"]; if (appearanceConfig != null) { SendPeriodicAppearanceUpdates = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates); } #endregion Region Config #region Interest Management IConfig interestConfig = m_config.Configs["InterestManagement"]; if (interestConfig != null) { string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); try { m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } catch (Exception) { m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); m_priorityScheme = UpdatePrioritizationSchemes.Time; } m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme); #endregion Interest Management StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; }
public ChatServer(ChatServerSettings settings, ModuleLoader loader, AuthServer authServer, LanguageTags languageTags) : base(settings) { this.modules = loader.ActiveModules; this.authServer = authServer; this.loader = loader; this.languageTags = languageTags; #region BandwidthLoad //Attempt to load the bandwidth monitor in the constructor. It's not a big deal if it doesn't load //though, so just fall back to the nice default empty monitor if we fail. BandwidthMonitor tempMonitor; if (MySerialize.LoadObject<BandwidthMonitor>(SavePath(BandwidthFile), out tempMonitor)) { Bandwidth = tempMonitor; Log("Loaded bandwidth data from file", MyExtensions.Logging.LogLevel.Debug); } else { Log("Couldn't load bandwidth data! Defaulting to empty bandwidth", MyExtensions.Logging.LogLevel.Error); } #endregion #region UserLoad //Attempt to load the users in the constructor. Again, not a big deal if it doesn't load. Dictionary<int, User> tempUsers; if (MySerialize.LoadObject<Dictionary<int, User>>(SavePath(UserFile), out tempUsers)) { users = tempUsers; if(users.Count > 0) { UserSession.SetNextID(users.Max(x => x.Value.MaxSessionID) + 1); }; Log("Loaded user data from file", MyExtensions.Logging.LogLevel.Debug); } else { Log("Couldn't load user data! Defaulting to empty user dictionary", MyExtensions.Logging.LogLevel.Error); } #endregion #region MessageLoad //Attempt to load the messages in the constructor. Again, not a big deal if it doesn't load. List<UserMessageJSONObject> tempMessages; if (MySerialize.LoadObject<List<UserMessageJSONObject>>(SavePath(MessageFile), out tempMessages)) { messages = tempMessages; UserMessageJSONObject.FindNextID(messages); PMRoom.FindNextID(messages.Select(x => x.tag).ToList()); Log("Loaded messages from file", MyExtensions.Logging.LogLevel.Debug); } else { Log("Couldn't load messages! Defaulting to empty message list", MyExtensions.Logging.LogLevel.Error); } #endregion #region HistoryLoad Dictionary<string, List<UserMessageJSONObject>> tempHistory; if (MySerialize.LoadObject<Dictionary<string, List<UserMessageJSONObject>>>(SavePath(HistoryFile), out tempHistory)) { history = tempHistory; PMRoom.FindNextID(history.SelectMany(x => x.Value.Select(y => y.tag)).ToList()); Log("Loaded history from file", MyExtensions.Logging.LogLevel.Debug); } else { Log("Couldn't load history! Defaulting to empty history", MyExtensions.Logging.LogLevel.Error); } #endregion #region RoomLoad Dictionary<string, PMRoom> tempRooms; if (MySerialize.LoadObject<Dictionary<string, PMRoom>>(SavePath(RoomFile), out tempRooms)) { rooms = tempRooms; PMRoom.FindNextID(rooms.Select(x => x.Key).ToList()); Log("Loaded rooms from file", MyExtensions.Logging.LogLevel.Debug); } else { Log("Couldn't load rooms! Defaulting to no rooms", MyExtensions.Logging.LogLevel.Error); } #endregion //now set up the save file timer saveTimer = new System.Timers.Timer(settings.SaveInterval.TotalMilliseconds);//1000 * managerOptions.GetAsType<int>("saveInterval")); saveTimer.Elapsed += SaveTimerElapsed; saveTimer.Start(); if (settings.MonitorThreads) { threadMonitorTimer = new System.Timers.Timer(1000); threadMonitorTimer.Elapsed += MonitorThreadsElapsed; threadMonitorTimer.Start(); } }