Exemple #1
0
        public static bool TryParseList <In, Out>(IList <In> data_in, Func <In, VhdlElement> visit_function, out List <Out> res)
            where In : class
            where Out : class
        {
            res = new List <Out>();
            if (data_in == null)
            {
                return(false);
            }

            foreach (In i in data_in)
            {
                Out new_item;
                try
                {
                    bool successfull = CastExtention.TryCast <VhdlElement, Out>(visit_function(i), out new_item);
                    if (successfull)
                    {
                        res.Add(new_item);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch { return(false); }
            }

            return(true);
        }
Exemple #2
0
        public static Out Parse <In, Out>(In data_in, Func <In, VhdlElement> visit_function)
            where In : class
            where Out : class
        {
            if (data_in == null)
            {
                throw new ArgumentNullException(string.Format("Argument data_in is null"));
            }

            VhdlElement parsed_data = visit_function(data_in);
            Out         res         = CastExtention.Cast <VhdlElement, Out>(parsed_data);

            return(res);
        }
Exemple #3
0
        public static List <Out> ParseList <In, Out>(IList <In> data_in, Func <In, VhdlElement> visit_function)
            where In : class
            where Out : class
        {
            if (data_in == null)
            {
                throw new ArgumentNullException(string.Format("Argument data_in is null"));
            }

            List <Out> res = new List <Out>();

            foreach (In i in data_in)
            {
                Out new_item = CastExtention.Cast <VhdlElement, Out>(visit_function(i));
                res.Add(new_item);
            }

            return(res);
        }
Exemple #4
0
        public static bool TryParse <In, Out>(In data_in, Func <In, VhdlElement> visit_function, out Out res)
            where In : class
            where Out : class
        {
            res = null;
            if (data_in == null)
            {
                return(false);
            }

            try
            {
                VhdlElement parsed_data = visit_function(data_in);
                bool        successfull = CastExtention.TryCast <VhdlElement, Out>(parsed_data, out res);
                return(successfull);
            }
            catch
            {
                res = null;
                return(false);
            }
        }