예제 #1
0
        private void InternalLoad(ICollection <PropertyDefinition> extraProperties)
        {
            ICollection <PropertyDefinition> collection;

            if (!this.IsCacheValid)
            {
                collection = this.PrefetchPropertyArray.Concat(extraProperties);
            }
            else
            {
                collection = extraProperties;
            }
            if (collection == null || collection.Count == 0)
            {
                return;
            }
            if (this.mapiPropertyBag != null)
            {
                IList <NativeStorePropertyDefinition> nativePropertyDefinitions = StorePropertyDefinition.GetNativePropertyDefinitions <PropertyDefinition>(PropertyDependencyType.AllRead, collection, (NativeStorePropertyDefinition native) => !((IDirectPropertyBag)this.MemoryPropertyBag).IsLoaded(native));
                if (nativePropertyDefinitions.Count > 0)
                {
                    object[] properties = this.MapiPropertyBag.GetProperties(nativePropertyDefinitions);
                    this.MemoryPropertyBag.PreLoadStoreProperty <NativeStorePropertyDefinition>(nativePropertyDefinitions, properties);
                    return;
                }
            }
            else
            {
                this.MemoryPropertyBag.Load(collection);
            }
        }
예제 #2
0
 internal CoreObject(StoreSession session, PersistablePropertyBag propertyBag, StoreObjectId storeObjectId, byte[] changeKey, Origin origin, ItemLevel itemLevel, ICollection <PropertyDefinition> prefetchProperties)
 {
     using (DisposeGuard disposeGuard = this.Guard())
     {
         this.session     = session;
         this.propertyBag = propertyBag;
         this.itemLevel   = itemLevel;
         this.Origin      = origin;
         if (propertyBag.DisposeTracker != null)
         {
             propertyBag.DisposeTracker.AddExtraDataWithStackTrace("CoreObject owns PersistablePropertyBag propertyBag at");
         }
         ((IDirectPropertyBag)CoreObject.GetPersistablePropertyBag(this)).Context.CoreObject = this;
         ((IDirectPropertyBag)CoreObject.GetPersistablePropertyBag(this)).Context.Session    = this.Session;
         if (prefetchProperties != null)
         {
             if (prefetchProperties == CoreObjectSchema.AllPropertiesOnStore)
             {
                 this.propertyBag.PrefetchPropertyArray = CoreObjectSchema.AllPropertiesOnStore;
             }
             else
             {
                 this.propertyBag.PrefetchPropertyArray = StorePropertyDefinition.GetNativePropertyDefinitions <PropertyDefinition>(PropertyDependencyType.AllRead, prefetchProperties).ToArray <NativeStorePropertyDefinition>();
             }
             this.propertyBag.Load(prefetchProperties);
         }
         this.storeObjectId = storeObjectId;
         this.id            = ((changeKey != null) ? new VersionedId(this.storeObjectId, changeKey) : null);
         disposeGuard.Success();
     }
 }
예제 #3
0
        private static ICollection <PropertyDefinition> GetNativeProperties(ICollection <PropertyDefinition> properties)
        {
            ICollection <NativeStorePropertyDefinition> nativePropertyDefinitions = StorePropertyDefinition.GetNativePropertyDefinitions <PropertyDefinition>(PropertyDependencyType.NeedForRead, properties);
            ICollection <PropertyDefinition>            collection = new List <PropertyDefinition>(nativePropertyDefinitions.Count);

            foreach (PropertyDefinition item in nativePropertyDefinitions)
            {
                collection.Add(item);
            }
            return(collection);
        }
예제 #4
0
        private static void DebugCheckContains(PropertyDefinition[] properties, PropertyDefinition property)
        {
            ICollection <NativeStorePropertyDefinition> nativePropertyDefinitions = StorePropertyDefinition.GetNativePropertyDefinitions <PropertyDefinition>(PropertyDependencyType.AllRead, new PropertyDefinition[]
            {
                property
            });

            foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in nativePropertyDefinitions)
            {
            }
        }
        private static NativeStorePropertyDefinition[] CreatePrefetchPropertySet <T>(ICollection <NativeStorePropertyDefinition> oldSet, ICollection <T> additionalProperties) where T : PropertyDefinition
        {
            HashSet <NativeStorePropertyDefinition>     hashSet = new HashSet <NativeStorePropertyDefinition>(oldSet);
            ICollection <NativeStorePropertyDefinition> nativePropertyDefinitions = StorePropertyDefinition.GetNativePropertyDefinitions <T>(PropertyDependencyType.AllRead, additionalProperties);

            foreach (NativeStorePropertyDefinition item in nativePropertyDefinitions)
            {
                hashSet.TryAdd(item);
            }
            return(hashSet.ToArray());
        }
예제 #6
0
        public override void Load(ICollection <PropertyDefinition> properties)
        {
            base.CheckDisposed("Load");
            if (!this.attachmentProvider.ExistsInCollection(this))
            {
                throw new ObjectNotFoundException(ServerStrings.InvalidAttachmentNumber);
            }
            ICollection <NativeStorePropertyDefinition> collection = null;

            if (properties != InternalSchema.ContentConversionProperties)
            {
                collection = StorePropertyDefinition.GetNativePropertyDefinitions <PropertyDefinition>(PropertyDependencyType.AllRead, properties);
                properties = collection.ToArray <NativeStorePropertyDefinition>();
            }
            if (this.persistablePropertyBag == null)
            {
                bool flag = false;
                if (collection != null)
                {
                    IDirectPropertyBag currentPropertyBag = this.CurrentPropertyBag;
                    using (IEnumerator <NativeStorePropertyDefinition> enumerator = collection.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NativeStorePropertyDefinition propertyDefinition = enumerator.Current;
                            if (!currentPropertyBag.IsLoaded(propertyDefinition))
                            {
                                flag = true;
                                break;
                            }
                        }
                        goto IL_8A;
                    }
                }
                flag = true;
IL_8A:
                if (flag)
                {
                    this.OnOpenConnection(properties);
                    return;
                }
            }
            else
            {
                this.persistablePropertyBag.Load(properties);
                this.attachmentProvider.OnAttachmentLoad(this);
            }
        }
 private static NativeStorePropertyDefinition[] CreatePrefetchPropertySet <T>(ICollection <T> propertySet) where T : PropertyDefinition
 {
     return(StorePropertyDefinition.GetNativePropertyDefinitions <T>(PropertyDependencyType.AllRead, propertySet).ToArray <NativeStorePropertyDefinition>());
 }
            private void AddProperties(params StorePropertyDefinition[] propertiesToAdd)
            {
                ICollection <NativeStorePropertyDefinition> nativePropertyDefinitions = StorePropertyDefinition.GetNativePropertyDefinitions <StorePropertyDefinition>(PropertyDependencyType.NeedForRead, propertiesToAdd);

                this.properties.AddRange(nativePropertyDefinitions);
            }