public bool Exists(SearchObjectId identity)
        {
            MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Querying existence of search object {0}", identity);
            bool result;

            using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore())
            {
                result = mailboxDataStore.Exists(identity);
            }
            return(result);
        }
        public bool Exists <T>(string name) where T : IConfigurable, new()
        {
            MailboxDataProvider.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Querying existence of search object {0}", name);
            bool result;

            using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore())
            {
                result = mailboxDataStore.Exists <T>(name);
            }
            return(result);
        }
        private void Save(SearchObjectBase instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Saving search object {0}", instance.Id);
            if (instance.ObjectState == ObjectState.Deleted)
            {
                throw new InvalidOperationException("Calling Save() on a deleted object is not permitted. Delete() should be used instead.");
            }
            if (instance.ObjectState == ObjectState.Unchanged)
            {
                return;
            }
            bool flag = false;

            if (instance.ObjectState == ObjectState.New && (instance.Id == null || instance.Id.IsEmpty))
            {
                instance.SetId(base.ADUser.Id, Guid.NewGuid());
                flag = true;
            }
            ValidationError[] array = instance.Validate();
            if (array.Length > 0)
            {
                throw new DataValidationException(array[0]);
            }
            using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore())
            {
                if (flag)
                {
                    while (mailboxDataStore.Exists(instance.Id))
                    {
                        instance.SetId(base.ADUser.Id, Guid.NewGuid());
                    }
                }
                instance.OnSaving();
                mailboxDataStore.Save(instance);
            }
            instance.ResetChangeTracking(true);
            this.LogSaveEvent(instance);
        }