Example #1
0
            /// <summary>
            /// Read Nuget NuSpec File to Populate nugetSpec Object
            /// </summary>
            /// <param name="NuSpecPath"></param>
            /// <returns></returns>
            public nugetSpec ReadNuSpec(string NuSpecPath)
            {
                nugetSpec sln    = new nugetSpec();
                _AHK      ahk    = new _AHK();
                _Parse    prs    = new _Parse();
                string    nutext = ahk.FileRead(NuSpecPath);

                if (nutext != "")
                {
                    sln.csproj               = prs.XML_Text(nutext, "<id>");
                    sln.authors              = prs.XML_Text(nutext, "<authors>");
                    sln.version              = prs.XML_Text(nutext, "<version>");
                    sln.owners               = prs.XML_Text(nutext, "<owners>");
                    sln.LicenseURL           = prs.XML_Text(nutext, "<licenseUrl>");
                    sln.projecturl           = prs.XML_Text(nutext, "<projectUrl>");
                    sln.iconurl              = prs.XML_Text(nutext, "<iconUrl>");
                    sln.requireLicAcceptance = prs.XML_Text(nutext, "<requireLicenseAcceptance>").ToBool();
                    sln.description          = prs.XML_Text(nutext, "<description>");
                    sln.releasenotes         = prs.XML_Text(nutext, "<releaseNotes>");
                    sln.copyright            = prs.XML_Text(nutext, "<copyright>");
                    sln.tags = prs.XML_Text(nutext, "<tags>");
                }

                return(sln);
            }
Example #2
0
        /// <summary>Scintilla - Read File and Populate Control</summary>
        /// <param name="sci">Scintilla Control Name</param>
        /// <param name="FileName"> </param>
        public void OpenFile(Scintilla sci, string FileName)
        {
            string Code = ahk.FileRead(FileName);

            UpdateScintilla(sci, Code);  // update control with new text
            //this.Text = AppTitle + " - " + FileName;  // update app title with filename loaded
        }
        /// <summary>Scintilla - Read File and Populate Control</summary>
        /// <param name="sci">Scintilla Control Name</param>
        /// <param name="FileName"> </param>
        public static void OpenFile(this Scintilla Sci, string FileName)
        {
            _AHK ahk = new _AHK();
            _ScintillaControl sci = new _ScintillaControl();

            if (File.Exists(FileName))
            {
                string Code = ahk.FileRead(FileName);
                sci.UpdateScintilla(Sci, Code);
            }
        }
Example #4
0
        /// <summary>Reads a File's Contents into a Variable</summary>
        /// <param name="FilePath">Path to File to Read, Assumed to be in %A_WorkingDir% if Absolute Path isn't Specified</param>
        public static string FileRead(this string FilePath)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileRead(FilePath));
        }
Example #5
0
        /// <summary>Converts text from a text file to list <string>
        /// <param name="Input">Either Text String of Valid Text File Path</param>
        /// <param name="SkipBlankLines">Option To Skip Blank Lines in List Return</param>
        /// <param name="Trim">Option To Trim Each Line</param>
        /// <param name="SkipCommentLines">Skip Lines Starting with '//' (For Excluding C# Comments)</param>
        public static List <string> ToList(this string Input, string SplitChar = "NewLine", bool SkipBlankLines = true, bool Trim = true, bool SkipCommentLines = false)
        {
            _AHK          ahk  = new _AHK();
            List <string> list = new List <string>();

            if (Input == null)
            {
                return(list);
            }

            if (Input.CharCount() < 259) // valid number of chars for a file path
            {
                if (Input.IsFile())
                {
                    if (File.Exists(Input))
                    {
                        Input = ahk.FileRead(Input);
                    }
                }

                if (Input.IsDir())
                {
                    if (Directory.Exists(Input))
                    {
                        return(DirList(Input, "*.*", true, true));
                    }
                }
            }

            if (SplitChar == "NewLine" || SplitChar == "\n" || SplitChar == "\r" || SplitChar == "\n\r")
            {
                // Creates new StringReader instance from System.IO
                using (StringReader reader = new StringReader(Input))
                {
                    // Loop over the lines in the string.
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (SkipCommentLines)
                        {
                            string First2 = ahk.FirstCharacters(line, 2); // skip over lines if they are comments
                            if (First2 == @"//")
                            {
                                continue;
                            }
                        }

                        string writeline = line;

                        if (Trim)
                        {
                            writeline = line.Trim();
                        }                                      // trim leading spaces

                        if (SkipBlankLines)
                        {
                            if (writeline == "")
                            {
                                continue;
                            }
                        }

                        list.Add(writeline);
                    }
                }
            }
            else
            {
                return(ahk.StringSplit_List(Input, SplitChar, SkipBlankLines));
            }
            return(list);
        }