Esempio n. 1
0
        public int CompareTo(object obj)
        {
            var other = obj as BreakPoint;

            if (File == null && other == null)
            {
                return(1);
            }

            //same file?
            var result = string.Compare(File, other.File, StringComparison.OrdinalIgnoreCase);

            if (result != 0)
            {
                return(result);
            }

            //same column?
            result = FileColumn.CompareTo(other.FileColumn);
            if (result != 0)
            {
                return(result);
            }

            //same line?
            result = FileLine.CompareTo(other.FileLine);
            if (result != 0)
            {
                return(result);
            }

            //same file, same column, same line: must be same breakpoint
            return(0);
        }
Esempio n. 2
0
    //Loads in all the data from the master item list text file, organize items from the FullItemList into the FullItemDictionary by combining the ItemData with what was read from the text file
    private void Awake()
    {
        //Assign our singleton class instance
        Instance = this;

        //Import the master item list file listening every item and its ItemNumber values
        string[] FileLines = System.IO.File.ReadAllLines(Application.dataPath + "/Exports/MasterItemList.txt");
        Log.PrintChatMessage("Reading " + FileLines.Length + " lines in the MasterItemList file");
        //string[] FileLines = System.IO.File.ReadAllLines("C:/Users/Harley/Desktop/mmo-client/Assets/Exports/MasterItemList.txt");

        //Look through and process each line of the text file
        foreach (string FileLine in FileLines)
        {
            //Split apart each line of the file to seperate the items information apart
            string[] LineSplit = FileLine.Split(':');

            //Each line should split into 5 parts, being the Name, DisplayName, Type, Slot and ItemNumber values
            string        ItemName        = LineSplit[0];
            string        ItemDisplayName = LineSplit[1];
            ItemType      ItemType        = FindItemType(LineSplit[2]);
            EquipmentSlot ItemSlot        = FindItemSlot(LineSplit[3]);
            int           ItemNumber      = Int32.Parse(LineSplit[4]);

            //Fetch the relevant items ItemData object from the FullItemList array, using the ItemName to find it
            ItemData ItemData = GetItemData(ItemName);
            //Update the items ItemNumber value, then store it into the dictionary with the ItemNumber as its key
            ItemData.ItemNumber = ItemNumber;
            FullItemDictionary.Add(ItemNumber, ItemData);
        }
    }
 //class constructor
 public ReadStatsGeneral(string NetworkName)
     : base(NetworkName)
 {
     AverageDelay = 0;
     DelayCount   = 0;
     using (StreamReader ReadFile = new StreamReader((LogDir + @"\stats-general.csv")))
     {
         try
         {
             string FileLine;
             string data = "";
             while ((FileLine = ReadFile.ReadLine()) != null)
             {
                 if (!FileLine.Contains("Day"))
                 {
                     data = FileLine;
                     DelayCount++;
                 }
             }
             string[] SplitLine = data.Split(',');
             AverageDelay = Convert.ToDouble(SplitLine[5]);
         }
         catch (Exception e)
         {
             // Let the user know what went wrong.
             Console.WriteLine("The events file could not be read:");
             Console.WriteLine(e.Message);
         }
     }
 }
Esempio n. 4
0
        public async Task <FileLine> GetStats(RetrievedDataModel retrived)
        {
            try
            {
                var fileLine = new FileLine();
                if (retrived != null)
                {
                    // Quantidade de vendedores
                    fileLine.SalesmanCount = GetSalesmanLength(retrived.Salesmans);

                    // Quantidade de clientes
                    fileLine.CustomerCount = GetCustomerLength(retrived.Custumers);

                    // Id da venda mais cara
                    fileLine.MostExpensive = GetMostExpensive(retrived.SalesData);

                    // Nome do pior vendedor
                    fileLine.WorseSalesman = GetWorseSalesman(retrived.SalesData);
                }

                return(await Task.FromResult(fileLine));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 5
0
        public static void Compact()
        {
            Assert.True(
                string.Equals(
                    "Member, File.cs:5",
                    FileLine.Compact(
                        "File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));

            Assert.True(
                string.Equals(
                    "Member, File.cs:5",
                    FileLine.Compact(
                        @"c:\dir1\dir2\File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));

            Assert.True(
                string.Equals(
                    "Member, File.cs:5",
                    FileLine.Compact(
                        @"/mnt/sdcard/File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));
        }
Esempio n. 6
0
        public static ICollection <KeyValuePair <string, string> > ReadFileWithCheckSum(string path)
        {
            FilesWithHash = new Dictionary <string, string>();


            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    string FileLine;
                    string FilePath;
                    string FileHash;

                    while (!sr.EndOfStream)
                    {
                        FileLine = sr.ReadLine();
                        FilePath = FileLine.Substring(0, FileLine.IndexOf("|"));
                        FileHash = FileLine.Substring(FileLine.IndexOf("|") + 1, FileLine.Length - 1 - FilePath.Length);
                        FilesWithHash.Add(new KeyValuePair <string, string>(FilePath, FileHash));
                        //  Console.WriteLine(FilePath + " " + FileHash);
                    }
                }
            }

            catch (Exception e) { Console.WriteLine(e.Message + "\n" + e.StackTrace); }

            return(FilesWithHash);
        }
Esempio n. 7
0
        public string LinkTurningFile = @"C:\Documents and Settings\Siemens\Desktop\Andrew's Work\Paramics Models\Sopers\SopersLaneApproachMovements.txt"; //This is the clockwise link order
        //public string LinkFile = @"C:\Documents and Settings\Siemens\Desktop\Andrew's Work\Paramics Models\Poole Junction\Paramics 2010.1 Version\Cabot Lane Poole V3\links";
        //public string PrioritiesFile = @"C:\Documents and Settings\Siemens\Desktop\Andrew's Work\Paramics Models\Poole Junction\Paramics 2010.1 Version\Cabot Lane Poole V3\priorities";
        //public string PrioritiesStages = @"C:\Documents and Settings\Siemens\Desktop\Andrew's Work\Paramics Models\Simple Crossroads\Simple Crossroads\priorities_file"; //This is the required stage


        /// <summary>
        /// This  returns the link number being turned onto. (i.e. moving from link 1 0 to link 0 3
        /// would return '3'.
        /// </summary>
        /// <returns></returns>
        public string NextLinkNumber(string ApproachNode, string JunctionNode, string TurningNumber)
        {
            string Returner             = "";
            string WithoutCommaReturner = "";

            using (StreamReader ReadFile = new StreamReader(LinkTurningFile))
            {
                string FileLine;
                while ((FileLine = ReadFile.ReadLine()) != null)
                {
                    if (FileLine.Contains("Link " + ApproachNode + " " + JunctionNode + ": "))
                    {
                        string[] SplitString = FileLine.Split(' ');
                        Returner             = SplitString[3 + Convert.ToInt16(TurningNumber)];
                        WithoutCommaReturner = Returner.Substring(0, Returner.Length - 1);
                        return(WithoutCommaReturner);
                        //break;
                    }
                }
            }

            /*using (StreamReader ReadFile = new StreamReader(LinkFile))
             * {
             *  string FileLine2;
             *  while ((FileLine2 = ReadFile.ReadLine()) != null)
             *  {
             *      if (FileLine2.Contains("link " + JunctionNode + " " + WithoutCommaReturner))
             *      {
             *          return WithoutCommaReturner;
             *      }
             *  }
             * }*/
            return("null");
        }
Esempio n. 8
0
        public List <AsbtractRenderCommand> Parse(FileLine line, IMessageHandler messageHandler)
        {
            var commands = new List <AsbtractRenderCommand>();

            //
            var beginSpan       = line.CreateOriginalTextSpan(line.BeginNonSpace, line.BeginNonSpace + 1); //skip matched character
            var scriptBegin     = line.Text.IndexOfNot(beginSpan.End, line.End, CharExtensions.IsSpace);
            var indentationSpan = line.CreateOriginalTextSpan(beginSpan.End, scriptBegin);

            if (indentationSpan.IsEmpty == false)
            {
                var endSpan = line.CreateOriginalTextSpan(indentationSpan.End, indentationSpan.End);
                commands.Add(new PushIndentationCommand(beginSpan, indentationSpan, endSpan));
            }

            //
            var statementSpan    = line.CreateOriginalTextSpan(indentationSpan.End, line.End);
            var statementEndSpan = line.CreateOriginalTextSpan(statementSpan.End, statementSpan.End);

            if (statementSpan.IsEmpty == false)
            {
                commands.Add(new StatementCommand(statementSpan, statementEndSpan));
            }

            //
            if (indentationSpan.IsEmpty == false)
            {
                var popIndentationSpan = line.CreateOriginalTextSpan(line.End, line.End);
                commands.Add(new PopIndentationCommand(popIndentationSpan));
            }

            return(commands);
        }
        public static string GetDescription(this FileLine fileLine, string format)
        {
            var words       = GetWords(format);
            var @properties = fileLine.GetType().GetProperties();

            foreach (var word in words)
            {
                var value    = "";
                var property = @properties.FirstOrDefault(i => i.Name.EndsWith(word));

                if (property != null)
                {
                    var descriptionAttribute = property
                                               .GetCustomAttributes(typeof(DescriptionAttribute), false)
                                               .FirstOrDefault() as DescriptionAttribute;

                    if (descriptionAttribute != null)
                    {
                        value = descriptionAttribute.Description;
                    }

                    format = format.Replace(String.Concat("{", $"{ word }", "}"), value.ToString());
                    format = format.Replace(word, value.ToString());
                }
            }

            return(format);
        }
Esempio n. 10
0
        public int CompareTo(object obj)
        {
            BreakPoint other = obj as BreakPoint;

            //same file?
            int result = File.CompareTo(other.File);

            if (result != 0)
            {
                return(result);
            }

            //same column?
            result = FileColumn.CompareTo(other.FileColumn);
            if (result != 0)
            {
                return(result);
            }

            //same line?
            result = FileLine.CompareTo(other.FileLine);
            if (result != 0)
            {
                return(result);
            }

            //same file, same column, same line: must be same breakpoint
            return(0);
        }
        public EditLink(String NetPath)
            : base(NetPath)
        {
            FileName = "links";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string FileLine;

                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (FileLine.Contains("link ") && FileLine.Contains("category"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            string   StartNode = splitline[1];
                            string   EndNode   = splitline[2];
                            int      Cat       = Convert.ToInt32(splitline[4]);

                            LinkList.Add(new N_W_Link(StartNode, EndNode, Cat, false));//TODO un hardcode false to read oneway data from file
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The pathroutes file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
        //*Constructors
        public EditNodes(string NetPath)
            : base(NetPath)
        {
            FileName = "nodes";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string   FileLine;
                    N_W_Node temp = new N_W_Node();
                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (FileLine.Contains("node "))
                        {
                            string[] splitline  = FileLine.Split(new Char[] { ' ' });           // split the line up into an array of strings
                            string   NodeNum    = splitline[1];
                            string[] splitline2 = FileLine.Split(new Char[] { 't', 'm', ',' }); // split the line up into an array of strings
                            double   X          = Convert.ToDouble(splitline2[1]);
                            double   Y          = Convert.ToDouble(splitline2[3]);
                            double   Z          = Convert.ToDouble(splitline2[5]);
                            //temp = new N_W_Node(NodeNum,X,Y,Z);
                            NodeList.Add(new N_W_Node(NodeNum, X, Y, Z));
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The pathroutes file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(FileLineProcessingIgnoredEvent domainEvent)
        {
            // find the line
            FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber);

            fileLine.ProcessingResult = ProcessingResult.Ignored;
        }
Esempio n. 14
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(FileLineProcessingFailedEvent domainEvent)
        {
            FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber);

            fileLine.TransactionId    = domainEvent.TransactionId;
            fileLine.ProcessingResult = ProcessingResult.Failed;
        }
Esempio n. 15
0
        private static bool SameMemberAsTopPartialStackTrace(Exception e, string file, string member)
        {
            const string key = "PartialStackTrace";

            if (!TryGetValue(e, key, out string partialStackTrace))
            {
                return(false);
            }

            int    firstLineEndsAt = partialStackTrace.IndexOf('\r');
            string firstLine       = firstLineEndsAt == -1 ? partialStackTrace : partialStackTrace.Substring(0, firstLineEndsAt);

            string pstFile, pstMember;

            try
            {
                FileLine.ParseCompact(firstLine, out pstFile, out pstMember, out _);
            }
            catch
            {
                return(false);
            }

            return(string.Equals(pstFile, file, StringComparison.Ordinal) &&
                   string.Equals(pstMember, member, StringComparison.Ordinal));
        }
Esempio n. 16
0
        /*public string StageRequired(string ApproachNode, string NextLinkNumber)
         * {
         *  string Returner = "";
         *  using (StreamReader ReadFile = new StreamReader(PrioritiesStages))
         *  {
         *      string FileLine;
         *      while ((FileLine = ReadFile.ReadLine()) != null)
         *      {
         *          if (FileLine.Contains("link " + ApproachNode + " to " + NextLinkNumber + ": "))
         *          {
         *              string[] SplitString = FileLine.Split(' ');
         *              Returner = SplitString[4];
         *              return Returner;
         *          }
         *      }
         *  }
         *  return "null";
         * }*/

        /// <summary>
        /// This  returns the direction they are turning. (i.e. 'Left'.)
        /// </summary>
        /// <returns></returns>
        public string NextTurnDirection(string ApproachNode, string JunctionNode, string TurningNumber)
        {
            string Returner             = "";
            string WithoutCommaReturner = "";

            using (StreamReader ReadFile = new StreamReader(LinkTurningFile))
            {
                string FileLine;
                while ((FileLine = ReadFile.ReadLine()) != null)
                {
                    if (FileLine.Contains("Link " + ApproachNode + " " + JunctionNode + ": "))
                    {
                        string[] SplitString = FileLine.Split(' ');
                        if (SplitString[4] == "None,")
                        {
                            return("None");
                        }
                        if (SplitString[5] == "Left," || SplitString[5] == "Straight," || SplitString[5] == "Right,")
                        {
                            Returner             = SplitString[5 + Convert.ToInt16(TurningNumber)];
                            WithoutCommaReturner = Returner.Substring(0, Returner.Length - 1);
                            return(WithoutCommaReturner);
                        }
                        else
                        {
                            Returner             = SplitString[6 + Convert.ToInt16(TurningNumber)];
                            WithoutCommaReturner = Returner.Substring(0, Returner.Length - 1);
                            return(WithoutCommaReturner);
                        }
                    }
                }
            }
            return("null");
        }
Esempio n. 17
0
        public bool Check(string fileName)
        {
            using (var fileStream = FileWithBuffer.OpenRead(fileName, _fileBuffer))
            {
                FileLine previousLine    = FileLine.None;
                bool     firstLineReaden = false;
                foreach (var fileLine in new FileLineReader(fileStream, _streamBuffer))
                {
                    if (!_onlyCheckFormat && firstLineReaden)
                    {
                        if (previousLine.CompareTo(fileLine) > 0)
                        {
                            _logger.Warn($"File '{fileName}' is not properly sorted.");
                            _logger.Warn($"Line '{fileLine}' should be before line '{previousLine}'.");
                            return(false);
                        }
                    }

                    previousLine    = fileLine;
                    firstLineReaden = true;
                }

                return(true);
            }
        }
Esempio n. 18
0
        public void ShouldSortNumberStringArray()
        {
            var sorter = CreateSorter <FileLine>(new FileLineSizeCalculator());

            var sourceArray = new FileLine[]
            {
                FileLine.Parse("415. Apple"),
                FileLine.Parse("30432. Something something something"),
                FileLine.Parse("1. Apple"),
                FileLine.Parse("32. Cherry is the best"),
                FileLine.Parse("2. Banana is yellow")
            };
            var expectedArray = new FileLine[]
            {
                FileLine.Parse("1. Apple"),
                FileLine.Parse("415. Apple"),
                FileLine.Parse("2. Banana is yellow"),
                FileLine.Parse("32. Cherry is the best"),
                FileLine.Parse("30432. Something something something")
            };

            var sortedArray = sorter.Sort(sourceArray);

            CollectionAssert.AreEqual(expectedArray, sortedArray);
        }
Esempio n. 19
0
        public static void EnglishDotNet()
        {
            Assert.True(
                string.Equals(
                    "  at Member in File.cs:line 5",
                    FileLine.EnglishDotNet(
                        "File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));

            Assert.True(
                string.Equals(
                    "  at Member in File.cs:line 5",
                    FileLine.EnglishDotNet(
                        @"c:\dir1\dir2\File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));

            Assert.True(
                string.Equals(
                    "  at Member in File.cs:line 5",
                    FileLine.EnglishDotNet(
                        @"/mnt/sdcard/File.cs",
                        "Member",
                        5),
                    StringComparison.OrdinalIgnoreCase));
        }
Esempio n. 20
0
        private void PlayEvent(FileLineProcessingRejectedEvent domainEvent)
        {
            // find the line
            FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber);

            fileLine.ProcessingResult = ProcessingResult.Rejected;
            fileLine.RejectedReason   = domainEvent.Reason;
        }
Esempio n. 21
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(FileLineProcessingSuccessfulEvent domainEvent)
        {
            // find the line
            FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber);

            fileLine.TransactionId    = domainEvent.TransactionId;
            fileLine.ProcessingResult = ProcessingResult.Successful;
        }
Esempio n. 22
0
        public override List <AsbtractRenderCommand> Parse(FileLine line, IMessageHandler messageHandler)
        {
            List <AsbtractRenderCommand> commands = base.Parse(line, messageHandler);
            var newLineSpan = line.CreateOriginalTextSpan(line.BeginNonSpace, line.BeginNonSpace + 1);

            commands.Add(new NewLineCommand(newLineSpan));
            return(commands);
        }
        //*Constructor
        public EditPaths(string NetPath)
            : base(NetPath)
        {
            FileName = "paths";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string   FileLine;
                    N_W_Path temp = new N_W_Path();
                    LinkID   tLiD = new LinkID();
                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (FileLine.Contains("number "))
                        {
                            temp = new N_W_Path();

                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            //read the data from the file into the class object lists
                            int index = splitline.Length;
                            index--;
                            int num = Convert.ToInt32(splitline[index]);
                            temp.PathIDn = num;
                        }
                        if (FileLine.Contains("name "))
                        {
                            string[] splitline = FileLine.Split(new Char[] { '"' });// split the line up into an array of strings
                            temp.PathName = splitline[1];
                        }
                        if (FileLine.Contains("link "))
                        {
                            string[] splitline       = FileLine.Split(new Char[] { ':' });// split the line up into an array of strings
                            string[] splitsplitline1 = splitline[0].Split(new Char[] { ' ' });
                            string[] splitsplitline2 = splitline[1].Split(new Char[] { ' ' });
                            int      index1          = splitsplitline1.Length;
                            int      index2          = 0;
                            index1--;
                            string num1 = splitsplitline1[index1];
                            string num2 = splitsplitline2[index2];

                            tLiD = new LinkID(num1, num2);
                            temp.PathDescription.Add(tLiD);
                        }
                        if (FileLine.Contains(" end"))
                        {
                            PathList.Add(temp);
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The pathroutes file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 24
0
        public FileLineTrackParser(FileLine line)
        {
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }

            _line = line;
        }
Esempio n. 25
0
        /// <summary>
        /// 删除域名
        /// </summary>
        /// <param name="domian"></param>
        /// <param name="line"></param>
        private void remove(string domian, FileLine line)
        {
            FileLine cacheLine;

            if (domains.TryGetValue(domian, out cacheLine) && cacheLine == line)
            {
                domains.Remove(domian);
            }
        }
        public void ShouldBeCorrectDescription()
        {
            var fileLine = new FileLine();

            var validResult = $"Nº ClientesçNº VendedoresçVenda Mais CaraçPior Vendedor";
            var result      = fileLine.GetDescription("{CustomerCount}ç{SalesmanCount}ç{MostExpensive}ç{WorseSalesman}");

            result.Should().Be(validResult);
        }
Esempio n. 27
0
 /// <summary>
 /// Handles the specified event.
 /// </summary>
 /// <param name="evnt">The event to handle.</param>
 void IEventHandler <ShuttingDownEvent> .Handle(ShuttingDownEvent evnt)
 {
     // make sure critical shutdown state is reached before the event queue finishes shutting down
     if (this.LastStateFinishedHandling != AppState.Shutdown)
     {
         FileLine.ParseCompact(evnt.EventEnqueuePos, out var file, out var member, out var line);
         this.MoveToState(AppState.Shutdown, file, member, line);
     }
 }
        //*Constructor
        public EditZones(string NetPath)
            : base(NetPath)
        {
            FileName = "zones";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string   FileLine;
                    N_W_Zone temp = new N_W_Zone();

                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (FileLine.Contains("zone ") && !FileLine.Contains("Count"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            temp.ZoneNum = Convert.ToInt32(splitline[1]);
                        }
                        else if (FileLine.Contains("m ") && !FileLine.Contains("max") && !FileLine.Contains("min") && !FileLine.Contains("centroid"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            double[] corner    = new double[2] {
                                Convert.ToDouble(splitline[0]), Convert.ToDouble(splitline[2])
                            };
                            temp.Corners.Add(corner);
                        }
                        else if (FileLine.Contains("max"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            temp.Max = new double[2] {
                                Convert.ToDouble(splitline[1]), Convert.ToDouble(splitline[3])
                            };
                        }
                        else if (FileLine.Contains("min"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            temp.Min = new double[2] {
                                Convert.ToDouble(splitline[1]), Convert.ToDouble(splitline[3])
                            };
                        }
                        else if (FileLine.Contains("centroid"))
                        {
                            ZoneList.Add(temp);
                            temp = new N_W_Zone();
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The pathroutes file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 29
0
        //class constructor
        public ReadPointLoopFiles(string NetworkName, int ModelTimeofDay, int dT)
            : base(NetworkName)
        {
            string[] Paths     = Directory.GetFiles(LogDir, "point-*.csv");
            TimeSpan TS        = new TimeSpan(0, 0, ModelTimeofDay / 100);
            string   TimeOfDay = TS.ToString();

            foreach (string p in Paths)
            {
                FileInfo f         = new FileInfo(p);
                DateTime StartTime = new DateTime();
                DateTime EndTime   = new DateTime();

                StartTime = StartTime.AddSeconds(ModelTimeofDay / 100 - dT);
                EndTime   = EndTime.AddSeconds(ModelTimeofDay / 100);

                LoopRecord LoopData = new LoopRecord(StartTime, EndTime, f.Name);

                using (StreamReader ReadFile = new StreamReader(File.Open(p, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    try
                    {
                        string FileLine;
                        while ((FileLine = ReadFile.ReadLine()) != null)
                        {
                            if (!FileLine.Contains("Day"))
                            {
                                string[] Fields    = FileLine.Split(',');
                                DateTime Detection = new DateTime();
                                DateTime Holder    = Convert.ToDateTime(Fields[1]);
                                Detection = Detection.Add(Holder.TimeOfDay);

                                int Comparitor1 = Detection.CompareTo(StartTime);
                                int Comparitor2 = Detection.CompareTo(EndTime);

                                if (Comparitor1 == 1)
                                {
                                    if (Comparitor2 <= 0)
                                    {
                                        LoopData.AddData(Detection, Convert.ToDouble(Fields[8]));
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        // Let the user know what went wrong.
                        Console.WriteLine("A point loop file could not be read:");
                        Console.WriteLine(e.Message);
                    }
                }
                LoopSensors.Add(LoopData);
            }
        }
Esempio n. 30
0
        void ParseTrackCommands(ICollection <Track> tracks)
        {
            for (int i = 0; i < _cueLines.Count; ++i)
            {
                var fileLine = new FileLine(_cueLines[i]);

                switch (fileLine.Command)
                {
                case "TRACK":
                {
                    Track track = new FileLineTrackParser(fileLine).Parse();

                    if (track.TrackType != "AUDIO")
                    {
                        continue;
                    }

                    tracks.Add(track);

                    foreach (var trackLine in _cueLines.Skip(i + 1)
                             .Select(line => new FileLine(line))
                             .TakeWhile(line => line.Command != "TRACK"))
                    {
                        switch (trackLine.Command)
                        {
                        case "FLAGS":
                        case "ISRC":
                        case "PERFORMER":
                        case "SONGWRITER":
                        case "TITLE":
                        {
                            TrackSingleValueCommands[trackLine.Command](
                                track,
                                new FileLineSingleValueParser(trackLine).Parse());
                            break;
                        }

                        case "INDEX":
                        case "POSTGAP":
                        case "PREGAP":
                        {
                            TrackIndexCommands[trackLine.Command](
                                track,
                                new FileLineIndexParser(trackLine).Parse());
                            break;
                        }
                        }
                    }

                    break;
                }
                }
            }
        }
Esempio n. 31
0
 public static FileLine[] Readfile(string filename)
 {
     var file = System.IO.File.ReadAllLines(Docsfolder + "\\" + filename + ".txt");
     var newlinesArray = new FileLine[file.Count()];
     var count = file.Count();
     for (var i = 0; i < count; i++ )
     {
         newlinesArray[i] = new FileLine(file[i]);
     }
     return newlinesArray;
 }
Esempio n. 32
0
        public void when_repository_is_empty_and_a_valid_file_line_is_provided_add_user_organisation_and_association()
        {
            //Arrange
            var validFileLine = new FileLine
            {
                Forename = "Edmund",
                Surname = "Blackadder",
                Email = "*****@*****.**",
                OrgCode = "X26",
                OrgName = "Health & Social Care Information Centre"
            };

            //Act
            var errors = _sut.ProcessLine(validFileLine);

            //Assert
            Assert.That(errors.Count, Is.EqualTo(0));
            Assert.That(_repository.GetAllUsers().Count, Is.EqualTo(1));
            Assert.That(_repository.GetAllOrganisations().Count, Is.EqualTo(1));
            Assert.That(_repository.GetAllAssociations().Count, Is.EqualTo(1));
        }
 public OriginExpression(FileLine line, TextSpan span)
     : base(CodeFragmentTypes.OriginExpression, line, span)
 { }
 public TargetNewLine(FileLine line, TextSpan span)
     : base(CodeFragmentTypes.TargetNewLine, line, span)
 { }
Esempio n. 35
0
 public FileLineEnum(FileLine[] list)
 {
     Filelines = list;
 }
 public OriginPragma(string name, string argument, FileLine line, TextSpan span)
     : base(CodeFragmentTypes.OriginPragma, line, span)
 {
     Name = name;
     Argument = argument;
 }
 public TargetPushIndentation(FileLine line, TextSpan span)
     : base(CodeFragmentTypes.TargetPushIndentation, line, span)
 { }
 public AsbtractCodeFragment(CodeFragmentTypes type, FileLine line, TextSpan span)
 {
     Type = type;
     Line = line;
     Span = span;
 }
 public OriginScript(FileLine line, TextSpan span)
     : base(CodeFragmentTypes.OriginScript, line, span)
 { }