public Task ValidateAsync(MemoryConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     if (config.Enabled)
     {
         if (config.DelayStart < Consts.AppConsts.DELAY_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.DelayStart), $"Minimum value is {Consts.AppConsts.DELAY_MIN}");
         }
         if (config.DelayStart > Consts.AppConsts.DELAY_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.DelayStart), $"Maximum value is {Consts.AppConsts.DELAY_MAX}");
         }
         if (config.RunInterval < Consts.AppConsts.INTERVAL_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.RunInterval), $"Minimum value is {Consts.AppConsts.INTERVAL_MIN}");
         }
         if (config.RunInterval > Consts.AppConsts.INTERVAL_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.RunInterval), $"Maximum value is {Consts.AppConsts.INTERVAL_MAX}");
         }
         if (config.MaxPercentageUsage < AppConsts.PERCENT_MIN)
         {
             throw new ArgumentOutOfRangeException(nameof(config.MaxPercentageUsage), $"Minimum value is {AppConsts.PERCENT_MIN}");
         }
         if (config.MaxPercentageUsage > AppConsts.PERCENT_MAX)
         {
             throw new ArgumentOutOfRangeException(nameof(config.MaxPercentageUsage), $"Maximum value is {AppConsts.PERCENT_MAX}");
         }
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddIdentityServer()
     .AddInMemoryIdentityResources(MemoryConfig.IdentityResources())
     .AddInMemoryClients(MemoryConfig.Clients())
     .AddTestUsers(MemoryConfig.TestUsers())
     .AddInMemoryApiResources(MemoryConfig.ApiResources())
     .AddInMemoryApiScopes(MemoryConfig.ApiScopes())
     .AddDeveloperSigningCredential();
     services.AddControllersWithViews();
 }
Exemplo n.º 3
0
 public DebugDialog(Cpu cpu, List <MemoryModule> memModules, MemoryConfig memCfg,
                    BiosMemController biosMemCtrl, AsusWMI asusWmi)
 {
     InitializeComponent();
     modules = memModules;
     SI      = cpu.systemInfo;
     MEMCFG  = memCfg;
     PT      = cpu.powerTable;
     BMC     = biosMemCtrl;
     CPU     = cpu;
     AWMI    = asusWmi;
 }
Exemplo n.º 4
0
 public DebugDialog(uint dramBaseAddr, List <MemoryModule> memModules,
                    MemoryConfig memCfg, SystemInfo systemInfo,
                    BiosMemController biosMemCtrl, PowerTable powerTable,
                    Ops ops)
 {
     InitializeComponent();
     baseAddress = dramBaseAddr;
     modules     = memModules;
     SI          = systemInfo;
     MEMCFG      = memCfg;
     PT          = powerTable;
     BMC         = biosMemCtrl;
     OPS         = ops;
 }
Exemplo n.º 5
0
        public static void SeedDataForIdentityServer(this IApplicationBuilder app, IConfiguration configuration)
        {
            using (var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var configContext = scope.ServiceProvider.GetRequiredService <IamConfigurationDbContext>();

                //ClientSettings settings = configuration.GetSection(nameof(ClientSettings)).Get<ClientSettings>();

                ////初始数据
                //if (!configContext.Clients.Any())
                //{
                //    foreach (var client in MemoryConfig.GetClients(settings))
                //    {
                //        configContext.Clients.Add(client.ToEntity());
                //    }
                //    configContext.SaveChanges();
                //}

                if (!configContext.IdentityResources.Any())
                {
                    foreach (var resource in MemoryConfig.GetIdentityResources())
                    {
                        configContext.IdentityResources.Add(resource.ToEntity());
                    }
                    configContext.SaveChanges();
                }

                if (!configContext.ApiScopes.Any())
                {
                    foreach (var apiScope in MemoryConfig.GetApiScopes())
                    {
                        configContext.ApiScopes.Add(apiScope.ToEntity());
                    }
                    configContext.SaveChanges();
                }

                if (!configContext.ApiResources.Any())
                {
                    foreach (var resource in MemoryConfig.GetApiResources())
                    {
                        configContext.ApiResources.Add(resource.ToEntity());
                    }
                    configContext.SaveChanges();
                }
            }
        }
Exemplo n.º 6
0
        public SystemInfoWindow(SystemInfo si, MemoryConfig mc, List <AsusSensorInfo> asusSensors)
        {
            InitializeComponent();
            Type type = si.GetType();

            PropertyInfo[]  properties = type.GetProperties();
            List <GridItem> items;

            try
            {
                items = new List <GridItem>
                {
                    new GridItem()
                    {
                        Name = "OS", Value = new Microsoft.VisualBasic.Devices.ComputerInfo().OSFullName
                    }
                };

                foreach (PropertyInfo property in properties)
                {
                    if (property.Name == "CpuId" || property.Name == "PatchLevel" || property.Name == "SmuTableVersion")
                    {
                        items.Add(new GridItem()
                        {
                            Name = property.Name, Value = $"{property.GetValue(si, null):X8}"
                        });
                    }
                    else if (property.Name == "SmuVersion")
                    {
                        items.Add(new GridItem()
                        {
                            Name = property.Name, Value = si.GetSmuVersionString()
                        });
                    }
                    else
                    {
                        items.Add(new GridItem()
                        {
                            Name = property.Name, Value = property.GetValue(si, null).ToString()
                        });
                    }
                }

                TestGrid.ItemsSource = items;
            }
            catch { }

            type       = mc.GetType();
            properties = type.GetProperties();

            try
            {
                items = new List <GridItem>();
                foreach (PropertyInfo property in properties)
                {
                    items.Add(new GridItem()
                    {
                        Name = property.Name, Value = property.GetValue(mc, null).ToString()
                    });
                }

                MemCfgGrid.ItemsSource = items;
            }
            catch { }

            //AsusWmiGrid.ItemsSource = asusSensors;

            DataContext = new
            {
                asusSensors
            };
        }
Exemplo n.º 7
0
 public AppConfigBuilder WithMemory(MemoryConfig memoryConfig)
 {
     this.Obj.Memory = memoryConfig;
     return(this);
 }