Exemplo n.º 1
0
Arquivo: O.cs Projeto: gform/MinTetris
        public override List <int> GetLayout(OutputDestination destination)
        {
            int        position;
            List <int> layout = new List <int>();

            position = xPos + yPos * columns;
            if (destination == OutputDestination.Next)
            {
                position = 0;
                columns  = nextColumns;
            }
            switch (rotation)
            {
            case Rotation.rotate0:
            case Rotation.rotate180:
            case Rotation.rotate90:
            case Rotation.rotate270:
                layout.Add(position);
                layout.Add(position + 1);
                layout.Add(position + columns);
                layout.Add(position + columns + 1);
                TetroWidth  = 2;
                TetroHeight = 2;
                break;
            }
            return(layout);
        }
Exemplo n.º 2
0
        public void Report(
            OutputDestination destination,
            OutputFormat format,
            string reportName,
            string fileName,
            IReadOnlyCollection <PackageUpdateSet> updates)
        {
            if (updates == null)
            {
                throw new ArgumentNullException(nameof(updates));
            }

            var destinationDesc = destination == OutputDestination.File ?
                                  $" File '{fileName}'" :
                                  destination.ToString();

            _logger.Detailed($"Output report named {reportName}, is {format} to {destinationDesc}");

            using (var writer = MakeReportWriter(destination, fileName))
            {
                var reporter = MakeReporter(format, writer);
                reporter.Write(reportName, updates);
            }

            _logger.Detailed($"Wrote report for {updates.Count} updates");
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        /// <summary>
        /// <c>:ERROR</c> directive
        /// </summary>
        /// <param name="od">The od.</param>
        /// <param name="fileName">Name of the file.</param>
        public virtual void Error(OutputDestination od, string fileName)
        {
            if (od == OutputDestination.File)
            {
                if (!TryCreateOutputFile(fileName, FileMode.Create, out var stream))
                {
                    // If the file is not available because of permissions or other reasons, the output will not be switched and will be sent to the last specified or default destination.
                    return;
                }

                this.StderrDestination = od;
                this.stderrFile        = stream;
            }
            else
            {
                this.StderrDestination = od;

                if (this.stderrFile == null)
                {
                    return;
                }

                this.stderrFile.Dispose();
                this.stderrFile = null;
            }
        }
Exemplo n.º 4
0
        private static IReportWriter MakeReportWriter(
            OutputDestination destination,
            string fileName)
        {
            switch (destination)
            {
            case OutputDestination.Console:
                return(new ConsoleReportWriter());

            case OutputDestination.File:
                return(new FileReportWriter(fileName));

            case OutputDestination.Off:
                return(new NullReportWriter());

            default:
                throw new ArgumentOutOfRangeException($"Invalid OutputDestination: {destination}");
            }
        }
Exemplo n.º 5
0
        public HelloAPI()
        {
            // get config
            // also, in reality handle exception processing where we can
            // but it's never a terrible idea to fail completely if
            // all assumptions can't be made correctly for default behavior.

            var builder = new ConfigurationBuilder()
                          .SetBasePath(System.IO.Directory.GetCurrentDirectory())
                          .AddJsonFile("helloConfig.json", true);

            _configuration = builder.Build();

            // will default to console if bad value
            OutputDestination configDest;

            Enum.TryParse <OutputDestination>($"{_configuration["outputFormat"]}", out configDest);

            _output = configDest;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines whether the specified line is a match for this command type.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns>
        ///   <c>true</c> if the specified line is match; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="CommandSyntaxException">File name argument is missing</exception>
        public bool IsMatch(string line)
        {
            var m = this.CommandRegex.Match(line);

            if (!m.Success)
            {
                return(false);
            }

            var fn = m.Groups["filename"].Value;

            if (string.IsNullOrEmpty(fn))
            {
                throw new CommandSyntaxException(this.CommandType);
            }

            this.Filename          = fn.Unquote();
            this.OutputDestination = Enum.TryParse <OutputDestination>(fn, true, out var od) ? od : OutputDestination.File;

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleName"></param>
        /// <param name="fileName"></param>
        /// <param name="verboseFileName"></param>
        /// <param name="outputCategory"></param>
        /// <param name="outputDestination"></param>
        ///  <param name="appendLog">true to append to log</param>
        /// <returns></returns>
        ///
        internal static Logger GetLogger(
            string moduleName,
            string fileName,
            string verboseFileName,
            bool appendLog,
            OutputCategory outputCategory,
            OutputDestination outputDestination)
        {
            Logger logger = new Logger();

            logger.Log               = fileName;
            logger.LogVerbose        = verboseFileName;
            logger.SharedWrite       = true;
            logger.OutputCategory    = outputCategory;
            logger.OutputDestination = outputDestination;
            logger.DateOn            = true;
            logger.ModuleName        = moduleName;
            logger.Append            = appendLog;
            logger.StartLogging();

            return(logger);
        }
Exemplo n.º 8
0
 /// <inheritdoc />
 /// <summary>
 /// <c>:PERFTRACE</c> directive
 /// </summary>
 /// <param name="od">The od.</param>
 /// <param name="fileName">Name of the file.</param>
 public virtual void PerfTrace(OutputDestination od, string fileName)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Firefly.SqlCmdParser.InputSourceChangedEventArgs" /> class.
 /// </summary>
 /// <param name="nodeNumber">The execution node number.</param>
 /// <param name="newSource">The new source.</param>
 /// <param name="outputDestination">The output destination.</param>
 /// <inheritdoc />
 internal InputSourceChangedEventArgs(int nodeNumber, IBatchSource newSource, OutputDestination outputDestination)
     : base(nodeNumber, outputDestination)
 {
     this.Source = newSource;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="destination"></param>
 public ConsoleLogger(OutputDestination destination = OutputDestination.StdOut)
 {
     Destination = destination;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Firefly.SqlCmdParser.OutputMessageEventArgs" /> class.
 /// </summary>
 /// <param name="nodeNumber"></param>
 /// <param name="message">The message.</param>
 /// <param name="outputDestination">The output destination.</param>
 /// <inheritdoc />
 public OutputMessageEventArgs(int nodeNumber, string message, OutputDestination outputDestination)
     : base(nodeNumber, outputDestination)
 {
     this.Message = message;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParallelNodeEventArgs" /> class.
 /// </summary>
 /// <param name="nodeNumber">The node number.</param>
 /// <param name="outputDestination">The output destination.</param>
 protected ParallelNodeEventArgs(int nodeNumber, OutputDestination outputDestination)
 {
     this.NodeNumber        = nodeNumber;
     this.OutputDestination = outputDestination;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Firefly.SqlCmdParser.ConnectEventArgs" /> class.
 /// </summary>
 /// <param name="nodeNumber">The execution node number.</param>
 /// <param name="connection">The connection.</param>
 /// <param name="outputDestination">The output destination.</param>
 /// <inheritdoc />
 public ConnectEventArgs(int nodeNumber, SqlConnection connection, OutputDestination outputDestination)
     : base(nodeNumber, outputDestination)
 {
     this.Connection = connection;
 }
Exemplo n.º 14
0
 /// <summary>
 /// <c>:OUT</c> directive.
 /// </summary>
 /// <param name="outputDestination">The od.</param>
 /// <param name="outputFileProperties">The output file properties.</param>
 public virtual void Out(OutputDestination outputDestination, IOutputFileProperties outputFileProperties)
 {
     this.CreateStdoutFile(outputDestination, outputFileProperties.CreateMode, outputFileProperties.Path);
 }
Exemplo n.º 15
0
 /// <inheritdoc />
 /// <summary>
 /// <c>:OUT</c> directive.
 /// </summary>
 /// <param name="outputDestination">The outputDestination.</param>
 /// <param name="fileName">Name of the file.</param>
 public virtual void Out(OutputDestination outputDestination, string fileName)
 {
     this.CreateStdoutFile(outputDestination, FileMode.Create, fileName);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Firefly.SqlCmdParser.OutputResultEventArgs" /> class.
 /// </summary>
 /// <param name="nodeNumber">The execution node number.</param>
 /// <param name="result">The result set, e.g. <c>DataTable</c> or <c>DataReader</c></param>
 /// <param name="outputDestination">The output destination.</param>
 /// <param name="outputStream">The output stream to write to if the destination is file.</param>
 /// <inheritdoc />
 public OutputResultEventArgs(int nodeNumber, dynamic result, OutputDestination outputDestination, Stream outputStream)
     : base(nodeNumber, outputDestination)
 {
     this.Result       = result;
     this.OutputStream = outputStream;
 }
Exemplo n.º 17
0
 //Virtual method for derived figure classes, returns the shape of the figure
 //Віртуальний метод для дочірніх фігур, повертає форму фігури
 public virtual List <int> GetLayout(OutputDestination destination)
 {
     return(null);
 }