public static Price ParseNetString(string objectDef, State state) { string[] tokens = objectDef.Split(NetCodes.SEPARATOR_FIELD); int count = 0; int id = Convert.ToInt32(tokens[count++]); int originId = Convert.ToInt32(tokens[count++]); int destinationId = Convert.ToInt32(tokens[count++]); Priority priority = PriorityExtensions.ParseNetString(tokens[count++]); int weightPrice = Convert.ToInt32(tokens[count++]); int volumePrice = Convert.ToInt32(tokens[count++]); return new Price() { ID = id, Origin = state.GetRouteNode(originId), Destination = state.GetRouteNode(destinationId), Priority = priority, PricePerGram = weightPrice, PricePerCm3 = volumePrice }; }
public static Route ParseNetString(string objectDef, State state) { string[] tokens = objectDef.Split(NetCodes.SEPARATOR_FIELD); int count = 0; int id = Convert.ToInt32(tokens[count++]); int originId = Convert.ToInt32(tokens[count++]); int destinationId = Convert.ToInt32(tokens[count++]); int companyId = Convert.ToInt32(tokens[count++]); TransportType type = TransportTypeExtensions.ParseNetString(tokens[count++]); int weightCost = Convert.ToInt32(tokens[count++]); int volumeCost = Convert.ToInt32(tokens[count++]); int weightMax = Convert.ToInt32(tokens[count++]); int volumeMax = Convert.ToInt32(tokens[count++]); int duration = Convert.ToInt32(tokens[count++]); List<WeeklyTime> routeTimes = WeeklyTime.ParseTimesNetString(tokens[count++]); return new Route() { ID = id, Origin = state.GetRouteNode(originId), Destination = state.GetRouteNode(destinationId), Company = state.GetCompany(companyId), TransportType = type, CostPerGram = weightCost, CostPerCm3 = volumeCost, MaxWeight = weightMax, MaxVolume = volumeMax, Duration = duration, DepartureTimes = routeTimes }; }