コード例 #1
0
 public IEnumerable <TTarget> FindPaged <TSource, TTarget>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize) where TSource : IConfigurable, new() where TTarget : IConfigurable, new()
 {
     MapiSession.< > c__DisplayClass10 <TSource, TTarget> CS$ < > 8__locals1 = new MapiSession.< > c__DisplayClass10 <TSource, TTarget>();
     CS$ < > 8__locals1.filter             = filter;
     CS$ < > 8__locals1.root               = root;
     CS$ < > 8__locals1.scope              = scope;
     CS$ < > 8__locals1.sort               = sort;
     CS$ < > 8__locals1.pageSize           = pageSize;
     CS$ < > 8__locals1.maximumResultsSize = maximumResultsSize;
     this.DisposeCheck();
     if (!typeof(MapiObject).IsAssignableFrom(typeof(TSource)))
     {
         throw new ArgumentException("TSource");
     }
     if (!typeof(MapiObject).IsAssignableFrom(typeof(TTarget)))
     {
         throw new ArgumentException("TTarget");
     }
     CS$ < > 8__locals1.objects = null;
     using (MapiObject mapiObject = ((default(TSource) == null) ? Activator.CreateInstance <TSource>() : default(TSource)) as MapiObject)
     {
         mapiObject.MapiSession = this;
         this.InvokeWithWrappedException(delegate()
         {
             CS$ < > 8__locals1.objects = mapiObject.FindPaged <TTarget>(CS$ < > 8__locals1.filter, CS$ < > 8__locals1.root, CS$ < > 8__locals1.scope, CS$ < > 8__locals1.sort, CS$ < > 8__locals1.pageSize, CS$ < > 8__locals1.maximumResultsSize);
         }, Strings.ExceptionFindObject(typeof(TTarget).Name, (null == CS$ < > 8__locals1.root) ? Strings.ConstantNull : CS$ < > 8__locals1.root.ToString()), null);
     }
     if (CS$ < > 8__locals1.objects != null)
     {
         return(CS$ < > 8__locals1.objects);
     }
     return((IEnumerable <TTarget>) new TTarget[0]);
 }
コード例 #2
0
        public T Read <T>(ObjectId identity, bool keepUnmanagedResources) where T : IConfigurable, new()
        {
            this.DisposeCheck();
            if (!typeof(MapiObject).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("T");
            }
            if (!(identity is MapiObjectId))
            {
                throw new ArgumentException("identity");
            }
            MapiObject mapiObject = ((default(T) == null) ? Activator.CreateInstance <T>() : default(T)) as MapiObject;

            mapiObject.MapiIdentity = (MapiObjectId)identity;
            mapiObject.MapiSession  = this;
            this.InvokeWithWrappedException(delegate()
            {
                mapiObject.Read(keepUnmanagedResources);
            }, Strings.ExceptionReadObject(typeof(T).Name, identity.ToString()), null);
            return((T)((object)mapiObject));
        }
コード例 #3
0
        public void Delete(IConfigurable instance)
        {
            MapiObject mapiObject = instance as MapiObject;

            if (mapiObject == null)
            {
                throw new ArgumentException("instance");
            }
            if (mapiObject.Identity == null)
            {
                throw new ArgumentException(Strings.ExceptionIdentityInvalid);
            }
            if (mapiObject.MapiSession == null)
            {
                mapiObject.MapiSession = this;
            }
            this.InvokeWithWrappedException(delegate()
            {
                mapiObject.Delete();
            }, Strings.ExceptionDeleteObject(instance.Identity.ToString()), null);
        }
コード例 #4
0
        public void Save(IConfigurable instance, bool keepUnmanagedResources)
        {
            this.DisposeCheck();
            MapiObject mapiObject = instance as MapiObject;

            if (mapiObject == null)
            {
                throw new ArgumentException("instance");
            }
            if (mapiObject.MapiSession == null)
            {
                mapiObject.MapiSession = this;
            }
            ValidationError[] array = mapiObject.Validate();
            if (array != null && 0 < array.Length)
            {
                throw new DataValidationException(array[0]);
            }
            this.InvokeWithWrappedException(delegate()
            {
                mapiObject.Save(keepUnmanagedResources);
            }, (instance.ObjectState == ObjectState.New) ? Strings.ExceptionNewObject((instance.Identity == null) ? Strings.ConstantNull : instance.Identity.ToString()) : Strings.ExceptionSaveObject((instance.Identity == null) ? Strings.ConstantNull : instance.Identity.ToString()), null);
        }