Exemple #1
0
        /// <summary>
        /// Append default EOL symbol \n to each line read in.
        /// </summary>
        /// <param name="file_path"></param>
        public Source(string file_path)
        {
            //
            m_SourceFile = new List <string>();
            using (var reader = new StreamReader(file_path))
            {
                for (; ;)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    else
                    {
                        m_SourceFile.Add(line + EOL.ToString());
                    }
                }
            }

            //
            m_LineNumber      = 0;
            m_CurrentPosition = 0;
        }
        /// <summary>
        /// The ToString implementation.
        /// </summary>
        /// <param name="format">The format specifier to use, e.g. <b>Console.WriteLine(workspace.ToString("L"));</b></param>
        /// <param name="provider">Allow clients to format output for their own types using [ICustomFormatter](https://msdn.microsoft.com/en-us/library/system.icustomformatter.aspx).</param>
        /// <returns>The formatted string.</returns>
        /// <exception cref="FormatException">thrown if an invalid format string is specified.</exception>
        /// \par Format specifiers:
        /// \arg \c G Name of the workspace, e.g. MARS_DEV3_barnyrd. Default when not using a format specifier.
        /// \arg \c LV Long version (verbose).
        /// \arg \c I Workspace ID number.
        /// \arg \c L Workspace [location](@ref AcUtils#AcWorkspace#Location).
        /// \arg \c S Location on the host ([storage](@ref AcUtils#AcWorkspace#Storage)) where the elements physically reside.
        /// \arg \c M Machine name ([host](@ref AcUtils#AcWorkspace#Host)) where the elements physically reside.
        /// \arg \c H \e True if the workspace is hidden, \e False otherwise.
        /// \arg \c D Depot name.
        /// \arg \c TL [Target level](@ref AcUtils#AcWorkspace#TargetLevel): how up-to-date the workspace should be.
        /// \arg \c UL [Update level](@ref AcUtils#AcWorkspace#UpdateLevel): how up-to-date the workspace actually is.
        /// \arg \c U Time of the oldest non-member file in the workspace with (\e modified) status, otherwise the time the \c update command was issued.
        /// \arg \c T [Workspace type](@ref AcUtils#WsType): standard, exclusive-file locking, anchor-required, or reference tree.
        /// \arg \c E [End-of-line character](@ref AcUtils#WsEOL) in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style.
        /// \arg \c PI Workspace owner's principal ID number.
        /// \arg \c PN Workspace owner's principal name.
        public string ToString(string format, IFormatProvider provider)
        {
            if (provider != null)
            {
                ICustomFormatter fmt = provider.GetFormat(this.GetType()) as ICustomFormatter;
                if (fmt != null)
                {
                    return(fmt.Format(format, this, provider));
                }
            }

            if (String.IsNullOrEmpty(format))
            {
                format = "G";
            }

            switch (format.ToUpperInvariant())
            {
            case "G":         // name of the workspace, e.g. MARS_DEV3_barnyrd
                return(Name); // general format should be short since it can be called by anything

            case "LV":        // long version (verbose)
                return($"{Name} ({ID}) {{{Type}}}{Environment.NewLine}" +
                       $@"Location: ""{Location}"", Storage: ""{Storage}""{Environment.NewLine}" +
                       $"Host: {Host}, ULevel-Target [{UpdateLevel}:{TargetLevel}]{((TargetLevel != UpdateLevel) ? " (incomplete)" : String.Empty)}{Environment.NewLine}" +
                       $"Depot: {Depot}, EOL: {EOL}, Hidden: {Hidden}{Environment.NewLine}");

            case "I":     // workspace ID number
                return(ID.ToString());

            case "L":     // workspace location
                return(Location);

            case "S":     // location on the host (storage) where the elements physically reside
                return(Storage);

            case "M":     // machine name (host) where the elements physically reside
                return(Host);

            case "H":     // True if workspace is hidden, False otherwise
                return(Hidden.ToString());

            case "D":     // depot name
                return(Depot.ToString());

            case "TL":     // how up-to-date the workspace should be
                return(TargetLevel.ToString());

            case "UL":     // how up-to-date the workspace actually is
                return(UpdateLevel.ToString());

            case "U":     // time of the oldest non-member file in the workspace with modified status, otherwise time the update command was issued
                return(FileModTime.ToString());

            case "T":     // type of workspace: standard, exclusive-file locking, anchor-required, or reference tree
                return(Type.ToString());

            case "E":     // end-of-line character in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style
                return(EOL.ToString());

            case "PI":     // ID number of the AccuRev principal who owns the workspace
                return(Principal.ID.ToString());

            case "PN":     // principal name of the workspace owner
                return(Principal.Name);

            default:
                throw new FormatException($"The {format} format string is not supported.");
            }
        }
Exemple #3
0
    //Checks if straight line from node1 to node2 crosses any platform
    bool PathDoesntCrossesTerrain(Node node1, Node node2)
    {
        int columnStart, columnEnd, rowStart, rowEnd;

        //Find max and min row and column
        if (node1.column > node2.column)
        {
            columnStart = node2.column;
            columnEnd   = node1.column;
            rowStart    = node2.row;
            rowEnd      = node1.row;
        }
        else if (node1.column < node2.column)
        {
            columnStart = node1.column;
            columnEnd   = node2.column;
            rowStart    = node1.row;
            rowEnd      = node2.row;
        }
        else
        {
            return(true);
        }

        if (node1.row == node2.row)
        {
            for (int column = columnStart; column < columnEnd; column++)
            {
                if (tileMap[node2.row, column] == 1)
                {
                    return(false);
                }
            }
            return(true);
        }
        EOL    eol = GetEquationOfLine(columnStart, rowStart, columnEnd, rowEnd);
        double a   = eol.a;
        double b   = eol.b;

        if (a < 0)
        {
            int y = 0;
        }
        //Find through which tiles line passes and if it passes trough tile with 1 (terrain tile) return flase
        for (int column = columnStart + 1; column < columnEnd; column++)
        {
            int rowUpper = (int)(a * column + b);
            int rowLower = (int)(a * (column + 1) + b);
            if (rowLower < rowUpper)
            {
                for (int row = rowLower; row <= rowUpper; row++)
                {
                    //Instantiate(spikes, new Vector3(column * tileSize.x + mapTranslation.x, (tileMap.GetLength(0) - row) * tileSize.y + mapTranslation.y, 0), Quaternion.identity);
                    if (tileMap[row, column] == 1)
                    {
                        return(false);
                    }
                }
            }

            else
            {
                for (int row = rowUpper; row <= rowLower; row++)
                {
                    //Instantiate(spikes, new Vector3(column * tileSize.x + mapTranslation.x, (tileMap.GetLength(0) - row) * tileSize.y + mapTranslation.y, 0), Quaternion.identity);

                    if (tileMap[row, column] == 1)
                    {
                        return(false);
                    }
                }
            }
        }
        return(true);
    }
Exemple #4
0
 public CsvOption(char delimiter, Encoding encoding, EOL eol)
 {
     Delimiter = delimiter;
     EOLType   = eol;
     Encoding  = encoding;
 }