示例#1
0
        private static FeedUri?TryResolveAlias(string uri)
        {
#if NETCOREAPP
            return(null);
#else
            var appList = AppList.LoadSafe();

            const string aliasPrefix = "alias:";
            if (uri.StartsWith(aliasPrefix))
            {
                string aliasName = uri.Substring(aliasPrefix.Length);
                var    result    = appList.ResolveAlias(aliasName);

                if (result == null)
                {
                    throw new UriFormatException(string.Format(Resources.AliasNotFound, aliasName));
                }
                return(result);
            }
            else
            {
                string aliasName = uri;
                var    result    = appList.ResolveAlias(aliasName);

                if (result != null)
                {
                    Log.Info(string.Format(Resources.ResolvedUsingAlias, aliasName, result));
                }
                return(result);
            }
#endif
        }
示例#2
0
    private static FeedUri?TryResolveAlias(string uri)
    {
        var appList = AppList.LoadSafe();

        const string aliasPrefix = "alias:";

        if (uri.StartsWith(aliasPrefix, out string?aliasName))
        {
            var result = appList.ResolveAlias(aliasName);

            if (result == null)
            {
                throw new UriFormatException(string.Format(Resources.AliasNotFound, aliasName));
            }
            return(result);
        }
        else
        {
            aliasName = uri;
            var result = appList.ResolveAlias(aliasName);

            if (result != null)
            {
                Log.Info(string.Format(Resources.ResolvedUsingAlias, aliasName, result));
            }
            return(result);
        }
    }
示例#3
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        var apps = AppList.LoadSafe(MachineWide);

        if (AdditionalArgs.Count > 0)
        {
            if (Uri.TryCreate(AdditionalArgs[0], UriKind.Absolute, out var uri))
            {
                var feedUri = new FeedUri(uri);
                apps.Entries.RemoveAll(x => x.InterfaceUri != feedUri);
            }
            else
            {
                apps.Entries.RemoveAll(x => !x.Name.ContainsIgnoreCase(AdditionalArgs[0]));
            }
        }

        if (_xmlOutput)
        {
            Handler.Output(Resources.MyApps, apps.ToXmlString());
        }
        else
        {
            Handler.Output(Resources.MyApps, apps.Entries);
        }
        return(ExitCode.OK);
    }
        /// <summary>
        /// Loads the current <see cref="AppList"/> from the disk and updates the "My Apps" <see cref="IAppTileList"/>.
        /// </summary>
        /// <returns>A list of <see cref="IAppTile"/>s that need to be injected with <see cref="Feed"/> data.</returns>
        public IEnumerable <IAppTile> UpdateMyApps()
        {
            var newAppList = AppList.LoadSafe(_machineWide);
            var tiles      = new List <IAppTile>();

            // Update the displayed AppList based on changes detected between the current and the new AppList
            Merge.TwoWay(
                theirs: newAppList.Entries, mine: AppList.Entries,
                added: entry =>
            {
                if (entry.InterfaceUri == null || entry.Name == null)
                {
                    return;
                }
                try
                {
                    var status = (entry.AccessPoints == null) ? AppStatus.Added : AppStatus.Integrated;
                    var tile   = _tileListMyApps.QueueNewTile(entry.InterfaceUri, entry.Name, status, _iconStore, _machineWide);
                    tiles.Add(tile);

                    // Update "added" status of tile in catalog list
                    var catalogTile = _tileListCatalog.GetTile(entry.InterfaceUri);
                    if (catalogTile != null)
                    {
                        catalogTile.Status = tile.Status;
                    }
                }
                #region Error handling
                catch (KeyNotFoundException)
                {
                    Log.Warn(string.Format(Resources.UnableToLoadFeedForApp, entry.InterfaceUri));
                }
                catch (InvalidOperationException)
                {
                    Log.Warn(string.Format(Resources.IgnoringDuplicateAppListEntry, entry.InterfaceUri));
                }
                #endregion
            },
                removed: entry =>
            {
                if (entry.InterfaceUri == null)
                {
                    return;
                }
                _tileListMyApps.RemoveTile(entry.InterfaceUri);

                // Update "added" status of tile in catalog list
                var catalogTile = _tileListCatalog.GetTile(entry.InterfaceUri);
                if (catalogTile != null)
                {
                    catalogTile.Status = AppStatus.Candidate;
                }
            });
            _tileListMyApps.AddQueuedTiles();
            AppList = newAppList;

            return(tiles);
        }
        public void GetInstalledPackages(string name)
        {
            var appList = AppList.LoadSafe(MachineWide);

            foreach (var entry in appList.Search(name))
            {
                Yield(entry.EffectiveRequirements);
            }
        }
示例#6
0
        /// <inheritdoc/>
        public override ExitCode Execute()
        {
            IEnumerable <AppEntry> apps = AppList.LoadSafe(MachineWide).Entries;

            if (AdditionalArgs.Count > 0)
            {
                apps = apps.Where(x => x.Name.ContainsIgnoreCase(AdditionalArgs[0]));
            }

            Handler.Output(Resources.MyApps, apps);
            return(ExitCode.OK);
        }
示例#7
0
        /// <summary>
        /// Returns a list of <see cref="Requirements"/> that describe the applications to be updated.
        /// </summary>
        private IEnumerable <Requirements> GetTargets()
        {
            var appList = AppList.LoadSafe(MachineWide);

            // Target every application in the AppList...
            return(from entry in appList.Entries
                   // ... unless excluded from auto-update
                   where entry.AutoUpdate
                   // ... or excluded by a hostname filter
                   where entry.Hostname == null || Regex.IsMatch(Environment.MachineName, entry.Hostname)
                   // Use custom app restrictions if any
                   select entry.Requirements ?? new Requirements(entry.InterfaceUri));
        }
示例#8
0
        private static FeedUri ResolveAlias(string aliasName)
        {
            var appList = AppList.LoadSafe();

            AppEntry appEntry;

            AddAlias.GetAppAlias(appList, aliasName, out appEntry);
            if (appEntry?.InterfaceUri == null)
            {
                throw new UriFormatException(string.Format(Resources.AliasNotFound, aliasName));
            }
            return(appEntry.InterfaceUri);
        }
示例#9
0
 private List <Requirements> GetApps()
 => AppList.LoadSafe(MachineWide)
 .Entries
 .Where(entry => entry.AutoUpdate && (entry.Hostname == null || Regex.IsMatch(Environment.MachineName, entry.Hostname)))
 .Select(entry => entry.Requirements ?? entry.InterfaceUri)
 .ToList();
示例#10
0
 /// <summary>
 /// Indicates whether any desktop integration for apps has been performed yet.
 /// </summary>
 private static bool ExistingDesktopIntegration(bool machineWide)
 => AppList.LoadSafe(machineWide).Entries.Any(x => x.AccessPoints != null);