コード例 #1
0
        public static string getDescription(IList <SimpleIdName> lista, string str)
        {
            string[] itens = str.Split(',');
            string   saida = "";

            for (int i = 0; i < itens.Length; i++)
            {
                if (itens[i] == String.Empty)
                {
                    continue;
                }

                try
                {
                    SimpleIdName it = lista.Where(s => s.Id.ToString() == itens[i]).Single();

                    if (saida != "")
                    {
                        saida += ", ";
                    }

                    saida += it.Name;
                }
                catch { }
            }

            return(saida);
        }
コード例 #2
0
        public static IList <SimpleIdName> createByString(string str)
        {
            List <SimpleIdName> lst = new List <SimpleIdName>();

            string[] itens = str.Split(',');

            for (int i = 0; i < itens.Length; i++)
            {
                if (itens[i] == String.Empty)
                {
                    continue;
                }

                var cols = itens[i].Split(new string[] { "||" }, StringSplitOptions.None);

                var itemSimple = new SimpleIdName();
                if (cols.Length > 1)
                {
                    itemSimple.Id   = cols[0];
                    itemSimple.Name = cols[1];
                }
                else
                {
                    itemSimple.Id   = cols[0];
                    itemSimple.Name = cols[0];
                }

                lst.Add(itemSimple);
            }

            return(lst);
        }