Ejemplo n.º 1
0
        public static ComponentLocation parseCsv(string csvLine)
        {
            ComponentLocation result = new ComponentLocation();

            using (StringReader rdr = new StringReader(csvLine))
                using (TextFieldParser csvParser = new TextFieldParser(rdr))
                {
                    csvParser.CommentTokens = new string[] { "#" };
                    csvParser.SetDelimiters(new string[] { "," });
                    csvParser.HasFieldsEnclosedInQuotes = true;
                    string[] components = csvParser.ReadFields();
                    if (components.Length != 7)
                    {
                        throw new InvalidOperationException("Expected 7 values");
                    }
                    result.reference = ComponentReference.parse(components[0]);
                    result.value     = components[1];
                    result.package   = components[2];
                    result.x         = double.Parse(components[3], CultureInfo.InvariantCulture);
                    result.y         = double.Parse(components[4], CultureInfo.InvariantCulture);
                    result.rotation  = double.Parse(components[5], CultureInfo.InvariantCulture);
                    result.layer     = components[6];
                    return(result);
                }
        }
Ejemplo n.º 2
0
        private static List <ComponentReference> parseDesignators(string designators)
        {
            string[] elements = designators.Split(',');
            List <ComponentReference> result = new List <ComponentReference>();

            foreach (string component in elements)
            {
                result.Add(ComponentReference.parse(component));
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static ComponentLocation parseKicad(string kicadLine)
        {
            ComponentLocation result = new ComponentLocation();

            string[] components = kicadLine.Split(KicadSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (components.Length != 7)
            {
                throw new InvalidOperationException("Expected 7 values");
            }
            result.reference = ComponentReference.parse(components[0]);
            result.value     = components[1];
            result.package   = components[2];
            result.x         = double.Parse(components[3], CultureInfo.InvariantCulture);
            result.y         = double.Parse(components[4], CultureInfo.InvariantCulture);
            result.rotation  = double.Parse(components[5], CultureInfo.InvariantCulture);
            result.layer     = components[6];
            return(result);
        }