コード例 #1
0
        private List <IDataItem> LoadItemsFromTable(DataTable results)
        {
            List <IDataItem> items = new List <IDataItem>();

            foreach (DataRow r in results.Rows)
            {
                try
                {
                    int      id            = Convert.ToInt32(r["ID"]);
                    string   name          = r["Name"].ToString();
                    int      srcId         = Convert.ToInt32(r["SourceID"]);
                    DateTime addedDate     = Convert.ToDateTime(r["AddedDate"]);
                    bool     isNew         = Convert.ToBoolean(r["IsNew"]);
                    string   actionContent = r["ActionContent"].ToString();

                    if (sourceLookup.ContainsKey(srcId))
                    {
                        IDataItem i = AbstractItem.CreateGenericItem(id, sourceLookup[srcId],
                                                                     name, actionContent, isNew, addedDate);

                        items.Add(i);
                    }
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e.Message);

                    throw e;
                }
            }

            return(items);
        }
コード例 #2
0
        private AbstractItem ParseToItem(string data)
        {
            string[] fields = data.Split(FieldDelim);

            int idx = 0;

            int      id        = Int32.Parse(fields[idx++]);
            int      srcId     = Int32.Parse(fields[idx++]);
            DateTime addedDate = DateTime.Parse(fields[idx++]);
            string   title     = fields[idx++];
            bool     isNew     = Boolean.Parse(fields[idx++]);
            string   url       = fields[idx++];

            AbstractItem b = AbstractItem.CreateGenericItem(id, Sources.Single(x => x.ID == srcId),
                                                            title, url, isNew, addedDate);

            return(b);
        }