protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            bool flag = base.Get(propertyBag, builder);

            if (this.emailAddressForDisplayPropDef != null)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(this.emailAddressForDisplayPropDef);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    builder[ParticipantSchema.EmailAddressForDisplay] = valueOrDefault;
                    if (Participant.RoutingTypeEquals(builder.RoutingType, "EX") && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.SmtpAddress)) && SmtpAddress.IsValidSmtpAddress(valueOrDefault))
                    {
                        builder[ParticipantSchema.SmtpAddress] = valueOrDefault;
                    }
                }
            }
            if (!flag && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault2 != null)
            {
                builder.Origin = new StoreParticipantOrigin(StoreObjectId.FromProviderSpecificId(valueOrDefault2), this.emailAddressIndex);
            }
            return(builder.ToParticipant());
        }
Exemple #2
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            byte[] valueOrDefault       = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault != null)
            {
                builder.SetPropertiesFrom(ParticipantEntryId.TryFromEntryId(valueOrDefault));
            }
            builder.DisplayName = (propertyBag.GetValueOrDefault <string>(InternalSchema.TransmitableDisplayName) ?? builder.DisplayName);
            if (!base.Get(propertyBag, builder))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            RecipientDisplayType?valueAsNullable = propertyBag.GetValueAsNullable <RecipientDisplayType>(InternalSchema.DisplayTypeExInternal);

            if (valueAsNullable != null)
            {
                builder[ParticipantSchema.DisplayTypeEx] = valueAsNullable.Value;
                builder.Origin = (builder.Origin ?? new DirectoryParticipantOrigin());
            }
            else if (PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.DisplayType)))
            {
                LegacyRecipientDisplayType?valueAsNullable2 = propertyBag.GetValueAsNullable <LegacyRecipientDisplayType>(InternalSchema.DisplayType);
                ObjectType?valueAsNullable3 = propertyBag.GetValueAsNullable <ObjectType>(InternalSchema.ObjectType);
                if (valueAsNullable2 != null)
                {
                    if (valueAsNullable2 != LegacyRecipientDisplayType.MailUser)
                    {
                        builder[ParticipantSchema.DisplayType] = (int)valueAsNullable2.Value;
                    }
                }
                else if (valueAsNullable3 != null && valueAsNullable3 == ObjectType.MAPI_DISTLIST)
                {
                    builder[ParticipantSchema.DisplayType] = 1;
                }
            }
            builder.SetOrDeleteProperty(ParticipantSchema.SendRichInfo, Util.NullIf <object>(propertyBag.GetValueAsNullable <bool>(InternalSchema.SendRichInfo), false));
            builder.SetOrDeleteProperty(ParticipantSchema.SendInternetEncoding, propertyBag.GetValueAsNullable <int>(InternalSchema.SendInternetEncoding));
            return(builder.ToParticipant());
        }