Beispiel #1
0
        public string Parse(IParsedObject parent, ref System.IO.StreamReader file, params object[] parts)
        {
            if (!(parent is TaskContainer)) {
                throw new SyntaxErrorException ();
            }
            var name = (string)parts[0];
            var _do = (string)parts[1];

            var match = Regex.Match (name, ":(\\w+)");
            if (!match.Success)
                throw new SyntaxErrorException ();
            name = match.Groups[1].Value;

            string line = null;
            if (_do != "do") {
                while (!string.IsNullOrEmpty (line = file.ReadLine ())) {
                    match = Regex.Match (line, "^\\s*do\\b(.*)");
                    if (!match.Success) {
                        if (EmptyLine (line)) {
                            continue;
                        } else {
                            throw new SyntaxErrorException ();
                        }
                    } else {
                        _do = "do";
                        line = match.Groups[1].Value;
                        break;
                    }
                }
                if (_do != "do")
                    throw new SyntaxErrorException ();
            } else {
                line = (string)parts[2];
            }

            var _namespace = new PlainNamespace (name, parent);
            var end = false;
            do {
                if (string.IsNullOrEmpty(line)) continue;
                var child = CrakeFileParser.MatchKeyword (_namespace, ref file, line);
                match = Regex.Match (child, "^\\s*end\\b(.*)");
                if (match.Success) {
                    line = match.Groups[1].Value;
                    end = true;
                    break;
                }
            } while (!string.IsNullOrEmpty (line = file.ReadLine ()));

            if (!end)
                throw new SyntaxErrorException ();

            if (_namespace.LastDesc != null) throw new SyntaxErrorException("desc for no task");

            foreach (var task in _namespace.Tasks) {
                task.Name = string.Format ("{0}:{1}", _namespace.Name, task.Name);
                ((TaskContainer)parent).Tasks.Add (task);
            }

            return line;
        }
        public void ReadFromStream(System.IO.StreamReader streamReader)
        {
            BaseBagUpgradePrice = Convert.ToInt32(StringUtilities.GrabVariableFromString(streamReader.ReadLine(), '='));
            BagUpgradePricePercentageIncrease = Convert.ToInt32(StringUtilities.GrabVariableFromString(streamReader.ReadLine(), '='));
            MaximumAmountOfBagSpace = Convert.ToInt32(StringUtilities.GrabVariableFromString(streamReader.ReadLine(), '='));

            bool shouldContinueToRead = true;
            while (shouldContinueToRead)
            {
                string line = streamReader.ReadLine();
                if (Program.IsComment(line))
                {
                    continue;
                }
                else
                {
                    switch (line.ToLower())
                    {
                        case "default money:":
                        case "default_money:":
                        case "defaultmoney:":
                            DefaultMoney.ReadFromStream(streamReader);
                            shouldContinueToRead = false;
                            break;
                    }
                }
            }
        }
        public static bool TryReadMetadataForCachedAssetBundle(System.IO.StreamReader reader, out ABMetadata abMeta)
        {
            abMeta = null;

            if (reader == null) return false;

            string bundlenameIn = reader.ReadLine();
            if (bundlenameIn == null) return false;

            string etagIn = reader.ReadLine();
            if (etagIn == null) return false;

            string crcStringIn = reader.ReadLine();
            if (crcStringIn == null) return false;
            uint crcIn = 0;
            if (!uint.TryParse(crcStringIn, out crcIn)) return false;

            string versionStringIn = reader.ReadLine();
            if (versionStringIn == null) return false;
            int versionInt = 0;
            if (!int.TryParse(versionStringIn, out versionInt)) return false;

            abMeta = new ABMetadata(etagIn, crcIn, bundlenameIn, versionInt);

            return true;
        }
Beispiel #4
0
        private static IEnumerable<XElement> GetXmlElements(System.IO.TextReader f)
        {
            //read until nex interesting element;
            var line = "";
            var interestings = new[] {"OBJECT", "LINK", "ATTR-VALUE", "ATTRIBUTE" };
            var attributeName = "";
            while ((line = f.ReadLine())!=null)
            {
                line = line.Trim();
                var nextOOI = interestings.FirstOrDefault( i => line.StartsWith("<"+i+" ") );
                if (nextOOI == null)
                    continue;
                //If it is the attribute tag, get the current atttribute name
                if (nextOOI == "ATTRIBUTE")
                {
                    attributeName = line.Split(new[] { "NAME=\"" }, 2, StringSplitOptions.RemoveEmptyEntries)[1].Split("\"".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries)[0];
                    continue;
                }
                //Read to the end of the tag
                var xml = line;
                if (!xml.Contains("/>"))
                    while (!xml.Contains("</" + nextOOI))
                        xml += f.ReadLine();
                var rv = XElement.Parse(xml);

                if (nextOOI == "ATTR-VALUE")
                {
                    rv.Add(new XAttribute("NAME", attributeName));
                }
                yield return rv;
            }
        }
 void ReadLines(System.IO.StreamReader reader)
 {
     words = new List<String>();
     string line = reader.ReadLine();
     while (line != null) {
         string[] splitLine = line.Trim().Split('\t');
         if (splitLine.Length >= 2) {
             words.Add(splitLine[1]);
         }
         line = reader.ReadLine();
     }
 }
		private static string NextLine (System.IO.TextReader reader)
		{
			string line = reader.ReadLine();
			if (line != null)
				while (line.EndsWith("_"))
				{
					string nextline = reader.ReadLine();
					if (nextline == null)
						nextline = string.Empty;
					line = line.Substring(0, line.Length-1) + "\n" + nextline;
				}
			return line;
		}
Beispiel #7
0
		/// <summary>
		/// Create tag dictionary object with contents of specified file and using specified case to determine how to access entries in the tag dictionary.
		/// </summary>
		/// <param name="reader">
		/// A reader for the tag dictionary.
		/// </param>
		/// <param name="caseSensitive">
		/// Specifies whether the tag dictionary is case sensitive or not.
		/// </param>
		public PosLookupList(System.IO.StreamReader reader, bool caseSensitive)
		{
            mDictionary = new Dictionary<string, string[]>();
			mIsCaseSensitive = caseSensitive;
			for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
			{
				string[] parts = line.Split(' ');
				string[] tags = new string[parts.Length - 1];
				for (int currentTag = 0, tagCount = parts.Length - 1; currentTag < tagCount; currentTag++)
				{
					tags[currentTag] = parts[currentTag + 1];
				}
				mDictionary[parts[0]] = tags;
			}
		}
Beispiel #8
0
        /*This reads the size of the bank and then reads each of the accounts in turn
        and adds it to the hash table.*/
        public static HashBank Load(System.IO.TextReader textIn)
        {
            HashBank result = new HashBank();
            string countString = textIn.ReadLine();
            int count = int.Parse(countString);

            for (int i = 0; i < count; i++)
            {
                string className = textIn.ReadLine();
                IAccount account =
                    AccountFactory.MakeAccount(className, textIn);
                result.bankHashtable.Add(account.GetName(), account);
            }
            return result;
        }
Beispiel #9
0
        public static int SearchB64Combined(System.IO.TextReader reader, List<Found> found)
        {
            int startCount = found.Count;
            int lineCount = 0;
            int startLine = 0;
            string line;
            System.Text.StringBuilder concatd = new StringBuilder();
            while (reader.Peek() != -1 && (line = reader.ReadLine()) != null)
            {
                if (s_isB64.IsMatch(line))
                {
                    concatd.Append(line);
                    Match m = s_B64Parser.Match(concatd.ToString());
                    if (m.Success)
                    {
                        Found f = new Found() { Line = startLine, Match = m.Value };
                        AddGuidsFromBytes(Convert.FromBase64String(m.Value), f);
                        found.Add(f);
                        startLine = lineCount+1;
                        concatd.Clear();
                    }
                }
                else
                {
                    concatd.Clear();
                    startLine = lineCount+1;
                }
                lineCount++;

            }
            return found.Count - startCount;
        }
Beispiel #10
0
 /// <summary>
 /// Loads a tick straight from an EPF file in the form of a StreamReader
 /// </summary>
 /// <param name="symbol">The symbol.</param>
 /// <param name="sr">The sr.</param>
 /// <returns></returns>
 public static eSigTick FromStream(string symbol, System.IO.StreamReader sr)
 {
     eSigTick e = new eSigTick();
     e.Load(sr.ReadLine());
     e.sym = symbol;
     return e;
 }
Beispiel #11
0
        static void Main(string[] args)
        {
            const string filePath = "Sentence.txt";

            StreamReader reader = new StreamReader(C: \Users\Sick\Documents\Homework\C#Homeworks\C-Homeworks\Homework 10\Homework 11 part 3);

            int linesCounter = 0;

            string Newline;

            using (reader)
            {

                while (!string.IsNullOrWhiteSpace(Newline = reader.ReadLine()))
                {
                    try
                    {
                        CheckForPunctuation(Newline);

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
Beispiel #12
0
        public Settings(System.IO.TextReader conf)
        {
            QuickFix.Dictionary currentSection = null;

            string line = null;
            while ((line = conf.ReadLine()) != null)
            {
                line = line.Trim();
                // TODO: make this more generic
                if (line.Contains("$AppPath"))
                {
                    line = line.Replace("$AppPath", System.AppDomain.CurrentDomain.BaseDirectory);
                }
                if (IsComment(line))
                {
                    continue;
                }
                else if (IsSection(line))
                {
                    currentSection = Add(new Dictionary(SplitSection(line)));
                }
                else if (IsKeyValue(line) && currentSection != null)
                {
                    string[] kv = line.Split(new char[]{'='}, 2);
                    currentSection.SetString(kv[0].Trim(), kv[1].Trim());
                }
            }
        }
        public static List<Employee> Load(System.IO.StreamReader stream)
        {
            List<Employee> list = new List<Employee>();

            try
            {
                while (stream.Peek() >= 0)
                {
                    string line = stream.ReadLine();

                    string[] values = line.Split(',');
                    Employee employee = new Employee();
                    employee.FirstName = values[0];
                    employee.LastName = values[1];
                    employee.Email = values[2];

                    list.Add(employee);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                stream.Close();
            }

            return list;
        }
Beispiel #14
0
    public Class1()
    {
        string[] InputText;
        int[]    RepeatedLettersCal = new int[26];
        System.WriteLine("Enter the Text you want to calculate the upper case letter times of reapeat ");
        InputText = System.ReadLine();

        foreach (char c in InputText)
        {
            int UperCaseLetters = 65;
            for (int i = 0; i < 26; i++)
            {
                if (UperCaseLetters == RepeatedLettersCal[i])
                {
                    RepeatedLettersCal[i]++;
                }
                UperCaseLetters++;
            }
        }
        char c = 'A';

        foreach (char i in RepeatedLettersCal)
        {
            System.WriteLine(c + "\t" + i);
        }
    }
Beispiel #15
0
		public void LoadStateText(System.IO.TextReader reader)
		{
			string hex = reader.ReadLine();
			byte[] state = new byte[hex.Length / 2];
			state.ReadFromHex(hex);
			LoadStateBinary(new BinaryReader(new MemoryStream(state)));
		}
 public override student Read(System.IO.StreamReader sr)
 {
     String record = sr.ReadLine();
     int length = record[0] - '0';
     string result = record.Substring(1, length);
     record = record.Substring(length + 1);
     return this.GetFields(result);
 }
Beispiel #17
0
		public void LoadStateText(System.IO.TextReader reader)
		{
			CheckDisposed();
			string hex = reader.ReadLine();
			byte[] state = new byte[hex.Length / 2];
			state.ReadFromHexFast(hex);
			LoadStateBinary(new System.IO.BinaryReader(new System.IO.MemoryStream(state)));
		}
Beispiel #18
0
        public virtual void ReadFromStream(System.IO.StreamReader streamReader)
        {
            string textToExtractVariablesFrom = streamReader.ReadLine(); // The text to extract variables from

            string nameValue = textToExtractVariablesFrom.Substring(textToExtractVariablesFrom.IndexOf('=') + 1, textToExtractVariablesFrom.Length - 1 - textToExtractVariablesFrom.IndexOf('='));

            Name = nameValue;
        }
Beispiel #19
0
    void reset(System.IO.StreamReader file, Transform t)
    {
        string readText;
        foreach (Transform child in t)
        {
            readText = file.ReadLine();
            float rx = float.Parse(readText);
            readText = file.ReadLine();
            float ry = float.Parse(readText);
            readText = file.ReadLine();
            float rz = float.Parse(readText);

            child.transform.localEulerAngles = new Vector3(rx, ry, rz);

            readText = file.ReadLine();
            float px = float.Parse(readText);
            readText = file.ReadLine();
            float py = float.Parse(readText);
            readText = file.ReadLine();
            float pz = float.Parse(readText);

            child.position = new Vector3(px, py, pz);
            file.ReadLine();
            reset(file, child);
        }
    }
 private bool searchFile(System.IO.StreamReader sReader)
 {
     string line;
     while ((line = sReader.ReadLine()) != null)
     {
         if (line.Contains(Text)) return true;
     }
     return false;
 }
Beispiel #21
0
 void treeRead(System.IO.StreamReader file, Transform t)
 {
     string readText;
     while((readText = file.ReadLine()) != null)
     {
         Debug.Log(readText);
         reset(file,t);
     }
 }
Beispiel #22
0
    private void ParseOrdersFile(System.IO.StreamReader file, int factionID)
    {
        /*
         * keep reading orders in the file until we hit "End"
         *
         * Currently available orders are:
         * -enlist
         * -end
         */
        string s;
        s = file.ReadLine();
        if (int.Parse(s) == factionID)
        {
            // faction IDs match - do nothing
        }
        else
        {
            Debug.Log("bug with faction ID");
        }

        // get (potentially new) faction name
        f[factionID].fname = file.ReadLine();
        // read in active city/commander... we don't really care about this just now
        s = file.ReadLine();
        bool keepreading = true;
        while (keepreading)
        {
            s = file.ReadLine();
            switch (s)
            {
            case "End":
                keepreading = false;
                break;
            case "Enlist":
                int tileID = int.Parse(file.ReadLine());
                ProcessEnlistOrder(factionID, tileID);
                break;
            default:
                keepreading = false;
                break;
            }
        }
    }
Beispiel #23
0
        /// <summary>
        /// Returns the next non blank line
        /// </summary>
        /// <param name="fin"></param>
        /// <returns></returns>
        protected String GetNextLine(System.IO.StreamReader fin)
        {
            String retVal = fin.ReadLine();
            while (retVal == " " || retVal == "\n")
            {
                retVal = fin.ReadLine();
            }

            return retVal;
        }
 public DelimitedTextReader(System.IO.StreamReader reader, IFormatProvider formatProvider, params char[] splitter)
 {
     this.splitter = splitter;
     this.line = reader.ReadLine();
     this.reader = reader;
     this.names = this.line.Split(splitter);
     for (int i = 0; i < this.names.Length; i++)
         this.names[i] = this.names[i].Trim();
     this.formatProvider = formatProvider;
     this.closed = false;
 }
 public static IEnumerable<Found> Find(System.IO.TextReader reader, string type)
 {
     IGuidSearcher searcher;
     if (!s_SearchesByKey.TryGetValue(type, out searcher)) throw new ArgumentOutOfRangeException();
     int lineCount = 0;
     string line;
     while (reader.Peek() != -1 && (line = reader.ReadLine()) != null)
     {
         foreach(Found found in searcher.Find(line, lineCount++)) yield return found;
     }
 }
Beispiel #26
0
		/// <summary> Reads lines from a Reader and adds every line as an entry to a HashSet (omitting
		/// leading and trailing whitespace). Every line of the Reader should contain only
		/// one word. The words need to be in lowercase if you make use of an
		/// Analyzer which uses LowerCaseFilter (like StandardAnalyzer).
		/// </summary>
		/// <param name="reader">Reader containing the wordlist</param>
		/// <returns>A HashSet with the reader's words</returns>
		public static ISet<string> GetWordSet(System.IO.TextReader reader)
		{
            var result = Support.Compatibility.SetFactory.CreateHashSet<string>();

			System.String word;
			while ((word = reader.ReadLine()) != null)
			{
				result.Add(word.Trim());
			}

			return result;
		}
 /**
 * Places all member info from the input file into the global membership
 * linked list
 * @param input the stream reader that will be used to read in the file as
 * defined by the argument
 */
 public static void createMembershipList(System.IO.StreamReader input)
 {
     // while the file can be read, each line of information is read
     // and is used to create a new customer
     String line;
     while ((line = input.ReadLine()) != null)
     {
         String[] c = line.Split(',');
         long t = Convert.ToInt64(c[2].Trim());
         Global.members.AddLast(new Customer(c[0], c[1], t));
     }
 }
Beispiel #28
0
 public void Load(System.IO.StreamReader file)
 {
     for (int i = 0; i < BgTileMap.worldSize; i++)
     {
         System.IO.StringReader stringReader = new System.IO.StringReader(file.ReadLine());
         for (int j = 0; j < BgTileMap.worldSize; j++)
         {
             BgTileMap.bgtiles[i, j].texID = stringReader.Read() - (int)'0';
             BgTileMap.bgtiles[i, j].UpdatePassability();
         }
     }
 }
Beispiel #29
0
        private string ReadTableName(string text, System.IO.StreamReader streamReader, out string tableText)
        {
            tableText = null;
            string tableName = null;
            while (!text.Contains("("))
            {
                text = text + streamReader.ReadLine();
            }
            // TODO: use regular expression to match out the table name and output the columns text.

            return tableName;
        }
        protected override System.Collections.IEnumerable ParseData(System.IO.TextReader dataReader)
        {
            string line;
            List<Institution> institutionInfos = new List<Institution>();

            while ((line = dataReader.ReadLine()) != null)
            {
                if (string.IsNullOrEmpty(line))
                    continue;
                
                string[] data = line.Split(',');

                var newInstitution = new Institution();
                newInstitution.Name = data[0];
                
                int intVal;
                
                if(int.TryParse(data[1], out intVal))
                    newInstitution.SmartRank  = intVal;

                if(int.TryParse(data[2], out intVal))
                    newInstitution.AcceptanceRate  = intVal;

                if(int.TryParse(data[3], out intVal))
                    newInstitution.TotalEnrolledStudents  = intVal;

                if(int.TryParse(data[4], out intVal))
                    newInstitution.AverageSATMathScore  = intVal;

                if(int.TryParse(data[5], out intVal))
                    newInstitution.AverageSATVerbalScore  = intVal;

                if(int.TryParse(data[6], out intVal))
                    newInstitution.AverageSATCompositeScore  = intVal;

                if(int.TryParse(data[7], out intVal))
                    newInstitution.FulltimeRetentionRate  = intVal;

                if(int.TryParse(data[8], out intVal))
                    newInstitution.InStateTuition  = intVal;

                if(int.TryParse(data[9], out intVal))
                    newInstitution.OutOfStateTuition  = intVal;
                
                if(int.TryParse(data[10], out intVal))
                    newInstitution.Endowment  = intVal;
                
                institutionInfos.Add(newInstitution);
            }

            return institutionInfos;
        }
Beispiel #31
0
 public void RunCA5(System.IO.StreamReader CA_File)
 {
     // Minimum of Three
     string rst = "";
     string line;
     int[] nums;
     while ((line = CA_File.ReadLine()) != null)
     {
         nums = Array.ConvertAll(line.Split(), int.Parse);
         rst = rst + nums.Min().ToString() + " ";
     }
     Console.WriteLine(rst);
 }
Beispiel #32
0
    void Main()
    {
        int num, sum = 0, r;

        System.WriteLine("Enter a Number : ");
        num = Parse(Console.ReadLine());
        while (num != 0)
        {
            r   = num % 10;
            num = num / 10;
            sum = sum + r;
        }
        System.WriteLine("Sum of Digits of the Number : " + sum);
        System.ReadLine();
    }