private static bool UpdatePartnerNetworkIdAndUserId(ICorePropertyBag propertyBag, byte[] oscContactSources, OscNetworkProperties networkProperties)
 {
     if (propertyBag.IsPropertyDirty(ContactSchema.PartnerNetworkId) || propertyBag.IsPropertyDirty(ContactSchema.PartnerNetworkUserId))
     {
         return(false);
     }
     if (oscContactSources == null)
     {
         propertyBag.Delete(ContactSchema.PartnerNetworkId);
         propertyBag.Delete(ContactSchema.PartnerNetworkUserId);
         return(true);
     }
     if (networkProperties != null)
     {
         propertyBag[ContactSchema.PartnerNetworkId]     = networkProperties.NetworkId;
         propertyBag[ContactSchema.PartnerNetworkUserId] = networkProperties.NetworkUserId;
         return(true);
     }
     return(false);
 }
        public virtual bool UpdateDisplayNameProperties(ICorePropertyBag propertyBag)
        {
            bool flag = false;

            foreach (NativeStorePropertyDefinition propertyDefinition in this.allSourceProperties)
            {
                if (propertyBag.IsPropertyDirty(propertyDefinition))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                return(false);
            }
            bool flag2 = false;

            for (int i = 0; i < this.candidateProperties.Count; i++)
            {
                PriorityBasedDisplayNamePropertyRule.CandidateProperty candidateProperty = this.candidateProperties[i];
                if (candidateProperty.HasNonEmptyValue(propertyBag))
                {
                    string value  = null;
                    string value2 = null;
                    candidateProperty.GetValue(propertyBag, out value, out value2);
                    propertyBag.SetProperty(InternalSchema.DisplayNameFirstLast, value);
                    propertyBag.SetProperty(InternalSchema.DisplayNameLastFirst, value2);
                    propertyBag.SetProperty(InternalSchema.DisplayNamePriority, i);
                    flag2 = true;
                    break;
                }
            }
            if (!flag2)
            {
                propertyBag.Delete(InternalSchema.DisplayNameFirstLast);
                propertyBag.Delete(InternalSchema.DisplayNameLastFirst);
                propertyBag.Delete(InternalSchema.DisplayNamePriority);
            }
            return(true);
        }
Esempio n. 3
0
 internal static void SetOrDeleteProperty(this ICorePropertyBag propertyBag, PropertyDefinition property, object newValue)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     if (newValue == null || PropertyError.IsPropertyNotFound(newValue))
     {
         propertyBag.Delete(property);
         return;
     }
     propertyBag.SetProperty(property, newValue);
 }
Esempio n. 4
0
 public NativeStorePropertyDefinition[] SetPropertiesHelper(ICorePropertyBag propertyBag, PropValueData[] pvda)
 {
     if (pvda == null || pvda.Length == 0)
     {
         return(null);
     }
     PropTag[] array = new PropTag[pvda.Length];
     for (int i = 0; i < pvda.Length; i++)
     {
         array[i] = (PropTag)pvda[i].PropTag;
         if (base.IsPublicFolderMailbox && array[i] == PropTag.IpmWasteBasketEntryId)
         {
             byte[] array2 = pvda[i].Value as byte[];
             if (array2 != null)
             {
                 pvda[i].Value = this.StoreSession.IdConverter.GetLongTermIdFromId(StoreObjectId.FromProviderSpecificId(array2));
             }
         }
     }
     NativeStorePropertyDefinition[] result;
     using (base.RHTracker.Start())
     {
         NativeStorePropertyDefinition[] array3 = this.ConvertPropTagsToDefinitions(array);
         for (int j = 0; j < pvda.Length; j++)
         {
             if (pvda[j].Value == null)
             {
                 propertyBag.Delete(array3[j]);
             }
             else
             {
                 propertyBag.SetProperty(array3[j], pvda[j].Value);
             }
         }
         result = array3;
     }
     return(result);
 }
        internal static void CoreObjectUpdateStreamAttachmentName(CoreAttachment coreAttachment)
        {
            ICorePropertyBag propertyBag = coreAttachment.PropertyBag;
            string           text        = (propertyBag.TryGetProperty(InternalSchema.AttachLongFileName) as string) ?? (propertyBag.TryGetProperty(InternalSchema.AttachFileName) as string);
            string           text2       = propertyBag.TryGetProperty(InternalSchema.DisplayName) as string;
            string           text3       = propertyBag.TryGetProperty(InternalSchema.AttachExtension) as string;

            if (!string.IsNullOrEmpty(text))
            {
                text = Attachment.TrimFilename(text);
            }
            if (!string.IsNullOrEmpty(text2))
            {
                text2 = Attachment.TrimFilename(text2);
            }
            if (!string.IsNullOrEmpty(text3))
            {
                text3 = '.' + Attachment.TrimFilename(text3);
            }
            string text4 = null;
            string text5 = null;
            string text6 = null;
            string text7 = null;

            Attachment.TryFindFileExtension(text, out text5, out text4);
            Attachment.TryFindFileExtension(text2, out text7, out text6);
            if (!string.IsNullOrEmpty(text5))
            {
                text3 = text5;
            }
            if (!string.IsNullOrEmpty(text7) && string.Compare(text3, text7, StringComparison.OrdinalIgnoreCase) != 0)
            {
                text6 += text7;
            }
            if (string.IsNullOrEmpty(text4))
            {
                text4 = Attachment.GenerateFilename();
            }
            if (EmailMessageHelpers.IsGeneratedFileName(text4) && string.IsNullOrEmpty(text3))
            {
                string text8 = propertyBag.TryGetProperty(InternalSchema.AttachMimeTag) as string;
                if (!string.IsNullOrEmpty(text8))
                {
                    text3 = StreamAttachmentBase.GetExtensionByContentType(text8);
                }
            }
            if (string.IsNullOrEmpty(text6))
            {
                text6 = text4;
            }
            if (!string.IsNullOrEmpty(text3))
            {
                text  = text4 + text3;
                text2 = text6 + text3;
            }
            else
            {
                text  = text4;
                text2 = text6;
                propertyBag.Delete(InternalSchema.AttachExtension);
            }
            propertyBag[InternalSchema.AttachLongFileName] = text;
            propertyBag[InternalSchema.DisplayName]        = text2;
            propertyBag[InternalSchema.AttachExtension]    = (text3 ?? string.Empty);
            bool      flag          = false;
            ICoreItem containerItem = coreAttachment.ParentCollection.ContainerItem;

            if (containerItem != null)
            {
                containerItem.PropertyBag.Load(new PropertyDefinition[]
                {
                    InternalSchema.IsAssociated
                });
                flag = containerItem.PropertyBag.GetValueOrDefault <bool>(InternalSchema.IsAssociated, false);
            }
            if (!flag)
            {
                propertyBag[InternalSchema.AttachFileName] = Attachment.Make8x3FileName(text, coreAttachment != null && coreAttachment.Session != null && coreAttachment.Session.IsMoveUser);
            }
        }