public ModuleProviderCLPair( ClassLoader classLoader, ModuleProvider moduleProvider) { ClassLoader = classLoader; ModuleProvider = moduleProvider; }
protected virtual bool IsStorageModuleAllowed(string storageModuleName) { var allowedStorageModules = new List <string> { "forum", "photo", "bookmarking", "wiki", "files", "crm", "projects", "logo", "fckuploaders", "talk", "mailaggregator" }; if (!allowedStorageModules.Contains(storageModuleName)) { return(false); } IModuleSpecifics moduleSpecifics = ModuleProvider.GetByStorageModule(storageModuleName); return(moduleSpecifics == null || !IgnoredModules.Contains(moduleSpecifics.ModuleName)); }
static ModuleLoader() { var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly()?.Location); var assemblyThemePath = Path.Combine(@$ "{assemblyPath}", "Themes/MudBlazor"); List <Assembly> allAssemblies = new(); if (Directory.Exists(assemblyThemePath)) { foreach (var dll in Directory.GetFiles(assemblyThemePath, "*.dll")) { allAssemblies.Add(AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(dll)))); } } var assemblyModulesPath = Path.Combine(@$ "{assemblyPath}", "Modules"); if (Directory.Exists(assemblyModulesPath)) { foreach (var dll in Directory.GetFiles(assemblyModulesPath, "*.dll")) { allAssemblies.Add(AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(dll)))); } } ModuleProvider.Init(allAssemblies); }
public void NetVersionTest() { var netModule = Substitute.For <INetModule>(); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); netModule.net_version().ReturnsForAnyArgs(x => new ResultWrapper <string> { Result = new Result { ResultType = ResultType.Success }, Data = "1" }); var shhModule = Substitute.For <IShhModule>(); var nethmModule = Substitute.For <INethmModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule, nethmModule); _jsonRpcService = new JsonRpcService(moduleProvider, _configurationProvider, _logManager); var request = GetJsonRequest("net_version", null); var response = _jsonRpcService.SendRequest(request); Assert.AreEqual(response.Id, request.Id); Assert.AreEqual(response.Result, "1"); Assert.IsNull(response.Error); Assert.AreEqual(_configurationProvider.GetConfig <IJsonRpcConfig>().JsonRpcVersion, response.Jsonrpc); }
public void NetPeerCountTest() { var netModule = Substitute.For <INetModule>(); netModule.net_peerCount().ReturnsForAnyArgs(x => new ResultWrapper <Quantity> { Result = new Result { ResultType = ResultType.Success }, Data = new Quantity(2) }); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); var shhModule = Substitute.For <IShhModule>(); var nethmModule = Substitute.For <INethmModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule, nethmModule); _jsonRpcService = new JsonRpcService(moduleProvider, _configurationProvider, _logManager); var requestJson = GetJsonRequest("net_peerCount", null); var response = _jsonRpcService.SendRequest(requestJson); var quantity = new Quantity(); quantity.FromJson(response.Result.ToString()); Assert.AreEqual(quantity.GetValue(), new BigInteger(2)); }
public void GetBlockByNumberTest() { var netModule = Substitute.For <INetModule>(); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); ethModule.eth_getBlockByNumber(Arg.Any <BlockParameter>(), true).ReturnsForAnyArgs(x => new ResultWrapper <Block> { Result = new Result { ResultType = ResultType.Success }, Data = new Block { Number = new Quantity(2) } }); var shhModule = Substitute.For <IShhModule>(); var nethmModule = Substitute.For <INethmModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule, nethmModule); _jsonRpcService = new JsonRpcService(moduleProvider, _configurationProvider, _logManager); var request = GetJsonRequest("eth_getBlockByNumber", new[] { "0x1b4", "true" }); var response = _jsonRpcService.SendRequest(request); Assert.IsTrue(response.Result.ToString().Contains("0x02")); }
public void GetWorkTest() { var netModule = Substitute.For <INetModule>(); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); ethModule.eth_getWork().ReturnsForAnyArgs(x => new ResultWrapper <IEnumerable <Data> > { Result = new Result { ResultType = ResultType.Success }, Data = new [] { new Data("aa"), new Data("01") } }); var shhModule = Substitute.For <IShhModule>(); var nethmModule = Substitute.For <INethmModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule, nethmModule); _jsonRpcService = new JsonRpcService(moduleProvider, _configurationProvider, _logManager); var request = GetJsonRequest("eth_getWork", null); var response = _jsonRpcService.SendRequest(request); Assert.Contains("0xaa", (List <object>)response.Result); Assert.Contains("0x01", (List <object>)response.Result); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); //TODO see what oqtane does var baseModule = new Theme.Material.Module(); var adminModule = new Theme.Material.Admin.Module(); var demoModule = new Theme.Material.Demo.Module(); Assembly[] allAssemblies = AppDomain.CurrentDomain.GetAssemblies(); ModuleProvider.Init(allAssemblies); builder.RootComponents.AddRange(new[] { ModuleProvider.RootComponentMapping }); builder.Services.AddLocalization(); builder.Services.AddDataProtection().SetApplicationName(nameof(BlazorBoilerplate)); builder.Services.AddProtectedBrowserStorage(); builder.Services.AddSingleton(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddAuthorizationCore(config => { config.AddPolicy(Policies.IsAdmin, Policies.IsAdminPolicy()); config.AddPolicy(Policies.IsUser, Policies.IsUserPolicy()); config.AddPolicy(Policies.IsReadOnly, Policies.IsUserPolicy()); // config.AddPolicy(Policies.IsMyDomain, Policies.IsMyDomainPolicy()); Only works on the server end }); builder.Services.AddScoped <AuthenticationStateProvider, IdentityAuthenticationStateProvider>(); builder.Services.AddScoped <IAuthorizeApi, AuthorizeApi>(); builder.Services.AddScoped <AppState>(); builder.Services.AddTransient <IApiClient, ApiClient>(); foreach (var module in ModuleProvider.Modules) { module.ConfigureWebAssemblyServices(builder.Services); } var host = builder.Build(); foreach (var module in ModuleProvider.Modules) { module.ConfigureWebAssemblyHost(host); } using (var serviceScope = host.Services.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var js = serviceScope.ServiceProvider.GetService <IJSRuntime>(); var cookieCulture = await js.GetAspNetCoreCultureCookie(); if (!string.IsNullOrWhiteSpace(cookieCulture)) { CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(cookieCulture); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CurrentCulture; } } await host.RunAsync(); }
public void RequestCollectionTest() { var netModule = Substitute.For <INetModule>(); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); netModule.net_version().ReturnsForAnyArgs(x => new ResultWrapper <string> { Result = new Result { ResultType = ResultType.Success }, Data = "1" }); ethModule.eth_protocolVersion().ReturnsForAnyArgs(x => new ResultWrapper <string> { Result = new Result { ResultType = ResultType.Success }, Data = "1" }); var shhModule = Substitute.For <IShhModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule); _jsonSerializer = new JsonSerializer(_logManager); _jsonRpcService = new JsonRpcService(_jsonSerializer, moduleProvider, _configurationProvider, _logManager); var netRequestJson = GetJsonRequest("net_version", null); var ethRequestJson = GetJsonRequest("eth_protocolVersion", null); var jsonRequest = $"[{netRequestJson},{ethRequestJson}]"; var rawResponse = _jsonRpcService.SendRequest(jsonRequest); var response = _jsonSerializer.DeserializeObjectOrArray <JsonRpcResponse>(rawResponse); Assert.IsNotNull(response); Assert.IsNotNull(response.Collection); Assert.IsNull(response.Model); }
public void GetWorkTest() { var netModule = Substitute.For <INetModule>(); var ethModule = Substitute.For <IEthModule>(); var web3Module = Substitute.For <IWeb3Module>(); ethModule.eth_getWork().ReturnsForAnyArgs(x => new ResultWrapper <IEnumerable <Data> > { Result = new Result { ResultType = ResultType.Success }, Data = new [] { new Data("t1"), new Data("t2") } }); var shhModule = Substitute.For <IShhModule>(); var moduleProvider = new ModuleProvider(_configurationProvider, netModule, ethModule, web3Module, shhModule); _jsonSerializer = new JsonSerializer(_logManager); _jsonRpcService = new JsonRpcService(_jsonSerializer, moduleProvider, _configurationProvider, _logManager); var requestJson = GetJsonRequest("eth_getWork", null); var rawResponse = _jsonRpcService.SendRequest(requestJson); var response = _jsonSerializer.Deserialize <JsonRpcResponse>(rawResponse); Assert.IsTrue(response.Result.ToString().Contains("0xt1")); Assert.IsTrue(response.Result.ToString().Contains("0xt2")); }
private void AddFile(SoftwareInfo software, string modulesPath, string file, Dictionary <string, ModuleInfo> modules) { var fileName = Path.GetFileName(file); var filePath = Path.Combine(modulesPath, fileName).ToLowerInvariant(); var productName = software.Product.Name; var moduleName = ModuleProvider.GetModuleName(productName, filePath); if (moduleName == null) { Logger.LogError("Missing module for {0}", filePath); moduleName = fileName; } var buffer = File.ReadAllBytes(file); if (!modules.TryGetValue(moduleName, out ModuleInfo moduleInfo)) { moduleInfo = GetModule(software, buffer); modules.Add(moduleName, moduleInfo); } var hashString = HashProvider.GetHashString(buffer, HashName); moduleInfo.Hash.Values.Add(filePath, hashString); }
protected bool IsStorageModuleAllowed(string storageModuleName) { var allowedStorageModules = new List<string> { "forum", "photo", "bookmarking", "wiki", "files", "crm", "projects", "logo", "fckuploaders", "talk", "mailaggregator", "whitelabel", "customnavigation", "userPhotos" }; if (!allowedStorageModules.Contains(storageModuleName)) return false; IModuleSpecifics moduleSpecifics = ModuleProvider.GetByStorageModule(storageModuleName); return moduleSpecifics == null || !IgnoredModules.Contains(moduleSpecifics.ModuleName); }
protected PortalTaskBase(DbFactory dbFactory, IOptionsMonitor <ILog> options, StorageFactory storageFactory, StorageFactoryConfig storageFactoryConfig, ModuleProvider moduleProvider) { Logger = options.CurrentValue; ProcessStorage = true; StorageFactory = storageFactory; StorageFactoryConfig = storageFactoryConfig; ModuleProvider = moduleProvider; DbFactory = dbFactory; }
private void DoRestoreStorage(IDataReadOperator dataReader) { Logger.Debug("begin restore storage"); var fileGroups = GetFilesToProcess(dataReader).GroupBy(file => file.Module).ToList(); var groupsProcessed = 0; foreach (var group in fileGroups) { foreach (var file in group) { var storage = StorageFactory.GetStorage(ConfigPath, Dump ? file.Tenant.ToString() : _columnMapper.GetTenantMapping().ToString(), group.Key); var quotaController = storage.QuotaController; storage.SetQuotaController(null); try { var adjustedPath = file.Path; var module = ModuleProvider.GetByStorageModule(file.Module, file.Domain); if (module == null || module.TryAdjustFilePath(Dump, _columnMapper, ref adjustedPath)) { var key = file.GetZipKey(); if (Dump) { key = Path.Combine(KeyHelper.GetStorage(), key); } using (var stream = dataReader.GetEntry(key)) { try { storage.Save(file.Domain, adjustedPath, module != null ? module.PrepareData(key, stream, _columnMapper) : stream); } catch (Exception error) { Logger.WarnFormat("can't restore file ({0}:{1}): {2}", file.Module, file.Path, error); } } } } finally { if (quotaController != null) { storage.SetQuotaController(quotaController); } } } SetCurrentStepProgress((int)(++groupsProcessed * 100 / (double)fileGroups.Count)); } if (fileGroups.Count == 0) { SetStepCompleted(); } Logger.Debug("end restore storage"); }
/// <summary> /// Проверить контракт перед сериализацией. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override T ValidateContract(T obj) { obj = base.ValidateContract(obj); if (obj != null) { obj.ThumbnailContract = ModuleProvider.ValidateBeforeSerialize <IPostMediaWithSize, PostMediaBase, PostMediaExternalContract>(obj.Thumbnail); } return(obj); }
/// <summary> /// Проверить контракт после сериализации. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override T ValidateAfterDeserialize(T obj) { obj = base.ValidateAfterDeserialize(obj); if (obj != null) { obj.Thumbnail = ModuleProvider.ValidateAfterDeserialize <PostMediaBase, IPostMediaWithSize, PostMediaExternalContract>(obj.ThumbnailContract); obj.ThumbnailContract = null; } return(obj); }
//private string GetModuleTitle(SoftwareInfo software, string name) //{ // var productName = software.Product.Name; // if (!productName.Equals("CHDK")) // return null; // name = name.Replace('.', '_'); // return CHDK.ResourceManager.GetString($"Module_{name}"); //} private string TryGetModuleTitle(SoftwareInfo software, string name) { var productName = software.Product.Name; var id = ModuleProvider.GetModuleId(productName, name); if (id == null) { return(null); } return(ResourceProvider.GetString(id)); }
/// <summary> /// Start Marvin.Core, Start will load available modules and triggers /// MarvinInitialised when ready /// </summary> public void Start() { Console.Out.WriteLine("Marvin system starting"); Modules = ModuleProvider.LoadModules(); WireActions(Modules); Endpoints = CreateEndpoints(); Console.Out.WriteLine("Marvin system ready for lift off"); Initialised?.Invoke(this); }
/// <summary> /// Проверить контракт перед сериализацией. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override PostDocument ValidateContract(PostDocument obj) { PostNodeBase Validate(IPostNode n) { return(ModuleProvider.ValidateBeforeSerialize <IPostNode, PostNodeBase, PostNodeExternalContract>(n)); } obj = base.ValidateContract(obj); if (obj != null) { obj.NodesContract = obj.Nodes?.Select(Validate)?.ToList(); } return(obj); }
/// <summary> /// Сериализовать ссылку. /// </summary> /// <param name="link">Ссылка.</param> /// <returns>Ссылка в виде строки.</returns> public string Serialize(ILink link) { if (link == null) { return(null); } var serializer = ModuleProvider?.QueryModule <ILinkSerializer, Type>(link.GetTypeForSerializer()); if (serializer == null) { throw new ModuleNotFoundException($"Не найдена логика сериализации для ссылки типа {link.GetTypeForSerializer()?.FullName}"); } return(WithTypeId(serializer.Serialize(link), serializer.LinkTypeId)); }
private static void InitializeCore() { ModuleProvider moduleProvider = new ModuleProvider() { UserInteraction = new DefaultUserInteractionProvider(), Data = new XpoDataProvider() }; Scout.Core.DefaultModuleProvider = moduleProvider; Scout.Core.DefaultModuleProvider.Logging = new DatabaseLoggingProvider(); InitializeModules(); }
/// <summary> /// Десериализовать ссылку. /// </summary> /// <param name="linkStr">Ссылка в виде строки.</param> /// <returns>Ссыока.</returns> public ILink Deserialize(string linkStr) { if (linkStr == null) { return(null); } (var data, var typeId) = ExtractTypeId(linkStr); var serializer = ModuleProvider?.QueryModule <ILinkSerializer, string>(typeId); if (serializer == null) { throw new ModuleNotFoundException($"Не найдена логика сериализации для ссылки типа \"{typeId}\""); } return(serializer.Deserialize(data)); }
public void AddModuleServices_AddsServicesFromModule() { // Arrange var module = new TestModule(); var moduleProvider = new ModuleProvider(new[] { module }); var services = new ServiceCollection(); // Act ServiceCollectionExtensions.AddModuleServices(services, moduleProvider); // Assert var descriptor = services.FirstOrDefault(sd => sd.ServiceType == typeof(IServiceOne)); Assert.NotNull(descriptor); }
/// <summary> /// Проверить контракт после сериализации. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override PostDocument ValidateAfterDeserialize(PostDocument obj) { IPostNode Validate(PostNodeBase n) { return(ModuleProvider.ValidateAfterDeserialize <PostNodeBase, IPostNode, PostNodeExternalContract>(n)); } obj = base.ValidateAfterDeserialize(obj); if (obj != null) { obj.Nodes = obj.NodesContract?.Select(Validate)?.ToList(); obj.NodesContract = null; } return(obj); }
/// <summary> /// Проверить контракт перед сериализацией. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override CompositePostNode ValidateContract(CompositePostNode obj) { PostNodeBase ValidateNode(IPostNode node) { return(ModuleProvider.ValidateBeforeSerialize <IPostNode, PostNodeBase, PostNodeExternalContract>(node)); } obj = base.ValidateContract(obj); if (obj != null) { obj.ChildrenContracts = obj.Children?.Select(ValidateNode)?.ToList(); obj.AttributeContract = ModuleProvider.ValidateBeforeSerialize <IPostAttribute, PostAttributeBase, PostAttributeExternalContract>(obj.Attribute); } return(obj); }
public void AddModuleServices_AddsModuleProvider() { // Arrange var module = new TestModule(); var moduleProvider = new ModuleProvider(new[] { module }); var services = new ServiceCollection(); // Act ServiceCollectionExtensions.AddModuleServices(services, moduleProvider); // Assert var descriptor = services.FirstOrDefault(sd => sd.ServiceType == typeof(IModuleProvider)); Assert.NotNull(descriptor); Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime); }
private IObjectSerializer GetSerializer(string typeId) { if (typeId == null) { throw new ArgumentNullException(nameof(typeId)); } lock (_idCache) { if (!_idCache.ContainsKey(typeId)) { _idCache[typeId] = ModuleProvider.QueryModule <IObjectSerializer, string>(typeId) ?? throw new ModuleNotFoundException($"Не найдена логика сериализации типа TypeId=\"{typeId}\""); } return(_idCache[typeId]); } }
private IObjectSerializer GetSerializer(Type type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } lock (_typeCache) { if (!_typeCache.ContainsKey(type)) { _typeCache[type] = ModuleProvider.QueryModule <IObjectSerializer, Type>(type) ?? throw new ModuleNotFoundException($"Не найдена логика сериализации типа {type.FullName}"); } return(_typeCache[type]); } }
/// <summary> /// Проверить контракт после сериализации. /// </summary> /// <param name="obj">Исходный объект.</param> /// <returns>Проверенный объект.</returns> public override CompositePostNode ValidateAfterDeserialize(CompositePostNode obj) { IPostNode ValidateNode(PostNodeBase node) { return(ModuleProvider.ValidateAfterDeserialize <PostNodeBase, IPostNode, PostNodeExternalContract>(node)); } obj = base.ValidateAfterDeserialize(obj); if (obj != null) { obj.Attribute = ModuleProvider.ValidateAfterDeserialize <PostAttributeBase, IPostAttribute, PostAttributeExternalContract>(obj.AttributeContract); obj.AttributeContract = null; obj.Children = obj.ChildrenContracts?.Select(ValidateNode)?.ToList(); obj.ChildrenContracts = null; } return(obj); }
public RestorePortalTask( DbFactory dbFactory, IOptionsMonitor <ILog> options, StorageFactory storageFactory, StorageFactoryConfig storageFactoryConfig, CoreBaseSettings coreBaseSettings, LicenseReader licenseReader, TenantManager tenantManager, AscCacheNotify ascCacheNotify, ModuleProvider moduleProvider) : base(dbFactory, options, storageFactory, storageFactoryConfig, moduleProvider) { CoreBaseSettings = coreBaseSettings; LicenseReader = licenseReader; TenantManager = tenantManager; AscCacheNotify = ascCacheNotify; Options = options; }
public static void ModuleInitialize() { ModuleProvider moduleProvider = new ModuleProvider(); moduleProvider.Initialize(); }
private void InitializeProviders() { listThreads.BeginUpdate(); _threadP = new ThreadProvider(_pid); Program.SecondarySharedThreadProvider.Add(_threadP); _threadP.Interval = Properties.Settings.Default.RefreshInterval; _threadP.Updated += new ThreadProvider.ProviderUpdateOnce(_threadP_Updated); listThreads.Provider = _threadP; listModules.BeginUpdate(); _moduleP = new ModuleProvider(_pid); Program.SecondarySharedThreadProvider.Add(_moduleP); _moduleP.Interval = Properties.Settings.Default.RefreshInterval; _moduleP.Updated += new ModuleProvider.ProviderUpdateOnce(_moduleP_Updated); listModules.Provider = _moduleP; listMemory.BeginUpdate(); _memoryP = new MemoryProvider(_pid); Program.SecondarySharedThreadProvider.Add(_memoryP); _memoryP.IgnoreFreeRegions = true; _memoryP.Interval = Properties.Settings.Default.RefreshInterval; _memoryP.Updated += new MemoryProvider.ProviderUpdateOnce(_memoryP_Updated); listMemory.Provider = _memoryP; listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondarySharedThreadProvider.Add(_handleP); _handleP.HideHandlesWithNoName = Properties.Settings.Default.HideHandlesWithNoName; _handleP.Interval = Properties.Settings.Default.RefreshInterval; _handleP.Updated += new HandleProvider.ProviderUpdateOnce(_handleP_Updated); listHandles.Provider = _handleP; listThreads.List.SetTheme("explorer"); listModules.List.SetTheme("explorer"); listMemory.List.SetTheme("explorer"); listHandles.List.SetTheme("explorer"); this.InitializeShortcuts(); }
private void InitializeProviders() { listThreads.BeginUpdate(); _threadP = new ThreadProvider(_pid); Program.SecondaryProviderThread.Add(_threadP); _threadP.Updated += this._threadP_Updated; listThreads.Provider = _threadP; listModules.BeginUpdate(); _moduleP = new ModuleProvider(_pid); Program.SecondaryProviderThread.Add(_moduleP); _moduleP.Updated += this._moduleP_Updated; listModules.Provider = _moduleP; listMemory.BeginUpdate(); _memoryP = new MemoryProvider(_pid); Program.SecondaryProviderThread.Add(_memoryP); _memoryP.IgnoreFreeRegions = true; _memoryP.Updated += this._memoryP_Updated; listMemory.Provider = _memoryP; listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondaryProviderThread.Add(_handleP); _handleP.HideHandlesWithNoName = Settings.Instance.HideHandlesWithNoName; _handleP.Updated += this._handleP_Updated; listHandles.Provider = _handleP; this.InitializeShortcuts(); }