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; }
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); } }
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; } }
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; } }
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; } }
public void TestInitialize() { this.PageResourceContentLoader = new PageResourceContentLoader(); }
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; } }
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); } }
public Loader(ErrorPageLoader parent) { _loader = parent.ContentLoader; _parent = parent; _errorPages = parent.ErrorPages; }
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; } }
/// <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; }
public Shell(INavigationContentLoader contentLoader) { InitializeComponent(); this.ContentFrame.ContentLoader = contentLoader; }