예제 #1
0
 private void EnsureOneDriveProDataProvider(CallContext callContext, PolymorphicConfiguration <AttachmentDataProvider> attachmentDataProvidersConfig, UserContext userContext)
 {
     if (!this.useMockAttachmentDataProvider)
     {
         if (!this.isOneDriveProProviderAvailable)
         {
             return;
         }
         if (!userContext.IsBposUser)
         {
             return;
         }
     }
     if (!this.dataProviders.Values.Any((AttachmentDataProvider x) => x.GetType() == typeof(OneDriveProAttachmentDataProvider)))
     {
         lock (this.lockObject)
         {
             if (!this.dataProviders.Values.Any((AttachmentDataProvider x) => x.GetType() == typeof(OneDriveProAttachmentDataProvider)))
             {
                 OneDriveProAttachmentDataProvider oneDriveProAttachmentDataProvider = OneDriveProAttachmentDataProvider.CreateFromBpos(userContext, callContext, this.useMockAttachmentDataProvider);
                 if (oneDriveProAttachmentDataProvider != null)
                 {
                     this.AddProviderInternal(callContext, attachmentDataProvidersConfig, oneDriveProAttachmentDataProvider);
                 }
             }
         }
     }
 }
예제 #2
0
 private void AddProviderInternal(CallContext callContext, PolymorphicConfiguration <AttachmentDataProvider> attachmentDataProvidersConfig, AttachmentDataProvider provider)
 {
     lock (this.lockObject)
     {
         this.dataProviders[provider.Id] = provider;
         if (attachmentDataProvidersConfig != null)
         {
             attachmentDataProvidersConfig.Entries.Add(provider);
             attachmentDataProvidersConfig.Save(callContext);
         }
     }
 }
예제 #3
0
 private void ProviderChanged(AttachmentDataProvider provider, AttachmentDataProviderChangedEventArgs args)
 {
     if (this.dataProviders.ContainsKey(provider.Id))
     {
         lock (this.lockObject)
         {
             if (this.dataProviders.ContainsKey(provider.Id))
             {
                 PolymorphicConfiguration <AttachmentDataProvider> polymorphicConfiguration = new PolymorphicConfiguration <AttachmentDataProvider>();
                 foreach (AttachmentDataProvider item in this.dataProviders.Values)
                 {
                     polymorphicConfiguration.Entries.Add(item);
                     polymorphicConfiguration.Save(args.MailboxSession);
                 }
             }
         }
     }
 }
예제 #4
0
 private void EnsureAttachmentDataProviders(CallContext callContext)
 {
     if (this.dataProviders == null || this.dataProviders.Count == 0)
     {
         lock (this.lockObject)
         {
             if (this.dataProviders == null || this.dataProviders.Count == 0)
             {
                 UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);
                 PolymorphicConfiguration <AttachmentDataProvider> polymorphicConfiguration = null;
                 if (!userContext.IsGroupUserContext)
                 {
                     polymorphicConfiguration = new PolymorphicConfiguration <AttachmentDataProvider>();
                     try
                     {
                         polymorphicConfiguration.Load(callContext);
                     }
                     catch (TypeLoadException)
                     {
                     }
                     this.dataProviders = polymorphicConfiguration.Entries.ToDictionary((AttachmentDataProvider x) => x.Id);
                 }
                 else
                 {
                     this.dataProviders = new Dictionary <string, AttachmentDataProvider>();
                 }
                 this.EnsureOneDriveProDataProvider(callContext, polymorphicConfiguration, userContext);
                 IEnumerable <AttachmentDataProvider> enumerable = from x in this.dataProviders.Values
                                                                   where x is IAttachmentDataProviderChanged
                                                                   select x;
                 foreach (AttachmentDataProvider attachmentDataProvider in enumerable)
                 {
                     ((IAttachmentDataProviderChanged)attachmentDataProvider).AttachmentDataProviderChanged += this.ProviderChanged;
                 }
             }
         }
     }
 }