Exemplo n.º 1
0
        public static WindowsPersistence factory(String name)
        {
            WindowsPersistence obj = WindowsPersistence.findByName(name);

            if (obj == null)
            {
                obj      = new WindowsPersistence();
                obj.name = name;
            }
            return(obj);
        }
Exemplo n.º 2
0
        public static WindowsPersistence findByName(String name)
        {
            using (LiteDatabase db = WindowsPersistence.getDB())
            {
                // Get customer collection
                var col = db.GetCollection <WindowsPersistence>(TABLE);

                var results            = col.Find(x => x.name == name);
                WindowsPersistence tmp = null;
                foreach (WindowsPersistence result in results)
                {
                    tmp = result;
                }
                return(tmp);
            }
        }
Exemplo n.º 3
0
        public void save()
        {
            using (LiteDatabase db = WindowsPersistence.getDB())
            {
                // Get customer collection
                var col = db.GetCollection <WindowsPersistence>(TABLE);

                if (WindowsPersistence.findByName(this.name) == null)
                {
                    col.Insert(this);
                }
                else
                {
                    col.Update(this);
                }
                col.EnsureIndex(x => x.name, true);
            }
        }