Represents a page within the application's user interface.
Наследование: System.Windows.Controls.View
Пример #1
0
        /// <internalonly />
        protected override IAsyncResult BeginLoadUri(Uri uri, Page uriContext, AsyncCallback callback, object asyncState)
        {
            if (_currentController != null) {
                throw new InvalidOperationException();
            }

            UriData uriData = new UriData(uri);

            IList<string> path = uriData.GetPath();
            int minimumCount = _controllerType != null ? 1 : 2;

            if ((path != null) && (path.Count >= minimumCount)) {
                Controller controller = null;

                Type controllerType = _controllerType;
                if (controllerType == null) {
                    Type appType = Application.Current.GetType();

                    _currentControllerName = path[0];
                    path.RemoveAt(0);

                    string controllerTypeName =
                        appType.Namespace + ".Controllers." + _currentControllerName + "Controller";

                    controllerType = appType.Assembly.GetType(controllerTypeName, /* throwOnError */ false);
                    if (typeof(Controller).IsAssignableFrom(controllerType) == false) {
                        controllerType = null;
                    }
                }
                if (controllerType != null) {
                    controller = CreateController(controllerType);
                }

                if (controller != null) {
                    _currentController = controller;

                    _currentActionName = path[0];
                    path.RemoveAt(0);

                    ActionInvocation action = new ActionInvocation(_currentActionName);
                    foreach (string parameterItem in path) {
                        action.Parameters.Add(parameterItem);
                    }

                    IDictionary<string, string> queryString = uriData.GetQueryString();
                    if (queryString != null) {
                        foreach (KeyValuePair<string, string> parameterItem in queryString) {
                            action.NamedParameters[parameterItem.Key] = parameterItem.Value;
                        }
                    }

                    return ((IController)controller).BeginExecute(action, callback, asyncState);
                }
            }

            return base.BeginLoadUri(uri, uriContext, callback, asyncState);
        }
Пример #2
0
        public void AddPageReference(Page page)
        {
            if (page.KeepAlive == false) {
                return;
            }

            string cacheKey = GetCacheKey(page.Uri);

            if ((_pages.ContainsKey(cacheKey) == false) &&
                (_keepAlivePages.ContainsKey(cacheKey) == false)) {
                if (_keys.Count >= _cacheSize) {
                    string evictCacheKey = _keys[_keys.Count - 1];

                    _pages.Remove(evictCacheKey);
                }

                _pages[cacheKey] = page;
                _keys.Add(cacheKey);
            }
        }
Пример #3
0
        public void AddPage(Page page, Uri pageUri)
        {
            if (page.Cache.HasValue && (page.Cache == false)) {
                return;
            }

            string cacheKey = GetCacheKey(pageUri);

            if (page.Cache.HasValue && (page.Cache == true)) {
                _keepAlivePages.Add(cacheKey, page);
                return;
            }

            if (_keys.Count >= _cacheSize) {
                _pages.Remove(_keys[_keys.Count - 1]);
                _keys.RemoveAt(_keys.Count - 1);
            }

            _keys.Insert(0, cacheKey);
            _pages.Add(cacheKey, page);
        }
Пример #4
0
        public void RemovePageReference(Page page)
        {
            string cacheKey = GetCacheKey(page.Uri);

            if (page.KeepAlive == true) {
                if (_pages.ContainsKey(cacheKey)) {
                    _pages.Remove(cacheKey);
                    _keys.Remove(cacheKey);
                }

                _keepAlivePages[cacheKey] = page;
            }
        }