void IContainer.Configure(Type concreteComponent, ComponentCallModelEnum callModel)
        {
            typeHandleLookup[concreteComponent] = callModel;

            lock (componentProperties)
                if (!componentProperties.ContainsKey(concreteComponent))
                    componentProperties[concreteComponent] = new ComponentConfig();
        }
예제 #2
0
        //--------------------------------------------------------------------------------
        // Config
        //--------------------------------------------------------------------------------

        public ExecuteEngineConfig SetServiceProvider(IServiceProvider provider)
        {
            if (provider is null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            serviceProvider = provider;
            components      = null;

            return(this);
        }
예제 #3
0
        protected void Application_Start()
        {
            log.Info("Web application starting.");

            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(WebApiConfig.Configure);
            ComponentConfig.RegisterComponent();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            log.Debug("Web application started successfully.");
        }
예제 #4
0
        /// <summary>
        /// Add the selected build component to the project with a default configuration
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnAddComponent_Click(object sender, RoutedEventArgs e)
        {
            string key   = (string)lbAvailableComponents.SelectedItem;
            var    match = lbProjectComponents.Items.Cast <ComponentConfig>().FirstOrDefault(c => c.Name == key);

            if (availableComponents != null)
            {
                // No duplicates are allowed
                if (match != null)
                {
                    lbProjectComponents.SelectedIndex = lbProjectComponents.Items.IndexOf(match);
                }
                else
                {
                    var component = availableComponents.FirstOrDefault(p => p.Metadata.Id == key);

                    if (component != null)
                    {
                        try
                        {
                            var c = this.SelectedComponents.Add(key, true, String.Format(CultureInfo.InvariantCulture,
                                                                                         "<component id=\"{0}\">{1}</component>", key, component.Value.DefaultConfiguration));
                            match = new ComponentConfig {
                                Name = key, Configuration = c
                            };
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine(ex.ToString());

                            MessageBox.Show("Unexpected error attempting to add component: " + ex.Message,
                                            Constants.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        lbProjectComponents.SelectedIndex = lbProjectComponents.Items.Add(match);
                        lbProjectComponents.Items.Refresh();
                        btnDelete.IsEnabled = true;

                        this.ComponentsModified?.Invoke(this, EventArgs.Empty);

                        // Open the configuration dialog to configure it when first added if needed
                        if (availableConfigEditors.Any(ed => ed.Metadata.Id == key))
                        {
                            btnConfigure_Click(sender, e);
                        }
                    }
                }
            }
        }
예제 #5
0
 public NeonConfig()
 {
     Database           = new DatabaseConfig();
     Scripts            = new ScriptConfig();
     Mqtt               = new MqttConfig();
     Plugins            = new PluginConfig();
     Tasks              = new TaskConfig();
     FileSystem         = new FileSystemConfig();
     Components         = new ComponentConfig();
     EventsDatabase     = new EventDatabaseConfig();
     IoT                = new IoTConfig();
     JwtToken           = "password";
     AutoLoadComponents = true;
     Home               = new HomeConfig();
 }
예제 #6
0
        public TransactionResult <Boolean> Edit(ComponentConfig info)
        {
            TransactionResult <Boolean> result = new TransactionResult <Boolean>();
            var serviceResult = ComponentConfigService.UpdateByID(info);

            if (serviceResult.ActionResult)
            {
                result.Data = serviceResult.Data;
            }
            else
            {
                result.Code    = 103;
                result.Message = "暂无数据";
            }
            return(result);
        }
예제 #7
0
        public TransactionResult <ComponentConfig> Add(ComponentConfig info)
        {
            TransactionResult <ComponentConfig> result = new TransactionResult <ComponentConfig>();

            var serviceResult = ComponentConfigService.Create(info);

            if (serviceResult.ActionResult & serviceResult.HavingData)
            {
                result.Data = serviceResult.Data;
            }
            else
            {
                result.Code    = 103;
                result.Message = "暂无数据";
            }
            return(result);
        }
예제 #8
0
        public ExecuteEngineConfig ConfigureComponents(Action <ComponentConfig> action)
        {
            if (action is null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (components == null)
            {
                components = CreateDefaultComponents();
            }

            action(components);
            serviceProvider = null;

            return(this);
        }
        public void CoverageFix()
        {
            var config = new ExecuteEngineConfig();

            Assert.Throws <ArgumentNullException>(() => config.SetServiceProvider(null));
            Assert.Throws <ArgumentNullException>(() => config.ConfigureComponents(null));
            Assert.Throws <ArgumentNullException>(() => config.ConfigureTypeMap(null));
            Assert.Throws <ArgumentNullException>(() => config.ConfigureTypeHandlers(null));
            Assert.Throws <ArgumentNullException>(() => config.ConfigureResultMapperFactories(null));

            var provider = new ComponentConfig().ToContainer();

            config.SetServiceProvider(provider);
            Assert.Equal(provider, ((IExecuteEngineConfig)config).GetServiceProvider());

            config.ConfigureComponents(components => { });
            Assert.NotEqual(provider, ((IExecuteEngineConfig)config).GetServiceProvider());
        }
        /// <summary>
        /// Add a new shared config.
        /// </summary>
        /// <typeparam name="TProbingPolicy">HashTable lookup policy.</typeparam>
        /// <typeparam name="TType">Codegen config type.</typeparam>
        /// <typeparam name="TProxy">Codegen proxy type.</typeparam>
        /// <param name="sharedConfigMemoryRegion"></param>
        /// <param name="componentConfig"></param>
        public static void Add <TProbingPolicy, TType, TProxy>(
            this SharedConfigMemoryRegion sharedConfigMemoryRegion,
            ComponentConfig <TType, TProxy> componentConfig)
            where TProbingPolicy : IProbingPolicy
            where TType : ICodegenType, new()
            where TProxy : ICodegenProxy <TType, TProxy>, new()
        {
            uint slotIndex = 0;

            SharedConfig <TProxy> sharedConfig = sharedConfigMemoryRegion.Get <TProbingPolicy, TProxy>(componentConfig.Config, ref slotIndex);

            if (sharedConfig.Buffer != IntPtr.Zero)
            {
                throw new ArgumentException("Config already present", nameof(componentConfig));
            }

            TType config = componentConfig.Config;

            // Calculate size to allocate.
            //
            sharedConfig = sharedConfigMemoryRegion.Allocate <SharedConfig <TProxy> >();

            // Update hash map
            //
            ProxyArray <uint> sharedConfigOffsets = sharedConfigMemoryRegion.ConfigsOffsetArray.Elements;

            sharedConfigOffsets[(int)slotIndex] = (uint)sharedConfig.Buffer.Offset(sharedConfigMemoryRegion.Buffer);

            // Copy header, copy config.
            //
            SharedConfigHeader sharedHeader = sharedConfig.Header;
            TProxy             configProxy  = sharedConfig.Config;

            // Initialize header.
            //
            sharedHeader.ConfigId.Store(1);
            sharedHeader.CodegenTypeIndex = config.CodegenTypeIndex();

            // Copy the config to proxy.
            //
            CodegenTypeExtensions.Serialize(componentConfig.Config, sharedConfig.Config.Buffer);
        }
예제 #11
0
        /// <summary>
        /// Add a new shared config.
        /// </summary>
        /// <typeparam name="TType">Codegen config type.</typeparam>
        /// <typeparam name="TProxy">Codegen proxy type.</typeparam>
        /// <param name="sharedConfigDictionary"></param>
        /// <param name="componentConfig"></param>
        internal static void Add <TType, TProxy>(
            SharedConfigDictionary sharedConfigDictionary,
            ComponentConfig <TType, TProxy> componentConfig)
            where TType : ICodegenType, new()
            where TProxy : ICodegenProxy <TType, TProxy>, new()
        {
            uint slotIndex = 0;

            SharedConfig <TProxy> sharedConfig = Get <TProxy>(sharedConfigDictionary, componentConfig.Config, ref slotIndex);

            if (sharedConfig.Buffer != IntPtr.Zero)
            {
                throw new ArgumentException("Config already present", nameof(componentConfig));
            }

            TType config = componentConfig.Config;

            // Calculate size to allocate.
            //
            sharedConfig = sharedConfigDictionary.Allocator.Allocate <SharedConfig <TProxy> >();

            // Update hash map
            //
            ProxyArray <uint> sharedConfigOffsets = sharedConfigDictionary.ConfigsOffsetArray.Elements;

            // #TODO verify.
            sharedConfigOffsets[(int)slotIndex] = (uint)sharedConfig.Buffer.Offset(sharedConfigDictionary.Buffer - sharedConfigDictionary.Allocator.OffsetToAllocator);

            // Copy header, copy config.
            //
            SharedConfigHeader sharedHeader = sharedConfig.Header;
            TProxy             configProxy  = sharedConfig.Config;

            // Initialize header.
            //
            sharedHeader.ConfigId.Store(1);
            sharedHeader.CodegenTypeIndex = config.CodegenTypeIndex();

            // Copy the config to proxy.
            //
            CodegenTypeExtensions.Serialize(componentConfig.Config, sharedConfig.Config.Buffer);
        }
        public async Task GetBadgeAmount()
        {
            var config = new ComponentConfig
            {
                AuthType    = ComponentDataSourceAuthType.None,
                DataSources = new List <ComponentDataSource>
                {
                    new ComponentDataSource
                    {
                        Key = ComponentDataSourceKeys.BadgeValue
                    }
                }
            };

            var workbenchAppService = Substitute.For <IWorkbenchAppService>();

            workbenchAppService.GetComponentConfigAsync(Arg.Any <Guid>())
            .Returns(Task.FromResult(config));

            var apiClient = Substitute.For <IBadgeApiClient>();

            apiClient.GetAmountAsync(config)
            .Returns(Task.FromResult <int?>(1));

            var target = new WorkbenchController(
                workbenchAppService,
                Substitute.For <IClientAppService>(),
                Substitute.For <IBizSystemAppService>(),
                apiClient,
                Substitute.For <IMobileCodeSender>(),
                _ => Substitute.For <IUserSettingAppService>());

            target.ControllerContext = CreateMockContext();

            var result = await target.GetBadgeAmount(Guid.NewGuid());

            result.Value.Should().Be(1);
        }
예제 #13
0
        public async Task <int?> GetAmountAsync(ComponentConfig config)
        {
            var datasource = config.DataSources.Find(o => o.Key == ComponentDataSourceKeys.BadgeValue);

            if (datasource == null || string.IsNullOrEmpty(datasource.Value))
            {
                _logger.Warning(
                    "{@ComponentConfig} has not config BadgeValue or DataSource Url has not Config",
                    config);

                return(null);
            }

            var url = datasource.Value;

            if (config.AuthType == ComponentDataSourceAuthType.ClientCredential)
            {
                var accessToken = await _identityService.GetClientCredentialAccessTokenAsync(config.AuthUsername, config.AuthPassword, "mp.todo");

                _httpClient.SetBearerToken(accessToken);
            }
            _httpClient.AddUserClaimsHeader(_httpContextAccessor.HttpContext);

            try
            {
                var content = await _httpClient.GetStringAsync(url);

                var result = Newtonsoft.Json.JsonConvert.DeserializeObject <int>(content);
                return(result);
            }
            catch (Exception e)
            {
                _logger.Error(e, e.Message);
                return(null);
            }
        }
예제 #14
0
        internal static int Add(ComponentConfig info)
        {
            string sql = "insert into ComponentConfig(ComponentId,Content,Version,ComponentConfigTitle,IsDefault) values(@ComponentId,@Content,@Version,@ComponentConfigTitle,@IsDefault);select @@IDENTITY;";

            return(InsertWithReturnID <ComponentConfig, int>(con, sql, info));
        }
        public void ComponentInitialization(string path)
        {
            ParseInformationState isParser = new ParseInformationState();
            IS = new InformationState();
            IS = isParser.parseIS(path+ "res/InformationState.xml");
            MascaretApplication.Instance.VRComponentFactory.Log(IS.toString());
            edm = new EasyDialogueManager ();

            string[] fileEntries = Directory.GetFiles(path+"res/dialogue");
            foreach (string fileName in fileEntries)
            {
                MascaretApplication.Instance.VRComponentFactory.Log("................Easy dialogue files ...........::" + fileName);
                if (fileName.ToString().EndsWith(".xml"))
                {
                    EasyDialogueFile easyDialPlan = EasyDialogueManager.LoadDialogueFileFromPath1(fileName);
                    //	DialogueFile dialoguePlan 	= EasyDialogueManager.LoadDialogueFileFromPath (Application.dataPath + "/StreamingAssets/res/tutorial.xml");
                    planLib.AddPlan(easyDialPlan);
                    MascaretApplication.Instance.VRComponentFactory.Log("................Easy dialogue files ....file loaded successfully");

                }

            }
            //edm =  EasyDialogueManager.LoadDialogueFile(Application.dataPath + "/StreamingAssets/res/tutorial.xml");

            components = new InitialiseComponents (path);
            config = new ComponentConfig();
            config = components.Config;

            extractor = new TemplateExtractor();
            extractor.setupComponent(config);
            //		TextComponent tc = new TextComponent();
            hmmComponent = new HMMComponent();
            hmmComponent.setupComponent(config);

            dialogueInterpreter = new DialogueInterpreter();
            dialogueInterpreter.setupComponent(config);
            nlgDialogueGenerator = new NaturalLanguageDialogueGenerator();
            nlgDialogueGenerator.setupComponent(config);
        }
예제 #16
0
        public void Insert()
        {
            // Create a shared memory map.
            //
            using var sharedMemoryRegionView      = SharedMemoryRegionView.CreateNew <MlosProxyInternal.SharedConfigMemoryRegion>(SharedMemoryMapName, SharedMemorySize);
            sharedMemoryRegionView.CleanupOnClose = true;

            // Create a shared config manager, and register created test shared memory map.
            //
            using var sharedConfigManager = new SharedConfigManager();
            sharedConfigManager.RegisterSharedConfigMemoryRegion(sharedMemoryRegionView);

            sharedConfigManager.CleanupOnClose = true;

            for (int i = 0; i < 500; i++)
            {
                {
                    TestComponentConfig config = default;
                    config.ComponentType = (uint)(i + 1);
                    config.Category      = 2;
                    config.Delay         = 5;

                    var componentConfig = ComponentConfig.Create(config);

                    sharedConfigManager.Insert(componentConfig);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentConfig, UnitTestProxy.TestComponentConfig>();

                    componentConfig.Config.ComponentType = (uint)(i + 1);
                    componentConfig.Config.Category      = 2;

                    sharedConfigManager.UpdateConfig(componentConfig);
                    Assert.Equal <double>(5, componentConfig.Config.Delay);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentStatistics, UnitTestProxy.TestComponentStatistics>();
                    componentConfig.Config.Id                = i;
                    componentConfig.Config.RefCount.Value    = 5;
                    componentConfig.Config.Counters[0].Value = 2;

                    sharedConfigManager.Insert(componentConfig);
                }
            }

            for (int i = 0; i < 500; i++)
            {
                {
                    var componentConfig = new ComponentConfig <TestComponentConfig, UnitTestProxy.TestComponentConfig>();

                    componentConfig.Config.ComponentType = (uint)(i + 1);
                    componentConfig.Config.Category      = 2;

                    sharedConfigManager.UpdateConfig(componentConfig);
                    Assert.Equal <double>(5, componentConfig.Config.Delay);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentStatistics, UnitTestProxy.TestComponentStatistics>();
                    componentConfig.Config.Id = i;

                    sharedConfigManager.UpdateConfig(componentConfig);

                    Assert.Equal <ulong>(5, componentConfig.Config.RefCount.Value);
                    Assert.Equal <ulong>(2, componentConfig.Config.Counters[0].Value);
                }

                {
                    var componentStatistics = new TestComponentStatistics()
                    {
                        Id = i
                    };
                    SharedConfig <UnitTestProxy.TestComponentStatistics> sharedConfig = sharedConfigManager.Lookup(componentStatistics);
                }

                {
                    TestComponentStatistics.CodegenKey codegenKey = default;
                    codegenKey.Id = i;

                    SharedConfig <UnitTestProxy.TestComponentStatistics> sharedConfig = sharedConfigManager.Lookup(codegenKey);

                    Assert.Equal <ulong>(5, sharedConfig.Config.RefCount.Load());
                    Assert.Equal <ulong>(2, sharedConfig.Config.Counters[0].Load());
                }
            }
        }
예제 #17
0
        void IContainer.Configure(Type concreteComponent, DependencyLifecycle dependencyLifecycle)
        {
            typeHandleLookup[concreteComponent] = dependencyLifecycle;

            lock (componentProperties)
                if (!componentProperties.ContainsKey(concreteComponent))
                    componentProperties[concreteComponent] = new ComponentConfig();
        }
예제 #18
0
 public static ComponentContainer ToContainer(this ComponentConfig config) => new(config);
예제 #19
0
 /// <summary>
 /// get pending task
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public async Task <List <TodoListVM> > GetPendingListAsync(ComponentConfig config)
 {
     return(await this.GetAsync(config, ComponentDataSourceKeys.TodoPendingList));
 }
예제 #20
0
 /// <inheritdoc />
 public void Initialize(ComponentConfig config)
 {
 }
예제 #21
0
        public void Insert()
        {
            using var sharedMemoryRegionView      = SharedMemoryRegionView.Create <MlosProxyInternal.SharedConfigMemoryRegion>(SharedMemoryMapName, SharedMemorySize);
            sharedMemoryRegionView.CleanupOnClose = true;

            MlosProxyInternal.SharedConfigMemoryRegion sharedConfigMemoryRegion = sharedMemoryRegionView.MemoryRegion();

            var hashTable = new SharedConfigManager();

            hashTable.SetMemoryRegion(sharedConfigMemoryRegion);

            for (int i = 0; i < 500; i++)
            {
                {
                    TestComponentConfig config = default;
                    config.ComponentType = (uint)(i + 1);
                    config.Category      = 2;
                    config.Delay         = 5;

                    var componentConfig = ComponentConfig.Create(config);

                    hashTable.Insert(componentConfig);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentConfig, UnitTestProxy.TestComponentConfig>();

                    componentConfig.Config.ComponentType = (uint)(i + 1);
                    componentConfig.Config.Category      = 2;

                    hashTable.UpdateConfig(componentConfig);
                    Assert.Equal <double>(5, componentConfig.Config.Delay);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentStatistics, UnitTestProxy.TestComponentStatistics>();
                    componentConfig.Config.Id                = i;
                    componentConfig.Config.RefCount.Value    = 5;
                    componentConfig.Config.Counters[0].Value = 2;

                    hashTable.Insert(componentConfig);
                }
            }

            for (int i = 0; i < 500; i++)
            {
                {
                    var componentConfig = new ComponentConfig <TestComponentConfig, UnitTestProxy.TestComponentConfig>();

                    componentConfig.Config.ComponentType = (uint)(i + 1);
                    componentConfig.Config.Category      = 2;

                    hashTable.UpdateConfig(componentConfig);
                    Assert.Equal <double>(5, componentConfig.Config.Delay);
                }

                {
                    var componentConfig = new ComponentConfig <TestComponentStatistics, UnitTestProxy.TestComponentStatistics>();
                    componentConfig.Config.Id = i;

                    hashTable.UpdateConfig(componentConfig);

                    Assert.Equal <ulong>(5, componentConfig.Config.RefCount.Value);
                    Assert.Equal <ulong>(2, componentConfig.Config.Counters[0].Value);
                }

                {
                    var componentStatistics = new TestComponentStatistics()
                    {
                        Id = i
                    };
                    SharedConfig <UnitTestProxy.TestComponentStatistics> sharedConfig = hashTable.Lookup(componentStatistics);
                }

                {
                    TestComponentStatistics.CodegenKey codegenKey = default;
                    codegenKey.Id = i;

                    SharedConfig <UnitTestProxy.TestComponentStatistics> sharedConfig = hashTable.Lookup(codegenKey);

                    Assert.Equal <ulong>(5, sharedConfig.Config.RefCount.Load());
                    Assert.Equal <ulong>(2, sharedConfig.Config.Counters[0].Load());
                }
            }
        }
예제 #22
0
        void IContainer.Configure(Type concreteComponent, DependencyLifecycle dependencyLifecycle)
        {
            if (initialized)
                throw new InvalidOperationException("You can't alter the registrations after the container components has been resolved from the container");

            typeHandleLookup[concreteComponent] = dependencyLifecycle;

            lock (componentProperties)
                if (!componentProperties.ContainsKey(concreteComponent))
                    componentProperties[concreteComponent] = new ComponentConfig();
        }
예제 #23
0
        internal static int Update(ComponentConfig info)
        {
            string sql = "update ComponentConfig set ComponentId=@ComponentId,Content=@Content,Version=@Version,ComponentConfigTitle=@ComponentConfigTitle,IsDefault=@IsDefault where ComponentConfigId=@ComponentConfigId";

            return(Update <ComponentConfig>(con, sql, info));
        }