public string Execute(params string[] parameters)
 {
     for (int i = 0; i < NumberOfTimes; i++)
     {
         OutputToConsole?.Invoke(this, string.Format(Message, i));
         Thread.Sleep(WaitTimeBetween);
     }
     return(null);
 }
        public string Execute(params string[] parameters)
        {
            int cnt = 0;

            OutputToConsole?.Invoke(this, "Active Tasks: ");
            foreach (var t in _manager.Tasks)
            {
                OutputToConsole?.Invoke(this, $"{t.Id}\t{t.Status}\t{t.Exception.Message}");
                cnt++;
            }
            return($"Listed {cnt} tasks");
        }
        public void OutputToFileOk()
        {
            var f = new OutputToConsole();

            f.OutputHull(new List <CPoint>()
            {
                new CPoint(50, 50), new CPoint(60, 50)
            });
            f.OutputPoints(new List <CPoint>()
            {
                new CPoint(50, 50), new CPoint(60, 50)
            });
        }
Beispiel #4
0
 private void OutputContent(object output)
 {
     if (Type == DumpType.Json)
     {
         OutputToConsole?.Invoke(this, JsonConvert.SerializeObject(output, new JsonSerializerSettings()
         {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented
         }));
     }
     else if (output is KeyValuePair <string, string> )
     {
         OutputToConsole?.Invoke(this, ((KeyValuePair <string, string>)output).Key + ": " + ((KeyValuePair <string, string>)output).Value);
     }
     else if (output is IContent)
     {
         var c = (IContent)output;
         OutputToConsole?.Invoke(this, "Content Object: " + c.Name);
         OutputToConsole?.Invoke(this, "\tKind: " + ((c is PageData) ? "Page" : (c is BlockData) ? "Block" : (c is MediaData) ? "Media" : "Other"));
         OutputToConsole?.Invoke(this, "\tParent: " + c.ParentLink.ToString());
         foreach (PropertyData p in (c as IContentData).Property)
         {
             OutputToConsole?.Invoke(this, "\t" + p.Name + ": " + HttpUtility.HtmlEncode(p.Value));
         }
     }
     else if (output is IDictionary <string, object> )
     {
         foreach (var kvp in ((IDictionary <string, object>)output))
         {
             OutputToConsole?.Invoke(this, "\t" + kvp.Key + ": " + HttpUtility.HtmlEncode(kvp.Value));
         }
     }
     else if (output is IDictionary)
     {
         foreach (var kvp in ((IDictionary)output).Keys)
         {
             OutputToConsole?.Invoke(this, "\t" + kvp + ":" + HttpUtility.HtmlEncode(((IDictionary)output)[kvp]));
         }
     }
     else if (output is IList)
     {
         OutputToConsole?.Invoke(this, "List: ");
         foreach (var itm in (output as IList))
         {
             OutputContent(itm);
         }
     }
     else
     {
         OutputToConsole?.Invoke(this, HttpUtility.HtmlEncode(output?.ToString()));
     }
 }
        public string Execute(params string[] parameters)
        {
            int cnt = 0;
            AccessTokenStore store = new AccessTokenStore();

            foreach (var at in store.ListTokens(ShowAllTokens))
            {
                OutputToConsole?.Invoke(this, $"{at.Id}\t{at.Owner}\t{at.Created.ToShortDateString()}");
                cnt++;
            }


            return($"{cnt} access token listed. ");
        }
Beispiel #6
0
        private void Source_OnCommandOutput(IOutputCommand sender, object output)
        {
            //accepts strings with urls

            string success = DownloadAsset((string)output);

            if (success == null)
            {
                OutputToConsole?.Invoke(this, $"Successfully downloaded asset {(string)output}");
            }
            else
            {
                OutputToConsole?.Invoke(this, $"Failed to download asset {Url} with error: {success}");
            }
        }
        public string Execute(params string[] parameters)
        {
            //TODO: Support a specific command in the parameters
            if (string.IsNullOrEmpty(Command) && parameters.Length > 0)
            {
                Command = parameters.First();
            }
            var cmdMgr = ServiceLocator.Current.GetInstance <CommandManager>();

            if (!string.IsNullOrEmpty(Command))
            {
                var cmd = cmdMgr.Commands[Command];
                OutputToConsole?.Invoke(this, "Command: " + cmd.Keyword);
                OutputToConsole?.Invoke(this, "Description: " + cmd.Info.Description);
                if (cmd.Info.Syntax != null)
                {
                    OutputToConsole?.Invoke(this, "Syntax: " + cmd.Info.Syntax);
                }
                OutputToConsole?.Invoke(this, "Parameters:");
                foreach (var p in cmd.Parameters.Keys)
                {
                    OutputToConsole?.Invoke(this, $"\t{cmd.Parameters[p].PropertyType.Name} {p}");
                }
            }
            else
            {
                //Retrieve a list of commands
                foreach (var cmd in cmdMgr.Commands.Values.OrderBy(cm => cm.Keyword))
                {
                    OutputToConsole?.Invoke(this, cmd.Keyword);
                    if (cmd.Info.Description != null)
                    {
                        OutputToConsole?.Invoke(this, "\t" + cmd.Info.Description);
                    }
                }
            }

            return(null);
        }
Beispiel #8
0
        private static IOutput GetOutputStrategy(string[] args)
        {
            IOutput output;

            if (args.Length > 1)
            {
                var outputFile = args[1];
                Console.WriteLine("Trying to write result to file: " + outputFile);
                output = new OutputToFile(outputFile);
            }
            else
            {
                Console.WriteLine("Enter target file name (or press Enter to output to console): ");
                var outputFile = Console.ReadLine();
                if (outputFile.Length > 0)
                {
                    output = new OutputToFile(outputFile);
                }
                output = new OutputToConsole();
            }

            return(output);
        }
Beispiel #9
0
        public string Execute(params string[] parameters)
        {
            int cnt = 0;

            if (OnCommandOutput == null)
            {
                OutputToConsole.Invoke(this, "Assemblies loaded: ");
            }
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                cnt++;
                if (OnCommandOutput != null)
                {
                    //Pass on
                    OnCommandOutput.Invoke(this, assembly);
                }
                else
                {
                    //Output
                    OutputToConsole.Invoke(this, "\t" + assembly.FullName);
                }
            }
            return($"{cnt} assemblies listed.");
        }
Beispiel #10
0
        public void CheckOutputOfConsole()
        {
            string[] word = { "test" };

            Assert.True(OutputToConsole.WordsDisplayOnConsole(word) == "Sucessful");
        }