Example #1
0
 public void Save(SearchObjectBase savedObject)
 {
     this.CheckDisposed("Save");
     if (savedObject == null)
     {
         throw new ArgumentNullException("savedObject");
     }
     using (UserConfiguration userConfiguration = this.OpenFaiMessage(savedObject.Id.ConfigurationName, true))
     {
         bool flag = savedObject.IsChanged(SearchObjectBaseSchema.Name);
         using (Stream stream = userConfiguration.GetStream())
         {
             savedObject.ResetChangeTracking(true);
             IFormatter formatter = ExchangeBinaryFormatterFactory.CreateBinaryFormatter(null);
             formatter.Serialize(stream, savedObject);
             MailboxDataStore.Tracer.TraceDebug <SearchObjectBase, IExchangePrincipal>((long)this.GetHashCode(), "Saved {0} from discovery mailbox {1}.", savedObject, this.MailboxSession.MailboxOwner);
         }
         ConflictResolutionResult conflictResolutionResult = userConfiguration.Save(SaveMode.ResolveConflicts);
         if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
         {
             throw new SaveConflictException(ServerStrings.ErrorSavingSearchObject(savedObject.Id.ToString()), conflictResolutionResult);
         }
         if (flag)
         {
             using (ConfigurationItem configurationItem = (ConfigurationItem)Item.Bind(this.MailboxSession, userConfiguration.Id, new PropertyDefinition[]
             {
                 ItemSchema.Subject
             }))
             {
                 configurationItem.OpenAsReadWrite();
                 configurationItem.Subject = savedObject.Name;
                 configurationItem.Save(SaveMode.FailOnAnyConflict);
             }
         }
     }
 }