public AuthorizationContentLoader(Frame frame, INavigationContentLoader loader)
 {
     if (frame == null)
     {
         throw new ArgumentNullException("frame");
     }
     if (loader == null)
     {
         throw new ArgumentNullException("loader");
     }
     this._frame  = frame;
     this._loader = loader;
 }
コード例 #2
0
 public override void Load(Uri targetUri, Uri currentUri)
 {
     _loader = _parent.ContentLoader;
     try
     {
         if (!_loader.CanLoad(targetUri, currentUri))
         {
             throw new CannotLoadException(_loader, targetUri, currentUri);
         }
         _result = _loader.BeginLoad(targetUri, currentUri, res =>
         {
             try
             {
                 LoadResult lr = _loader.EndLoad(res);
                 if (lr.LoadedContent != null)
                 {
                     if (!(lr.LoadedContent is UserControl))
                     {
                         throw new InvalidContentException(
                             lr.LoadedContent);
                     }
                     Complete(lr.LoadedContent);
                     return;
                 }
                 Complete(lr.RedirectUri);
                 return;
             }
             catch (Exception e)
             {
                 var ep = GetErrorPage(e);
                 if (ep == null)
                 {
                     Error(e);
                     return;
                 }
                 ErrorLoad(ep.Map(e), currentUri, e);
             }
         }, null);
     }
     catch (Exception e)
     {
         var ep = GetErrorPage(e);
         if (ep == null)
         {
             Error(e);
             return;
         }
         ErrorLoad(ep.Map(e), currentUri, e);
     }
 }
コード例 #3
0
            public override void Load(Uri targetUri, Uri currentUri)
            {
                _loader = _parent.ContentLoader ?? _defaultLoader;
                if (_parent.Authorizer != null)
                {
                    try
                    {
                        _parent.Authorizer.CheckAuthorization(_parent.Principal, targetUri, currentUri);
                    }
                    catch (Exception e)
                    {
                        Error(e);
                        return;
                    }
                }
                try
                {
                    _result = _loader.BeginLoad(targetUri, currentUri, res =>
                    {
                        try
                        {
                            var loadResult = _loader.EndLoad(res);
                            if (loadResult.RedirectUri != null)
                            {
                                Complete(loadResult.RedirectUri);
                            }
                            else
                            {
                                Complete(loadResult.LoadedContent);
                            }

                            return;
                        }
                        catch (Exception e)
                        {
                            Error(e);
                            return;
                        }
                    }, null);
                }
                catch (Exception e)
                {
                    Error(e);
                    return;
                }
            }
コード例 #4
0
        private static void ContentLoaderPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            Frame frame = (Frame)depObj;
            INavigationContentLoader contentLoader = (INavigationContentLoader)e.NewValue;

            if (contentLoader == null)
            {
                throw new ArgumentNullException("ContentLoader");
            }

            if (frame.NavigationService.IsNavigating)
            {
                throw new InvalidOperationException(String.Format(Resource.Frame_CannotSetLoaderWhenLoading, "ContentLoader"));
            }
            else
            {
                frame.NavigationService.ContentLoader = contentLoader;
            }
        }
コード例 #5
0
 private void ErrorLoad(Uri errorTarget, Uri currentUri, Exception ex)
 {
     _loader = _parent.ErrorContentLoader ?? _parent.ContentLoader;
     try
     {
         _result = _loader.BeginLoad(errorTarget, currentUri, res =>
         {
             try
             {
                 LoadResult lr = _loader.EndLoad(res);
                 if (lr.LoadedContent != null)
                 {
                     if (lr.LoadedContent is DependencyObject)
                     {
                         SetError(
                             (lr.LoadedContent as DependencyObject),
                             ex);
                     }
                     Complete(lr.LoadedContent);
                     return;
                 }
                 Complete(lr.RedirectUri);
                 return;
             }
             catch (Exception e)
             {
                 Error(e);
                 return;
             }
         }, null);
     }
     catch (Exception e)
     {
         Error(e);
         return;
     }
 }
コード例 #6
0
 public void TestInitialize()
 {
     this.PageResourceContentLoader = new PageResourceContentLoader();
 }
コード例 #7
0
 private void ErrorLoad(Uri errorTarget, Uri currentUri, Exception ex)
 {
   _loader = _parent.ErrorContentLoader ?? _parent.ContentLoader;
   try
   {
     _result = _loader.BeginLoad(errorTarget, currentUri, res =>
     {
       try
       {
         LoadResult lr = _loader.EndLoad(res);
         if (lr.LoadedContent != null)
         {
           if (lr.LoadedContent is DependencyObject)
             SetError(
               (lr.LoadedContent as DependencyObject),
               ex);
           Complete(lr.LoadedContent);
           return;
         }
         Complete(lr.RedirectUri);
         return;
       }
       catch (Exception e)
       {
         Error(e);
         return;
       }
     }, null);
   }
   catch (Exception e)
   {
     Error(e);
     return;
   }
 }
コード例 #8
0
 public override void Load(Uri targetUri, Uri currentUri)
 {
   _loader = _parent.ContentLoader;
   try
   {
     if (!_loader.CanLoad(targetUri, currentUri))
       throw new CannotLoadException(_loader, targetUri, currentUri);
     _result = _loader.BeginLoad(targetUri, currentUri, res =>
     {
       try
       {
         LoadResult lr = _loader.EndLoad(res);
         if (lr.LoadedContent != null)
         {
           if (!(lr.LoadedContent is UserControl))
             throw new InvalidContentException(
               lr.LoadedContent);
           Complete(lr.LoadedContent);
           return;
         }
         Complete(lr.RedirectUri);
         return;
       }
       catch (Exception e)
       {
         var ep = GetErrorPage(e);
         if (ep == null)
         {
           Error(e);
           return;
         }
         ErrorLoad(ep.Map(e), currentUri, e);
       }
     }, null);
   }
   catch (Exception e)
   {
     var ep = GetErrorPage(e);
     if (ep == null)
     {
       Error(e);
       return;
     }
     ErrorLoad(ep.Map(e), currentUri, e);
   }
 }
コード例 #9
0
 public Loader(ErrorPageLoader parent)
 {
   _loader = parent.ContentLoader;
   _parent = parent;
   _errorPages = parent.ErrorPages;
 }
コード例 #10
0
 public Loader(ErrorPageLoader parent)
 {
     _loader     = parent.ContentLoader;
     _parent     = parent;
     _errorPages = parent.ErrorPages;
 }
コード例 #11
0
      public override void Load(Uri targetUri, Uri currentUri)
      {
        _loader = _parent.ContentLoader ?? _defaultLoader;
        if (_parent.Authorizer != null)
        {
          try
          {
            _parent.Authorizer.CheckAuthorization(_parent.Principal, targetUri, currentUri);
          }
          catch (Exception e)
          {
            Error(e);
            return;
          }
        }
        try
        {
          _result = _loader.BeginLoad(targetUri, currentUri, res =>
          {
            try
            {
              var loadResult = _loader.EndLoad(res);
              if (loadResult.RedirectUri != null)
                Complete(loadResult.RedirectUri);
              else
                Complete(loadResult.LoadedContent);

              return;
            }
            catch (Exception e)
            {
              Error(e);
              return;
            }
          }, null);
        }
        catch (Exception e)
        {
          Error(e);
          return;
        }
      }
 public void TestInitialize()
 {
     this.PageResourceContentLoader = new PageResourceContentLoader();
 }
コード例 #13
0
 /// <summary>
 ///   Constructs a CannotLoadException.
 /// </summary>
 /// <param name = "loader">The loader whose CanLoad method returned false.</param>
 /// <param name = "targetUri">The targetUri passed into CanLoad.</param>
 /// <param name = "currentUri">The currentUri passed into CanLoad.</param>
 public CannotLoadException(INavigationContentLoader loader, Uri targetUri, Uri currentUri)
 {
     Loader     = loader;
     TargetUri  = targetUri;
     CurrentUri = currentUri;
 }
コード例 #14
0
ファイル: Shell.xaml.cs プロジェクト: Rammesses/PMC-Sample
        public Shell(INavigationContentLoader contentLoader)
        {
            InitializeComponent();

            this.ContentFrame.ContentLoader = contentLoader;
        }
コード例 #15
0
 /// <summary>
 ///   Constructs a CannotLoadException.
 /// </summary>
 /// <param name = "loader">The loader whose CanLoad method returned false.</param>
 /// <param name = "targetUri">The targetUri passed into CanLoad.</param>
 /// <param name = "currentUri">The currentUri passed into CanLoad.</param>
 public CannotLoadException(INavigationContentLoader loader, Uri targetUri, Uri currentUri)
 {
   Loader = loader;
   TargetUri = targetUri;
   CurrentUri = currentUri;
 }