Exemple #1
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                Dictionary <string, Participant> dictionary = new Dictionary <string, Participant>();

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    Participant valueOrDefault = storePropertyBag.GetValueOrDefault <Participant>(ItemSchema.From, null);
                    if (valueOrDefault == null)
                    {
                        valueOrDefault = storePropertyBag.GetValueOrDefault <Participant>(ItemSchema.Sender, null);
                    }
                    if (!(valueOrDefault == null))
                    {
                        string text = string.IsNullOrEmpty(valueOrDefault.DisplayName) ? valueOrDefault.ToString(AddressFormat.Rfc822Smtp) : valueOrDefault.DisplayName;
                        if (!string.IsNullOrEmpty(text) && !dictionary.ContainsKey(text))
                        {
                            dictionary.Add(text, valueOrDefault);
                        }
                    }
                }
                if (dictionary.Count == 0)
                {
                    value = null;
                    return(false);
                }
                value = dictionary.Values.ToArray <Participant>();
                return(true);
            }
Exemple #2
0
        private T PrepareItem <T>(List <IStorePropertyBag> sources, Func <PropertyBag, T> converResultItem)
        {
            this.aggregationExtension.BeforeAggregation(sources);
            PropertyAggregationContext propertyAggregationContext = this.aggregationExtension.GetPropertyAggregationContext(sources);
            PropertyBag arg = ApplicationAggregatedProperty.AggregateAsPropertyBag(propertyAggregationContext, this.originalProperties);

            return(converResultItem(arg));
        }
Exemple #3
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                int num = 0;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    int valueOrDefault = storePropertyBag.GetValueOrDefault <int>(InternalSchema.Size, 0);
                    num += valueOrDefault;
                }
                value = num;
                return(true);
            }
Exemple #4
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                HashSet <string> hashSet = new HashSet <string>();

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    string valueOrDefault = storePropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, StoreObjectType.Message.ToString());
                    hashSet.Add(valueOrDefault);
                }
                value = hashSet.ToArray <string>();
                return(true);
            }
Exemple #5
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                List <short> list = new List <short>(context.Sources.Count);

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    short valueOrDefault = storePropertyBag.GetValueOrDefault <short>(InternalSchema.RichContent, 0);
                    list.Add(valueOrDefault);
                }
                value = list.ToArray();
                return(true);
            }
Exemple #6
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                int num = 0;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    if (!storePropertyBag.GetValueOrDefault <bool>(InternalSchema.IsRead, true))
                    {
                        num++;
                    }
                }
                value = num;
                return(true);
            }
Exemple #7
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                bool flag = false;

                foreach (IStorePropertyBag source in context.Sources)
                {
                    if (this.GetBoolValue(source))
                    {
                        flag = true;
                        break;
                    }
                }
                value = flag;
                return(true);
            }
Exemple #8
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                IconIndex iconIndex = IconIndex.Default;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    IconIndex valueOrDefault = storePropertyBag.GetValueOrDefault <IconIndex>(InternalSchema.IconIndex, IconIndex.Default);
                    if (valueOrDefault != IconIndex.Default && valueOrDefault != iconIndex)
                    {
                        iconIndex = valueOrDefault;
                    }
                }
                value = iconIndex;
                return(true);
            }
Exemple #9
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                ExDateTime exDateTime = ExDateTime.MinValue;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    ExDateTime valueOrDefault = storePropertyBag.GetValueOrDefault <ExDateTime>(InternalSchema.ReceivedTime, ExDateTime.MinValue);
                    if (valueOrDefault > exDateTime)
                    {
                        exDateTime = valueOrDefault;
                    }
                }
                value = exDateTime;
                return(true);
            }
Exemple #10
0
        internal static PropertyBag AggregateAsPropertyBag(PropertyAggregationContext context, IEnumerable <PropertyDefinition> properties)
        {
            MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();

            foreach (PropertyDefinition propertyDefinition in properties)
            {
                ApplicationAggregatedProperty applicationAggregatedProperty = propertyDefinition as ApplicationAggregatedProperty;
                if (applicationAggregatedProperty != null)
                {
                    applicationAggregatedProperty.Aggregate(context, memoryPropertyBag);
                }
            }
            memoryPropertyBag.SetAllPropertiesLoaded();
            return(memoryPropertyBag);
        }
Exemple #11
0
        public void Aggregate(PropertyDefinition aggregatedProperty, PropertyAggregationContext context, PropertyBag target)
        {
            Util.ThrowOnNullArgument(aggregatedProperty, "aggregatedProperty");
            Util.ThrowOnNullArgument(context, "context");
            Util.ThrowOnNullArgument(target, "target");
            PropertyAggregationStrategy.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Aggregating property {0}", aggregatedProperty.Name);
            object obj;

            if (this.TryAggregate(context, out obj))
            {
                this.Trace(obj, aggregatedProperty, context);
                target[aggregatedProperty] = obj;
                return;
            }
            PropertyAggregationStrategy.Tracer.TraceDebug <string>((long)this.GetHashCode(), "No value returned for property {0}", aggregatedProperty.Name);
        }
Exemple #12
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                FlagStatus flagStatus = FlagStatus.NotFlagged;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    FlagStatus valueOrDefault = storePropertyBag.GetValueOrDefault <FlagStatus>(InternalSchema.FlagStatus, FlagStatus.NotFlagged);
                    if (valueOrDefault > flagStatus)
                    {
                        flagStatus = valueOrDefault;
                        if (flagStatus == FlagStatus.Flagged)
                        {
                            break;
                        }
                    }
                }
                value = flagStatus;
                return(true);
            }
Exemple #13
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                List <StoreObjectId> list = new List <StoreObjectId>(context.Sources.Count);

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    byte[] valueOrDefault = storePropertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId, null);
                    if (valueOrDefault != null)
                    {
                        StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault, StoreObjectType.Unknown);
                        if (storeObjectId != null)
                        {
                            list.Add(storeObjectId);
                        }
                    }
                }
                value = list.ToArray();
                return(true);
            }
Exemple #14
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                Importance importance = Importance.Low;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    Importance valueOrDefault = storePropertyBag.GetValueOrDefault <Importance>(InternalSchema.Importance, Importance.Normal);
                    if (valueOrDefault > importance)
                    {
                        importance = valueOrDefault;
                        if (importance == Importance.High)
                        {
                            break;
                        }
                    }
                }
                value = importance;
                return(true);
            }
Exemple #15
0
            protected override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                ConversationId conversationId = null;

                foreach (IStorePropertyBag storePropertyBag in context.Sources)
                {
                    ConversationId valueOrDefault = storePropertyBag.GetValueOrDefault <ConversationId>(InternalSchema.ConversationId, null);
                    if (conversationId != null && valueOrDefault != null && !valueOrDefault.Equals(conversationId))
                    {
                        throw new ArgumentException("sources", "Property bag collection should have same conversationId");
                    }
                    if (conversationId == null)
                    {
                        conversationId = valueOrDefault;
                    }
                }
                value = conversationId;
                return(true);
            }
Exemple #16
0
            protected sealed override bool TryAggregate(PropertyAggregationContext context, out object value)
            {
                IStorePropertyBag storePropertyBag = null;

                foreach (IStorePropertyBag storePropertyBag2 in context.Sources)
                {
                    if (this.selectionStrategy.IsSelectable(storePropertyBag2) && (storePropertyBag == null || this.selectionStrategy.HasPriority(storePropertyBag2, storePropertyBag)))
                    {
                        storePropertyBag = storePropertyBag2;
                    }
                }
                if (storePropertyBag != null)
                {
                    value = this.selectionStrategy.GetValue(storePropertyBag);
                }
                else
                {
                    value = null;
                }
                return(value != null);
            }
Exemple #17
0
 private void Trace(object aggregatedValue, PropertyDefinition aggregatedProperty, PropertyAggregationContext context)
 {
     if (PropertyAggregationStrategy.Tracer.IsTraceEnabled(TraceType.DebugTrace))
     {
         StringBuilder stringBuilder = new StringBuilder(100);
         stringBuilder.Append("{");
         bool flag = true;
         foreach (IStorePropertyBag storePropertyBag in context.Sources)
         {
             if (flag)
             {
                 flag = false;
             }
             else
             {
                 stringBuilder.Append(", ");
             }
             foreach (PropertyDependency propertyDependency in this.Dependencies)
             {
                 object obj = storePropertyBag.TryGetProperty(propertyDependency.Property);
                 if (obj != null)
                 {
                     PropertyError propertyError = obj as PropertyError;
                     if (propertyError != null)
                     {
                         if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound)
                         {
                             stringBuilder.Append(PropertyAggregationStrategy.GetPropertyValuePair(propertyDependency.Property, "ERROR:" + propertyError.PropertyErrorCode.ToString()));
                         }
                     }
                     else
                     {
                         stringBuilder.Append(PropertyAggregationStrategy.GetPropertyValuePair(propertyDependency.Property, obj));
                     }
                 }
             }
         }
         stringBuilder.Append("}");
         PropertyAggregationStrategy.Tracer.TraceDebug <string, StringBuilder>((long)this.GetHashCode(), "Aggregated={0} Sources={1}", PropertyAggregationStrategy.GetPropertyValuePair(aggregatedProperty, aggregatedValue), stringBuilder);
     }
 }
Exemple #18
0
 protected override bool TryAggregate(PropertyAggregationContext context, out object value)
 {
     value = context.Sources.Count;
     return(true);
 }
Exemple #19
0
 protected override bool TryAggregate(PropertyAggregationContext context, out object value)
 {
     value = null;
     return(false);
 }
Exemple #20
0
 protected abstract bool TryAggregate(PropertyAggregationContext context, out object value);
Exemple #21
0
 internal void Aggregate(PropertyAggregationContext context, PropertyBag target)
 {
     this.propertyAggregationStrategy.Aggregate(this.aggregatedProperty, context, target);
 }
Exemple #22
0
 public static IStorePropertyBag Aggregate(PropertyAggregationContext context, IEnumerable <PropertyDefinition> properties)
 {
     return(ApplicationAggregatedProperty.AggregateAsPropertyBag(context, properties).AsIStorePropertyBag());
 }