public void Add(string resourceKind, object applicationBookmark)
        {
            string assemblyQualifiedName = applicationBookmark.GetType().AssemblyQualifiedName;
            object blob = this.SerializeApplicationBookmark(applicationBookmark);

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    appBookmarkTableAdapter.Insert(resourceKindInfo.Id, blob, assemblyQualifiedName, jetTransaction);
                }
                catch (OleDbException exception)
                {
                    if (exception.Errors.Count == 1 && exception.Errors[0].SQLState == "3022")
                    {
                        throw new StoreException(string.Format("An error occured while adding a new application bookmark. An application bookmark already exists for the resource kind '{0}'.", resourceKind), exception);
                    }

                    throw;
                }

                jetTransaction.Commit();
            }
        }
        public bool Get(string resourceKind, Type type, out object applicationBookmark)
        {
            bool result = false;

            applicationBookmark = null;
            string assemblyQualifiedName = type.AssemblyQualifiedName;

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                byte[] blob;
                string receivedAssemblyQualifiedName;
                if (appBookmarkTableAdapter.Get(resourceKindInfo.Id, out blob, out receivedAssemblyQualifiedName, jetTransaction))
                {
                    applicationBookmark = this.DeserializeBlob(blob, type);    // use given type not the one stored
                    result = true;
                }

                jetTransaction.Commit();
            }

            return(result);
        }
        public void Update(string resourceKind, object applicationBookmark)
        {
            string assemblyQualifiedName = applicationBookmark.GetType().AssemblyQualifiedName;
            object blob = this.SerializeApplicationBookmark(applicationBookmark);

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                if (!appBookmarkTableAdapter.Update(resourceKindInfo.Id, blob, assemblyQualifiedName, jetTransaction))
                {
                    throw new StoreException(string.Format("No application bookmark exists for the resource kind '{0}' that can be updated.", resourceKind));
                }

                jetTransaction.Commit();
            }
        }
        public void Delete(string resourceKind)
        {
            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    appBookmarkTableAdapter.Delete(resourceKindInfo.Id, jetTransaction);
                }
                catch
                {
                    return;
                }

                jetTransaction.Commit();
            }
        }