11using System ;
2+ using System . IO . Packaging ;
23using System . ComponentModel . Composition ;
34using System . Diagnostics ;
45using System . Reactive ;
56using System . Reactive . Linq ;
6- using System . Windows ;
77using System . Windows . Media . Imaging ;
88using Akavache ;
99using GitHub . Caches ;
1010using GitHub . Extensions ;
1111using GitHub . Models ;
12+ using System . Windows ;
1213
1314namespace GitHub . Services
1415{
@@ -24,13 +25,9 @@ public class AvatarProvider : IAvatarProvider
2425
2526 static AvatarProvider ( )
2627 {
27- // NB: If this isn't explicitly set, WPF will try to guess it via
28- // GetEntryAssembly, which in a unit test runner will be null
29- // This is needed for the pack:// URL format to be understood.
30- if ( Application . ResourceAssembly == null )
31- {
32- Application . ResourceAssembly = typeof ( AvatarProvider ) . Assembly ;
33- }
28+ // Calling `Application.Current` will install pack URI scheme via Application.cctor.
29+ // This is needed when unit testing for the pack:// URL format to be understood.
30+ if ( Application . Current != null ) { }
3431 }
3532
3633 [ ImportingConstructor ]
@@ -71,7 +68,7 @@ public IObservable<BitmapSource> GetAvatar(IAvatarContainer apiAccount)
7168 return imageCache . GetImage ( avatarUrl )
7269 . Catch < BitmapSource , Exception > ( _ => Observable . Return ( DefaultAvatar ( apiAccount ) ) ) ;
7370 }
74-
71+
7572 public IObservable < Unit > InvalidateAvatar ( IAvatarContainer apiAccount )
7673 {
7774 return String . IsNullOrWhiteSpace ( apiAccount ? . Login )
@@ -87,7 +84,7 @@ BitmapImage DefaultAvatar(IAvatarContainer apiAccount)
8784 }
8885
8986 protected virtual void Dispose ( bool disposing )
90- { }
87+ { }
9188
9289 public void Dispose ( )
9390 {
0 commit comments