Example #1
0
        public void Init(InitOptions options)
        {
            var resources = _webResourceRepo.GetAll(options.Prefixes.ToArray());

            _logger.Info($"Serializing...");

            var config = resources.Select(wr =>
            {
                var name = wr.GetAttributeValue <string>(WebResource.name);
                var path = name.NormalizePath(options.WebResourcesRoot, wr.GetOptionSetValueAsEnum <WebResourceType>(WebResource.webresourcetype));

                return(new WebResourceConfig
                {
                    Name = name,
                    DisplayName = wr.GetAttributeValue <string>(WebResource.displayname) ?? name.GetDisplayName(),
                    Description = wr.GetAttributeValue <string>(WebResource.description) ?? string.Empty,
                    Path = path
                });
            });
            var serialized = JsonConvert.SerializeObject(config, Formatting.Indented);

            File.WriteAllText(options.ConfigFilePath, serialized);

            _logger.Info("Done processing Web Resources.");
        }
Example #2
0
        public static void InitNewConfig(InitOptions options)
        {
            if (File.Exists(PathUtils.ConfigPath))
            {
                Logger.Log(LogCategory.Warning, "This project already has a config file");
            }

            Logger.Log(LogCategory.Info, $"Writing new config file to {PathUtils.ConfigPath} ...");
            var newConfigText = SerialiseConfig(ConfigDefaults.GetMinimalUserConfig());

            try
            {
                using (var file = File.Open(PathUtils.ConfigPath, FileMode.CreateNew))
                {
                    var writer = new StreamWriter(file);
                    writer.Write(newConfigText);
                    writer.Flush();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Failed to write new config file: " + e.Message, e);
            }

            var defaultConfigInstance = ConfigDefaults.GetDefaultConfig();

            if (!Directory.Exists(defaultConfigInstance.Build.OutputDirectory))
            {
                Logger.Log(LogCategory.Info, $"Creating your build output folder at {defaultConfigInstance.Build.OutputDirectory} ...");
            }
        }
Example #3
0
        private void PrepareInitCommand()
        {
            cmd.Command("init", config =>
            {
                config.FullName    = "Bake init build and deploy";
                config.Description = "Initialize build and deploy template files in current directory";
                var argSlnFilePath = config.Argument("[slnFile]", "Path to sln file, if empty sln will not be modified");
                var overwrite      = config.Option("-o|--overwrite", "Overwrite .cake files if they already exist", CommandOptionType.NoValue);
                var buildSolution  = config.Option("-bs|--buildSolution", "Build solution file, if not specified every project will be built separately", CommandOptionType.NoValue);
                config.OnExecute(() =>
                {
                    var solutionFilePath = argSlnFilePath.Value == null ? null : new DirectoryPath(Directory.GetCurrentDirectory()).CombineWithFilePath(argSlnFilePath.Value);
                    var initOptions      = new InitOptions()
                    {
                        SolutionFilePath = solutionFilePath,
                        Overwrite        = overwrite.HasValue(),
                        BuildSolution    = buildSolution.HasValue()
                    };

                    commandRunner.InitCommand.Run(initOptions);
                    return(0);
                });
                config.HelpOption("-?|-h|--help");
            });
        }
Example #4
0
        static SkyDrive()
        {
            Office.Initialize = delegate(InitializationEnum initReason)
            {
                ViewManager.SwitchToView(ViewManager.SignIn);
                InitOptions initOptions = new InitOptions();
                initOptions.client_id = "000000004C100093";
                initOptions.redirect_uri = "https://friendsinoffice.com/skydrive/App/callback.html";
                initOptions.Scope = new string[] { "wl.skydrive_update", "wl.signin" };
                initOptions.response_type = "code";
                initOptions.logging = true;
                LiveApi.Init(initOptions).Then(OnInitSuccess, OnFailure);
                LiveApi.Event.subscribe("auth.login", OnLogon);
                LiveApi.Event.subscribe("wl.log", OnLog);
                LiveApi.GetLoginStatus().Then(OnLogon, OnFailure);

                Element dropzone = Document.GetElementById("dropzone");
                dropzone.AddEventListener("dragenter", NoOpHandler, false);
                dropzone.AddEventListener("dragexit", NoOpHandler, false);
                dropzone.AddEventListener("dragover", NoOpHandler, false);
                dropzone.AddEventListener("drop", Drop, false);

                BindingOptions bo = new BindingOptions();
                bo.ID = TableBinding;
                bo.Columns = new string[]{"ID"};
                Office.Context.Document.Bindings.AddFromSelectionAsync(BindingType.Table, bo, delegate(ASyncResult result)
                {
                    Office.Select("bindings#"+TableBinding).AddHandlerAsync(EventType.BindingSelectionChanged, OnBindingSelectionChanged);
                    OnBindingSelectionChanged(null);
                });

            };
        }
Example #5
0
        public void GlobalOptionsInitTest(string type)
        {
            string[]    args = GetArgs("init", type);
            InitOptions opt  = TestParseArguments <InitOptions>(args);

            CheckFields(opt);
        }
Example #6
0
        public static int Execute(InitOptions opts)
        {
            var _defaultColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Starting up the receive listener...");
            Console.ForegroundColor = _defaultColor;

            // Start the receive script
            ProcessStartInfo start = new ProcessStartInfo()
            {
                FileName               = "python3",
                UseShellExecute        = false,
                RedirectStandardOutput = false,
                Arguments              = "Scripts/receive.py"
            };

            using (Process process = Process.Start(start))
            {
                // Save process pid to external file for later kill
                File.WriteAllTextAsync(".pid", process.Id.ToString()).Wait();
            }

            return(0);
        }
Example #7
0
        public WSmoothPingPong(InitOptions initOptions, PingPongOptions options)
        {
            _initOptions = initOptions;
            _options     = options;

            SmoothStart();
        }
Example #8
0
        private static int HandleInit(InitOptions options)
        {
            VersionFile versionFile = new VersionFile();

            versionFile.SetVersion(options.InitialVersion);
            versionFile.SerializeToFile();
            return(0);
        }
Example #9
0
 public TraversalEngine(Context context, QueryType query, RayFormat rayFormat, TriFormat triFormat,
                        TraversalOutput outputs, InitOptions options)
 {
     mRayFormat = rayFormat;
     mRaySize   = rayFormat == RayFormat.OriginDirectionInterleaved ? 24 : 32;
     CheckError(TraversalApi.rtuTraversalCreate(ref mTraversal, (RTUquerytype)query, (RTUrayformat)rayFormat,
                                                (RTUtriformat)triFormat, (uint)outputs, (uint)options, context.InternalPtr));
 }
Example #10
0
    static int Init(InitOptions options)
    {
        var updateChecker = CheckForUpdates();
        var exitCode      = InitCommand.Run(GetConfig(new Config.CLIInitCommandConfig(options)));

        WriteUpdateNotification(updateChecker);
        return(exitCode);
    }
        public void GetHtmlNoPaymentOptionsTest()
        {
            IOptions options = new InitOptions();

            string result = options.GetOptionString();

            Assert.IsNull(result);
        }
Example #12
0
 /// <summary>
 /// Method that handles "init" command.
 /// </summary>
 /// <param name="initOptions">Options passed to the command.</param>
 internal static void HandleInit(InitOptions initOptions)
 {
     CommandHandlerHelper.TryExecute(initOptions, options =>
     {
         var logger             = CommandHandlerHelper.CreateLogger(options.IsDebug);
         var storageInitializer = FileFsStorageInitializerFactory.Create(options.Instance, logger);
         storageInitializer.Initialize(options.Size, options.FileNameLength);
     });
 }
Example #13
0
 public ZitiIdentity(InitOptions opts)
 {
     this.InitOpts = opts;
     if (opts.IdentityFile != null)
     {
         string json = File.ReadAllText(opts.IdentityFile);
         nid = JsonSerializer.Deserialize <Native.IdentityFile>(json);
     }
 }
Example #14
0
        public void RunActionTest()
        {
            var opt = new InitOptions();
            var act = new ActionInit();

            int status        = act.Run(opt);
            int lastRunStatus = act.GetLastRunStatus();

            Assert.AreEqual(status, lastRunStatus, "Status need to be the same!!!");
        }
        public TemplatePlanResult Generate(InitOptions initOptions)
        {
            var filePaths = new List <string>()
            {
                "deploy\\deploy.ps1", "deploy\\deploy.cake"
            };

            // TODO
            return(null);
        }
        public void GetHtmlNoApiKeyTest()
        {
            IOptions options = new InitOptions
            {
                PaymentRequest = new PaymentRequestOptions()
            };

            string result = options.GetOptionString();

            Assert.IsNull(result);
        }
Example #17
0
        private static int Init(InitOptions opts)
        {
            if (!Directory.Exists(opts.Directory))
            {
                Directory.CreateDirectory(opts.Directory);
            }

            var file = AdrFile.Save(new AdrDirectory(opts.Directory), AdrEntry.CreateInitial());

            Console.WriteLine("Initialized and created {0}", file.FilePath);
            return(0);
        }
 public InitHostedService(
     IEngineConfigurationBuilder configurationBuilder,
     InitOptions initOptions,
     ILogger <InitHostedService> logger,
     ITelemetryLogger telemetryLogger,
     IHostApplicationLifetime appLifetime)
 {
     _configurationBuilder = configurationBuilder;
     _initOptions          = initOptions;
     _logger          = logger;
     _telemetryLogger = telemetryLogger;
     _appLifetime     = appLifetime;
 }
        public IInitContext AcquireInitContext(InitOptions initOptions)
        {
            if (this.contexts == null)
            {
                this.contexts = new Stack <InitialisationContext>();
            }

            var context = new InitialisationContext(this, initOptions);

            this.contexts.Push(context);

            return(context);
        }
Example #20
0
        /// <summary>
        /// Runs the init action.
        /// </summary>
        /// <param name="options">CLI options for the init action.</param>
        /// <param name="fromMain">Wheter or not this is called from the main method.</param>
        /// <returns>CLI return code.</returns>
        private static int Init(InitOptions options, bool fromMain = true)
        {
            InitAction initializer = new InitAction(options);
            int        result      = initializer.Run();

#if DEBUG
            if (fromMain == true)
            {
                Console.Read();
            }
#endif

            return(result);
        }
Example #21
0
        private void InitDeployment(InitOptions opts)
        {
            ParseYamlFile(opts);

            foreach (var service in _services)
            {
                _deployment.Name       = service.Name;
                _deployment.NameSpace  = _nameSpace;
                _deployment.ProjectDir = GetProjectName(service.Project);
                _deployment.KubeDir    = opts.KubeDirName;
                _deployment.InitDeployment();
                ConsoleMessage($"Deployment namespace and configmap for {service.Name.Trim()} has been created");
            }
        }
Example #22
0
        private SolutionInfo PrepareSolutionInfo(InitOptions initOptions)
        {
            if (initOptions.SolutionFilePath == null)
            {
                var currentDir = new DirectoryPath(Directory.GetCurrentDirectory());
                Log.Header("Exploring projects - searching directory {CurrentDir}.", currentDir.FullPath);
                Log.IncreaseIndent();
                return(new SolutionInfo(solutionPath: currentDir, buildSolution: false));
            }
            var relativeSlnDir = new DirectoryPath(Directory.GetCurrentDirectory()).GetRelativePath(initOptions.SolutionFilePath);

            Log.Header("Exploring projects - parsing solution file {SlnFile}.", relativeSlnDir.FullPath);
            return(new SolutionInfo(initOptions.SolutionFilePath, initOptions.BuildSolution));
        }
Example #23
0
 private static object RunInitAndReturnExitCode(InitOptions opts)
 {
     Telemetry.Current.TrackEvent("InitCommand");
     if (!File.Exists("vstsbulkeditor.json"))
     {
         string json = JsonConvert.SerializeObject(EngineConfiguration.GetDefault(),
                                                   new FieldMapConfigJsonConverter(),
                                                   new ProcessorConfigJsonConverter());
         StreamWriter sw = new StreamWriter("vstsbulkeditor.json");
         sw.WriteLine(json);
         sw.Close();
         Trace.WriteLine("New vstsbulkeditor.json file has been created", "vstsbulkeditor");
     }
     return(0);
 }
Example #24
0
 public InitHostedService(
     IEngineConfigurationBuilder configurationBuilder,
     ISettingsWriter settingsWriter,
     IOptions <InitOptions> initOptions,
     ILogger <InitHostedService> logger,
     ITelemetryLogger telemetryLogger,
     IHostApplicationLifetime appLifetime)
 {
     _configurationBuilder = configurationBuilder;
     _settingWriter        = settingsWriter;
     _initOptions          = initOptions.Value;
     _logger          = logger;
     _telemetryLogger = telemetryLogger;
     _appLifetime     = appLifetime;
 }
Example #25
0
        public void Run(InitOptions initOptions)
        {
            var solutionFilePath = initOptions.SolutionFilePath;
            var buildResult      = commandRunner.GenerateBuildScriptsCommand.Generate(initOptions);
            var deployResult     = commandRunner.GenerateDeployScriptsCommand.Generate(initOptions);

            if (solutionFilePath != null && buildResult.GetAddedFiles().Any())
            {
                var relativePaths = buildResult.GetAddedFiles()
                                    .Select(path => solutionFilePath.GetRelativePath(path).FullPath.Replace('/', '\\'))
                                    .ToList();
                commandRunner.UpdateVisualStudioSlnCommand.AddSolutionFolderToSlnFile(solutionFilePath.FullPath, "Build", "Build", relativePaths);
                //commandRunner.UpdateVisualStudioSlnCommand.AddSolutionFolderToSlnFile(slnFilePath, "Deploy", "Deploy", deployScriptPaths);
            }
        }
Example #26
0
        /*
         * int Main(string[] args)
         * {
         *  return CommandLine.Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions>(args)
         *    .MapResult(
         *      (AddOptions opts) => RunAddAndReturnExitCode(opts),
         *      (CommitOptions opts) => RunCommitAndReturnExitCode(opts),
         *      (CloneOptions opts) => RunCloneAndReturnExitCode(opts),
         *      errs => 1);
         * }*/

        private static void Initialize(InitOptions opts)
        {
            try
            {
                ICoreSrcDependencies srcdep = FSCoreSrcDependencies.InitializeNew(opts.BSName, cwd, new DiskFSInterop(), opts.Cache);

                if (opts.Cache != null)
                {
                    var cachedep = CoreDstDependencies.InitializeNew(opts.BSName, true, DiskDstFSInterop.InitializeNew(opts.Cache), false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #27
0
        private static (InitOptions init, ExecuteOptions execute) ParseOptions(string[] args)
        {
            InitOptions    initOptions    = null;
            ExecuteOptions executeOptions = null;

            Parser.Default.ParseArguments <InitOptions, ExecuteOptions>(args)
            .WithParsed <InitOptions>(opts =>
            {
                initOptions = opts;
            })
            .WithParsed <ExecuteOptions>(opts =>
            {
                executeOptions = opts;
            });
            return(initOptions, executeOptions);
        }
Example #28
0
        /// <summary>
        /// Initializes ROS
        /// </summary>
        /// <param name="args"> argv - parsed for remapping args (AND PARAMS??) </param>
        /// <param name="name"> the node's name </param>
        /// <param name="options"> options? </param>
        public static void Init(string[] args, string name, InitOptions options)
        {
            // ROS_MASTER_URI/ROS_HOSTNAME definition precedence:
            // 1. explicitely set by program
            // 2. passed in as remap argument
            // 3. environment variable

            if (RemappingHelper.GetRemappings(ref args, out IDictionary <string, string> remapping))
            {
                Init(remapping, name, options);
            }
            else
            {
                throw new InvalidOperationException("Could not initialize ROS");
            }
        }
        protected static object RunInitAndReturnExitCode(InitOptions opts, TelemetryClient telemetryClient)
        {
            _TelemetryClient.TrackEvent("InitCommand");

            string configFile = opts.ConfigFile;

            if (string.IsNullOrEmpty(configFile))
            {
                configFile = "configuration.json";
            }
            Log.Information("ConfigFile: {configFile}", configFile);
            if (File.Exists(configFile))
            {
                Log.Information("Deleting old configuration.json reference file");
                File.Delete(configFile);
            }
            if (!File.Exists(configFile))
            {
                Log.Information("Populating config with {Options}", opts.Options.ToString());
                IEngineConfigurationBuilder cbuilder = new EngineConfigurationBuilder();
                EngineConfiguration         config;
                switch (opts.Options)
                {
                case OptionsMode.Full:
                    config = cbuilder.BuildDefault();
                    break;

                case OptionsMode.WorkItemTracking:
                    config = cbuilder.BuildWorkItemMigration();
                    break;

                default:
                    config = cbuilder.BuildDefault();
                    break;
                }

                string json = JsonConvert.SerializeObject(config, Formatting.Indented,
                                                          new FieldMapConfigJsonConverter(),
                                                          new ProcessorConfigJsonConverter());
                StreamWriter sw = new StreamWriter(configFile);
                sw.WriteLine(json);
                sw.Close();
                Log.Information("New configuration.json file has been created");
            }
            return(0);
        }
        public void GetHtmlWithOptionsTest()
        {
            IOptions options = new InitOptions
            {
                PaymentRequest = new PaymentRequestOptions(),
                ApiKey         = "apiKey",
                Settings       = new SettingOptions()
            };

            string result = options.GetOptionString();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("V.init({"));
            Assert.IsTrue(result.Contains("\"paymentRequest\":{"));
            Assert.IsTrue(result.Contains("\"apikey\":\"apiKey\""));
            Assert.IsTrue(result.Contains("\"settings\":{"));
        }
Example #31
0
        private static object RunInitAndReturnExitCode(InitOptions opts)
        {
            Telemetry.Current.TrackEvent("InitCommand");
            string configFile = opts.ConfigFile;

            if (configFile.IsEmpty())
            {
                configFile = "configuration.json";
            }
            Telemetry.Current.TrackEvent("InitCommand");
            Trace.WriteLine(String.Format("ConfigFile: {0}", configFile), "[Info]");
            if (File.Exists(configFile))
            {
                Trace.WriteLine("Deleting old configuration.json reference file", "[Info]");
                File.Delete(configFile);
            }
            if (!File.Exists(configFile))
            {
                Trace.WriteLine(string.Format("Populating config with {0}", opts.Options.ToString()), "[Info]");
                EngineConfiguration config;
                switch (opts.Options)
                {
                case OptionsMode.Full:
                    config = EngineConfiguration.GetDefault();
                    break;

                case OptionsMode.WorkItemTracking:
                    config = EngineConfiguration.GetWorkItemMigration();
                    break;

                default:
                    config = EngineConfiguration.GetDefault();
                    break;
                }

                string json = JsonConvert.SerializeObject(config, Formatting.Indented,
                                                          new FieldMapConfigJsonConverter(),
                                                          new ProcessorConfigJsonConverter());
                StreamWriter sw = new StreamWriter(configFile);
                sw.WriteLine(json);
                sw.Close();
                Trace.WriteLine("New configuration.json file has been created", "[Info]");
            }
            return(0);
        }
Example #32
0
    // Use this for initialization
    public void create()
    {
        this.allArrivable = false;

        this.initOptions = new InitOptions(11, 55, 25, 60, 36);
        this.initOptions.initField();
        this.initOptions.addWallField();

        this.control = new ControlOperations(this.initOptions.getWall(), this.initOptions.getField());
        this.control.check();
        do
        {
            this.control.finalise();
            this.allArrivable = this.control.checkArrivable();
        }while(this.allArrivable == false);

        this.spanpoints = new SettingSpanpoints();
        this.spanpoints.Start();
    }