예제 #1
0
        public static IBookmark GetBookmark(BookmarkTypes type, Guid accId, string name, string address)
        {
            switch (type)
            {
            case BookmarkTypes.ShopBookmark:
                return(new ShopBookmark(accId, name, address));

            case BookmarkTypes.MessagingBookmark:
                return(new MessagingBookmark(accId, name, address));
            }

            return(null);
        }
        public override string UpdateBookmark(string wallet, string address, BookmarkTypes type, string bookmarkId, string name, string bookmarkAddress, IDbConnectorService dbservice)
        {
            try
            {
                if (EconomyMainContext.Wallets.TryGetValue(wallet, out var w))
                {
                    if (w.Accounts.TryGetValue(address, out var account))
                    {
                        IBookmark bkm = null;
                        bkm = account.Bookmarks.FirstOrDefault(b => b.Id.ToString() == bookmarkId);
                        if (bkm != null)
                        {
                            if (!string.IsNullOrEmpty(name))
                            {
                                bkm.Name = name;
                            }

                            if (!string.IsNullOrEmpty(bookmarkAddress))
                            {
                                bkm.Address = bookmarkAddress;
                            }

                            if (type != bkm.Type)
                            {
                                bkm.Type = type;
                            }
                        }
                        else
                        {
                            bkm = BookmarkFactory.GetBookmark(type, account.Id, name, bookmarkAddress);

                            bkm.Id = Guid.NewGuid();
                            account.Bookmarks.Add(bkm);
                        }

                        if (EconomyMainContext.WorkWithDb)
                        {
                            dbservice.SaveBookmark(bkm);
                        }

                        return("OK");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Cannot add bookmark!", ex);
            }

            return("Add bookmark - ERROR");
        }
예제 #3
0
        public Bookmark(SerializationInfo info, StreamingContext context)
        {
            this.Name         = info.GetString("Name");
            this.Url          = info.GetString("Url");
            this.SortOrder    = info.GetInt32("SortOrder");
            this.LastModified = info.GetDateTime("LastModified");
            this.DateAdded    = info.GetDateTime("DateAdded");
            this.BookmarkType = (BookmarkTypes)info.GetValue("BookmarkType", typeof(BookmarkTypes));

            if (info.GetValue("ChildCount", typeof(int)) != null)
            {
                int childCount = info.GetInt32("ChildCount");
                this.Children = new List <Bookmark>();
                for (int i = 0; i < childCount; i++)
                {
                    this.Children.Add(info.GetValue("Child" + i.ToString(), typeof(Bookmark)) as Bookmark);
                }
            }
            this.Parent = info.GetValue("Parent", typeof(Bookmark)) as Bookmark;
        }
 public abstract string UpdateBookmark(string wallet, string address, BookmarkTypes type, string bookmarkId, string name, string bookmarkAddress, IDbConnectorService dbservice);