/// <summary>
        /// To be called before updating to add/remove resource relationships according to the components.
        /// </summary>
        /// <returns>True if resources were updated.</returns>
        public bool UpdateResources(Page page)
        {
            var resourcesUpdated = false;
            var pageRes = _resourceManager.GetResourcesFromPage(page);
            var decs = getUICDeclarations(page);
            var compRes = decs.PageResources;

            // remove non required resources
            foreach (var res in pageRes)
            {
                if (!compRes.Any(r => res.Equals(r)))
                {
                    _resourceManager.RemoveResource(page, res);
                    resourcesUpdated = true;
                }
            }

            // add required resources
            foreach (var res in compRes)
            {
                if (!pageRes.Any(r => res.Equals(r)))
                {
                    _resourceManager.AddResource(page, res);
                    resourcesUpdated = true;
                }
            }

            // remove any unused properties
            var propsInUse = decs.PagePropertyNames;
            var propsToDelete = new List<string>();
            foreach (var prop in page.Properties)
            {
                if (propsInUse.All(p => p != prop.Name))
                {
                    propsToDelete.Add(prop.Name);
                }
            }

            foreach (var prop in propsToDelete)
            {
                page.DeleteProperty(prop);
            }

            return resourcesUpdated;
        }