예제 #1
0
 internal void Init(OptionsBase options)
 {
     this.isInitializing = true;
     this.options = options;
     this.OnInit();
     this.isInitializing = false;
 }
예제 #2
0
        // -- constructor

        public ImportPipeline(OptionsBase options, FactoryBase factory, RuntimeBase runtime)
        {
            Arguments = new Dictionary <SimulationTypes, ArgumentsBase>();
            Options   = options;
            Factory   = factory;
            Runtime   = runtime;
        }
예제 #3
0
        private static void InitLogger(OptionsBase options)
        {
            var eventLevel = options.Verbose ? LogEventLevel.Verbose : LogEventLevel.Information;

            var logFile = Path.Combine(ApplicationDataDirectory.FullName, "logs", "log_.txt");
            var config  = new LoggerConfiguration()
                          .WriteTo.Console(restrictedToMinimumLevel: eventLevel)
#if DEBUG
                          .WriteTo.Debug(restrictedToMinimumLevel: LogEventLevel.Verbose)
#endif
                          .MinimumLevel.Verbose();

            if (!options.NoLog)
            {
                config = config.WriteTo.File(
                    logFile, restrictedToMinimumLevel: eventLevel,
                    rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7);
            }

            Log.Logger = config.CreateLogger();

            Log.Information("Operating system: {0}", RuntimeInformation.OSDescription);
            Log.Information("Runtime: {0}", RuntimeInformation.FrameworkDescription);

            Log.Information("GUI version: {0}", VersionStatistics.AppVersion);
            foreach (var kvp in VersionStatistics.LoadedAssemblyVersions)
            {
                Log.Information("Using {0} v{1}", kvp.Key.GetName().Name, kvp.Value);
            }

            Log.Verbose($"Application directory: {ApplicationDirectory.FullName}");
            Log.Verbose($"Data directory: {ApplicationDataDirectory.FullName}");
        }
예제 #4
0
        private static async Task InitProgramAsync(OptionsBase options)
        {
            var restartArgs = new List <string>(3);

            if (options.Verbose)
            {
                restartArgs.Add("--verbose");
            }
            if (options.NoLog)
            {
                restartArgs.Add("--no-log");
            }
            if (!string.IsNullOrWhiteSpace(options.AppDataPath))
            {
                restartArgs.Add($"--app-data=\"{options.AppDataPath}\"");
            }
            RestartArgs = string.Join(" ", restartArgs);

            var factory = new GlobalSingletonFactory(ApplicationDirectory, ApplicationDataDirectory);

            Settings = factory.LoadSettings();
            (Manager, Locations, ModStateManager) = await factory.CreateManagerAsync(Settings);

            Locations.ModsReloaded += async(s, e) =>
            {
                _modpacks = await LoadModpacksAsync();
            };
            _modpacks = await LoadModpacksAsync();
        }
예제 #5
0
        public SignalrClient(AppSettings appSettings, OptionsBase options)
        {
            string host = appSettings.Host;
            int    port = appSettings.RpcPort;

            if (!string.IsNullOrWhiteSpace(options.Host))
            {
                host = options.Host;
            }

            if (options.Port.HasValue)
            {
                port = options.Port.Value;
            }

            this.connection = new HubConnectionBuilder().WithUrl(new UriBuilder(appSettings.UseTls ? "https" : "http", host, port, "signal").ToString()).WithAutomaticReconnect().AddJsonProtocol(options2 => {
                options2.PayloadSerializerOptions.WriteIndented = false;
            }).Build();

            this.connection.Closed += async error => {
                await Task.Delay(new Random().Next(0, 5) * 1000).ConfigureAwait(false);

                await this.connection.StartAsync().ConfigureAwait(false);
            };
        }
예제 #6
0
        public static bool AzureAuth(OptionsBase o)
        {
            if (o.AccountKey is null)
            {
                Offline = true;
                return(true);
            }

            if (o.AccountKey.EndsWith(".txt"))
            {
                if (!File.Exists(o.AccountKey))
                {
                    Console.WriteLine($"Account key file '{o.AccountKey}' does not exist. Aborting...");
                    return(false);
                }
                o.AccountKey = File.ReadAllText(o.AccountKey);
            }

            try
            {
                var credentials = new StorageCredentials(o.AccountName, o.AccountKey);
                Account    = new CloudStorageAccount(credentials, true);
                Experiment = o.Experiment;
                return(true);
            }
            catch (Exception e)
            {
                File.WriteAllText("log.txt", e.ToString());
                Console.WriteLine("Azure authentication failed. Aborting...");
                return(false);
            }
        }
예제 #7
0
        public PKVesrionOptionPage(OptionsBase option)
        {
            InitializeComponent();
            this.controlledOption = option;

            VerCB.Items.Clear();

            VerCB.Items.Add(new PKVer("Manual select", string.Empty));
            //string s =  Environment.GetEnvironmentVariable("SPOCLIENT");
            //if (!string.IsNullOrEmpty(s))
            //{
            //    VerCB.Items.Add(new PKVer("Environment variable", s));
            //}

            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\.NETMicroFrameworkPortingKit"))
            {
                if (key != null)
                {
                    foreach (string str in key.GetSubKeyNames())
                    {
                        using (RegistryKey key1 = key.OpenSubKey(str))
                        {
                            if (key1 != null)
                            {
                                VerCB.Items.Add(new PKVer(str, key1.GetValue("InstallRoot").ToString()));
                            }
                        }
                    }
                }
            }


            VerCB.SelectedIndex = 0;
            string s = Environment.GetEnvironmentVariable("SPOCLIENT");

            if (s[s.Length - 1] != '\\')
            {
                s += "\\";
            }

            if (!string.IsNullOrEmpty(s))
            {
                PathTB.Text = s;

                PKVersionOption po = this.controlledOption as PKVersionOption;

                for (int i = 1; i < VerCB.Items.Count; i++)
                {
                    PKVer ver = VerCB.Items[i] as PKVer;
                    if (ver != null)
                    {
                        if (String.Compare(ver.Path, s, true) == 0)
                        {
                            VerCB.SelectedIndex = i;
                        }
                    }
                }
            }
        }
예제 #8
0
        public override void SetOption(OptionsBase option)
        {
            base.SetOption(option);
            ((EnvironmentOption)option).OnApplyChanges();
            this.RefreshControl();

            ModifiedChange();
        }
예제 #9
0
        internal async Task <MatchDescriptor> HostMatch(string gameName, OptionsBase options)
        {
            Endpoint             e       = Endpoint.NewGame(_gameServer.TranslateGameName(gameName), Player.Secret);
            ConnectorPayloadBase payload = new NewMatchPayload(Player.Name, options);
            MatchDescriptor      match   = await _gameServer.PostJSON <MatchDescriptor>(e, payload);

            CurrentMatchID = match.MatchId;
            return(match);
        }
        internal BaseMultiCombiner(IHostEnvironment env, string name, OptionsBase args)
        {
            Contracts.AssertValue(env);
            env.AssertNonWhiteSpace(name);
            Host = env.Register(name);
            Host.CheckValue(args, nameof(args));

            Normalize = args.Normalize;
        }
예제 #11
0
파일: Program.cs 프로젝트: rumkit/GZippy
 private static ErrorCode HandleError(Exception e, OptionsBase options)
 {
     Console.WriteLine("Unexpected error occured. Show this to your programmer");
     Console.WriteLine("Error:");
     Console.WriteLine(e.Message);
     Console.WriteLine("Stacktrace:");
     Console.WriteLine(e.StackTrace);
     return(ErrorCode.Fail);
 }
예제 #12
0
 public BoosterParameterBase(OptionsBase options)
 {
     Contracts.CheckUserArg(options.MinimumSplitGain >= 0, nameof(OptionsBase.MinimumSplitGain), "must be >= 0.");
     Contracts.CheckUserArg(options.MinimumChildWeight >= 0, nameof(OptionsBase.MinimumChildWeight), "must be >= 0.");
     Contracts.CheckUserArg(options.SubsampleFraction > 0 && options.SubsampleFraction <= 1, nameof(OptionsBase.SubsampleFraction), "must be in (0,1].");
     Contracts.CheckUserArg(options.FeatureFraction > 0 && options.FeatureFraction <= 1, nameof(OptionsBase.FeatureFraction), "must be in (0,1].");
     Contracts.CheckUserArg(options.L2Regularization >= 0, nameof(OptionsBase.L2Regularization), "must be >= 0.");
     Contracts.CheckUserArg(options.L1Regularization >= 0, nameof(OptionsBase.L1Regularization), "must be >= 0.");
     BoosterOptions = options;
 }
예제 #13
0
        protected SweeperBase(OptionsBase options, IHostEnvironment env, IValueGenerator[] sweepParameters, string name)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckNonWhiteSpace(name, nameof(name));
            Host = env.Register(name);
            Host.CheckValue(options, nameof(options));
            Host.CheckValue(sweepParameters, nameof(sweepParameters));

            _options        = options;
            SweepParameters = sweepParameters;
        }
예제 #14
0
        protected SweeperBase(OptionsBase options, IHostEnvironment env, string name)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckNonWhiteSpace(name, nameof(name));
            Host = env.Register(name);
            Host.CheckValue(options, nameof(options));
            Host.CheckNonEmpty(options.SweptParameters, nameof(options.SweptParameters));

            _options = options;

            SweepParameters = options.SweptParameters.Select(p => p.CreateComponent(Host)).ToArray();
        }
예제 #15
0
 internal static ICache CreateCache(OptionsBase options)
 {
     if (options.ConnectionOptions == null)
     {
         return(CacheManager.GetCache(
                    options.CacheId));
     }
     else
     {
         return(CacheManager.GetCache(options.CacheId, options.ConnectionOptions.CacheConnectionOptions));
     }
 }
예제 #16
0
 protected ExeConfigRunnerBase(OptionsBase args, IHostEnvironment env, string registrationName)
 {
     Contracts.AssertValue(env);
     Host = env.Register(registrationName);
     Host.CheckUserArg(!string.IsNullOrEmpty(args.ArgsPattern), nameof(args.ArgsPattern), "The command pattern is missing");
     Host.CheckUserArg(!string.IsNullOrEmpty(args.OutputFolderName), nameof(args.OutputFolderName), "Please specify an output folder");
     ArgsPattern              = args.ArgsPattern;
     OutputFolder             = GetOutputFolderPath(args.OutputFolderName);
     Prefix                   = string.IsNullOrEmpty(args.Prefix) ? "" : args.Prefix;
     ResultProcessor          = args.ResultProcessor.CreateComponent(Host);
     _calledFromUnitTestSuite = args.CalledFromUnitTestSuite;
     RunNums                  = new List <int>();
 }
예제 #17
0
    private void OnEnable()
    {
        options = OptionsBase.LoadFromFile(
            Paths.GetOptionsFilePath()) as Options;
        calibratingTouchscreen = true;

        RefreshRadioButtons();
        RefreshSliders();
        RefreshInputFields();

        stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        bgSource.Play();
    }
예제 #18
0
        public async Task TestConfigFailure(string fileName, Strings expectedMessage)
        {
            var client         = A.Fake <IStoreClient>();
            var logger         = new MockLogger();
            var stringprovider = new StringProvider();
            var command        = new MockCommandBase(client, logger, stringprovider);
            var options        = new OptionsBase
            {
                ConfigFile = $"{this.GetExecutingPath()}\\Files\\{fileName}"
            };
            var result = await command.DoCommand(options);

            logger.Message.ElementAt(logger.Message.Count - 2).Should().Be(string.Format(stringprovider.GetString(expectedMessage), options.ConfigFile), "because there is something wrong with the config file");
            result.Should().BeNegative("the config file is invalid");
        }
예제 #19
0
        public async Task TestLoginSuccess()
        {
            var client = A.Fake <IStoreClient>();

            A.CallTo(() => client.Login("myId", "myKey", "myTenantId")).Returns(Task.Factory.StartNew(() => true));
            var logger         = new MockLogger();
            var stringprovider = new StringProvider();
            var command        = new MockCommandBase(client, logger, stringprovider);
            var options        = new OptionsBase
            {
                ConfigFile = $"{this.GetExecutingPath()}\\Files\\.valid_config"
            };
            var result = await command.DoCommand(options);

            result.Should().BeGreaterOrEqualTo(0, "client credentials do not match");
            A.CallTo(() => client.Login("myId", "myKey", "myTenantId")).MustHaveHappened();
        }
예제 #20
0
        private static void SetDirectories(OptionsBase options)
        {
            // Application directory
            var assembly = Assembly.GetEntryAssembly();

            ApplicationDirectory = new DirectoryInfo(Path.GetDirectoryName(assembly !.Location) !);

            // Data directory
            if (string.IsNullOrWhiteSpace(options.AppDataPath))
            {
                ApplicationDataDirectory = GetApplicationDataDirectory();
                if (!ApplicationDataDirectory.Exists)
                {
                    ApplicationDataDirectory.Create();
                }
            }
            else
            {
                try
                {
                    ApplicationDataDirectory = new DirectoryInfo(options.AppDataPath);
                    if (!ApplicationDataDirectory.Exists)
                    {
                        ApplicationDataDirectory.Create();
                    }
                }
                catch
                {
                    // We play it safe here and fall back to the default since at this point
                    // in the app lifetime we cannot properly handle this error except crashing
                    ApplicationDataDirectory = GetApplicationDataDirectory();
                    if (!ApplicationDataDirectory.Exists)
                    {
                        ApplicationDataDirectory.Create();
                    }
                }
            }

            // Temporary directory
            TemporaryDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "ModMyFactoryGUI"));
            if (!TemporaryDirectory.Exists)
            {
                TemporaryDirectory.Create();
            }
        }
예제 #21
0
        public EnvironmentOptionsPage(OptionsBase option)
        {
            InitializeComponent();
            this.controlledOption = option;

            ToolCB.Items.Clear();

            ToolCB.Items.Add("GCC");
            ToolCB.Items.Add("GCCOP");
            ToolCB.Items.Add("MDK");
            ToolCB.Items.Add("RVDS");
            ToolCB.Items.Add("SHC");
            ToolCB.Items.Add("VS");

            ToolCB.SelectedIndex = 3;
            UpdatePath();
            this.Modified = false;
        }
예제 #22
0
        /// <summary>
        /// Initializes the <see cref="MetaMulticlassClassificationTrainer{TTransformer, TModel}"/> from the <see cref="OptionsBase"/> class.
        /// </summary>
        /// <param name="env">The private instance of the <see cref="IHostEnvironment"/>.</param>
        /// <param name="options">The legacy arguments <see cref="OptionsBase"/>class.</param>
        /// <param name="name">The component name.</param>
        /// <param name="labelColumn">The label column for the metalinear trainer and the binary trainer.</param>
        /// <param name="singleEstimator">The binary estimator.</param>
        /// <param name="calibrator">The calibrator. If a calibrator is not explicitly provided, it will default to <see cref="PlattCalibratorTrainer"/></param>
        internal MetaMulticlassClassificationTrainer(IHostEnvironment env, OptionsBase options, string name, string labelColumn = null,
            TScalarTrainer singleEstimator = null, ICalibratorTrainer calibrator = null)
        {
            Host = Contracts.CheckRef(env, nameof(env)).Register(name);
            Host.CheckValue(options, nameof(options));
            Args = options;

            if (labelColumn != null)
                LabelColumn = new SchemaShape.Column(labelColumn, SchemaShape.Column.VectorKind.Scalar, NumberDataViewType.UInt32, true);

            Trainer = singleEstimator ?? CreateTrainer();

            Calibrator = calibrator ?? new PlattCalibratorTrainer(env);
            if (options.Calibrator != null)
                Calibrator = options.Calibrator.CreateComponent(Host);

            // Regarding caching, no matter what the internal predictor, we're performing many passes
            // simply by virtue of this being a meta-trainer, so we will still cache.
            Info = new TrainerInfo(normalization: Trainer.Info.NeedNormalization);
        }
예제 #23
0
    private void LoadOrCreateOptions()
    {
        options = null;
        try
        {
            options = OptionsBase.LoadFromFile(
                Paths.GetOptionsFilePath()) as Options;
        }
        catch (IOException)
        {
            options = new Options();
        }

        // Find all resolutions, as well as resolutionIndex.
        resolutions     = new List <Resolution>();
        resolutionIndex = -1;
        for (int i = 0; i < Screen.resolutions.Length; i++)
        {
            Resolution r = Screen.resolutions[i];
            resolutions.Add(r);
            if (r.width == options.width &&
                r.height == options.height &&
                r.refreshRate == options.refreshRate)
            {
                resolutionIndex = i;
            }
        }

        if (resolutionIndex == -1)
        {
            // Restore default resolution.
            resolutionIndex     = resolutions.Count - 1;
            options.width       = resolutions[resolutionIndex].width;
            options.height      = resolutions[resolutionIndex].height;
            options.refreshRate = resolutions[resolutionIndex].refreshRate;
        }
    }
예제 #24
0
 public DataStrategyWithOptions(DataStrategy wrappedStrategy, OptionsBase options)
 {
     _options         = options;
     _wrappedStrategy = wrappedStrategy.Clone();
     _wrappedStrategy.GetAdapter().Options = options;
 }
예제 #25
0
 internal BaseMultiAverager(IHostEnvironment env, string name, OptionsBase args)
     : base(env, name, args)
 {
 }
예제 #26
0
 protected SerializerBase(OptionsBase options)
 {
     _hooks  = CollectionUtils.Cast <IJsmlSerializerHook>(new JsmlSerializerHookExtensionPoint().CreateExtensions());
     Options = options;
 }
예제 #27
0
 public DeobfuscatorBase(OptionsBase optionsBase)
 {
     this.optionsBase     = optionsBase;
     StringFeatures       = StringFeatures.AllowAll;
     DefaultDecrypterType = DecrypterType.Static;
 }
예제 #28
0
 public SignalrClient(AppSettings appSettings, OptionsBase options, IApiEvents eventHandler) : this(appSettings, options)
 {
     // make sure we can receive events
     this.RegisterEvents(eventHandler);
 }
예제 #29
0
 public UniformRandomSweeper(IHostEnvironment env, OptionsBase options, IValueGenerator[] sweepParameters)
     : base(options, env, sweepParameters, "UniformRandom")
 {
 }
예제 #30
0
 public UniformRandomSweeper(IHostEnvironment env, OptionsBase options)
     : base(options, env, "UniformRandom")
 {
 }
예제 #31
0
 private void AddNodes(TreeNodeCollection nodes, OptionsBase options)
 {
   foreach (OptionsBase options1 in (IEnumerable<OptionsBase>) options.SubOptions)
   {
     OptionsNode optionsNode = new OptionsNode(options1);
     nodes.Add((TreeNode) optionsNode);
     if (!this.optionsNodes.ContainsKey(options1.GetType()))
       this.optionsNodes.Add(options1.GetType(), optionsNode);
     this.AddNodes(optionsNode.Nodes, options1);
   }
   if (nodes.Count <= 0 || options is AppOptions)
     return;
   GeneralOptionsNode generalOptionsNode = new GeneralOptionsNode(options);
   nodes.Insert(0, (TreeNode) generalOptionsNode);
 }
예제 #32
0
 public dynamic WithOptions(OptionsBase options)
 {
     return new DataStrategyWithOptions(this, options);
 }
예제 #33
0
		public GeneralOptionsNode(OptionsBase options) : base(options)
		{
			this.Text = "General";
		}
예제 #34
0
		public OptionsNode(OptionsBase options) : base(options.Text)
		{
			this.Options = options;
		}
예제 #35
0
 public static void SetOptions(OptionsBase options)
 {
     options.Host      = Global.DefaultHost;
     options.SourceDir = Global.AssemblyDir;
     options.OutputDir = Global.TempDir;
 }
 public DataStrategyWithOptions(DataStrategy wrappedStrategy, OptionsBase options)
 {
     _options = options;
     _wrappedStrategy = wrappedStrategy.Clone();
     _wrappedStrategy.GetAdapter().Options = options;
 }