Example #1
0
 protected virtual void InternalSetProperty(MdbPropertyMapping mdbMapping, object value)
 {
     if (this.allowItemBind)
     {
         this.InitializeItemIfNecessary();
         MdbDocumentAdapter.CallXsoAndMapExceptions(this.diagnosticsSession, this.id.MailboxGuid, delegate
         {
             mdbMapping.SetPropertyValue(this.Item, value, new MdbDocumentAdapter.MdbDocAdapterPropertyContext
             {
                 MailboxSession = this.Session
             });
         });
         if (this.mappedPropertiesToLoadOnBind != null)
         {
             foreach (StorePropertyDefinition item in mdbMapping.StorePropertyDefinitions)
             {
                 if (!this.mappedPropertiesToLoadOnBind.Contains(item))
                 {
                     this.mappedPropertiesToLoadOnBind.Add(item);
                 }
             }
             return;
         }
     }
     else
     {
         mdbMapping.SetPropertyValue(this.preloadedProperties, value);
     }
 }
Example #2
0
 private void InternalDispose(bool calledFromDispose)
 {
     if (calledFromDispose && this.MdbDocumentAdapter != null)
     {
         this.MdbDocumentAdapter.Dispose();
         this.MdbDocumentAdapter = null;
     }
 }
Example #3
0
        private static TReturnValue CallXsoAndMapExceptionsWithReturnValue <TReturnValue>(IDiagnosticsSession tracer, Guid mailboxGuid, MdbDocumentAdapter.CallXsoWithReturnValue <TReturnValue> xsoCall)
        {
            TReturnValue result = default(TReturnValue);

            MdbDocumentAdapter.CallXsoAndMapExceptions(tracer, mailboxGuid, delegate
            {
                result = xsoCall();
            });
            return(result);
        }
Example #4
0
        protected virtual IItem GetItem()
        {
            IItem item = null;

            MdbDocumentAdapter.CallXsoAndMapExceptions(this.diagnosticsSession, this.id.MailboxGuid, delegate
            {
                HashSet <PropertyDefinition> propsToReturn = new HashSet <PropertyDefinition>(this.mappedPropertiesToLoadOnBind);
                item = Microsoft.Exchange.Data.Storage.Item.Bind(this.Session, this.id.ItemId, ItemBindOption.None, propsToReturn);
                item.OpenAsReadWrite();
            });
            return(item);
        }
Example #5
0
        protected virtual object InternalGetProperty(MdbPropertyMapping mdbMapping)
        {
            object result = null;

            if (this.allowItemBind)
            {
                this.InitializeItemIfNecessary();
                result = MdbDocumentAdapter.CallXsoAndMapExceptionsWithReturnValue <object>(this.diagnosticsSession, this.id.MailboxGuid, () => MdbDocumentAdapter.CheckPropertyValue(mdbMapping.GetPropertyValue(this.Item, new MdbDocumentAdapter.MdbDocAdapterPropertyContext
                {
                    MailboxSession = this.Session
                })));
            }
            else if (this.AllPropertiesContained(mdbMapping.StorePropertyDefinitions))
            {
                return(MdbDocumentAdapter.CheckPropertyValue(mdbMapping.GetPropertyValue(this.preloadedProperties)));
            }
            return(result);
        }
Example #6
0
 internal MdbDocumentAdapter(MdbCompositeItemIdentity id, PropertyDefinition[] propertiesToLoad, IItem item, MailboxSession session, MdbPropertyMap propertyMap, bool allowItemBind = true)
 {
     Util.ThrowOnNullArgument(id, "id");
     Util.ThrowOnNullArgument(propertyMap, "propertyMap");
     this.id          = id;
     this.propertyMap = propertyMap;
     this.mappedPropertiesToLoadOnBind = MdbDocumentAdapter.GetMappings(this.propertyMap, propertiesToLoad);
     ExAssert.RetailAssert(this.mappedPropertiesToLoadOnBind != null, "Store Properties to load is null");
     this.Item    = item;
     this.Session = session;
     if (this.Item == null && this.Session == null)
     {
         throw new ArgumentException("session and item are both null");
     }
     this.shouldDisposeItem  = false;
     this.allowItemBind      = allowItemBind;
     this.diagnosticsSession = DiagnosticsSession.CreateComponentDiagnosticsSession("MdbDocumentAdapter", ComponentInstance.Globals.Search.ServiceName, ExTraceGlobals.MdbDocumentAdapterTracer, (long)this.GetHashCode());
 }
Example #7
0
 public virtual void Save(bool reload)
 {
     if (this.Item == null)
     {
         throw new OperationFailedException(Strings.SaveWithNoItemError);
     }
     if (this.Item.IsDirty)
     {
         MdbDocumentAdapter.CallXsoAndMapExceptions(this.diagnosticsSession, this.id.MailboxGuid, delegate
         {
             this.Item.Save(SaveMode.ResolveConflicts);
             if (reload)
             {
                 this.Item.Load(this.mappedPropertiesToLoadOnBind);
             }
         });
         return;
     }
 }
Example #8
0
 internal MdbDocument(MdbCompositeItemIdentity identity, DocumentOperation operation, MdbDocumentAdapter documentAdapter) : base(identity, operation, documentAdapter)
 {
     Util.ThrowOnNullArgument(documentAdapter, "documentAdapter");
     this.disposeTracker = this.GetDisposeTracker();
 }