コード例 #1
0
        public void InstalledPackage(CanonicalName canonicalName)
        {
            _packages.Value.Add(Package.GetPackage(canonicalName));
            Package.GetPackage(canonicalName).IsInstalled = true;

            Task.Factory.StartNew(() => {
                if (PackageManager.Instance.Telemetry)
                {
                    // ping the coapp server to tell it that a package installed
                    try {
                        Logger.Message("Pinging `http://coapp.org/telemetry/?anonid={0}&pkg={1}` ".format(PackageManager.Instance.AnonymousId, canonicalName));
                        var req =
                            HttpWebRequest.Create("http://coapp.org/telemetry/?anonid={0}&pkg={1}".format(PackageManager.Instance.AnonymousId, canonicalName));
                        req.BetterGetResponse().Close();
                    } catch {
                        // who cares...
                    }
                }
            }, TaskCreationOptions.AttachedToParent);

            try {
                Event <PackageInstalled> .Raise(canonicalName);
            }
            catch (Exception e) {
                Logger.Error("CRITICAL: PackageInstalled event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
            }
        }
コード例 #2
0
        public void PackageSatisfiedBy(string requestedCanonicalName, string satisfiedByCanonicalName)
        {
            var pkg = Package.GetPackage(requestedCanonicalName);

            // pkg.SatisfiedBy = Package.GetPackage(satisfiedByCanonicalName);
            _packages.Value.Add(pkg);
        }
コード例 #3
0
 public void RemovedPackage(CanonicalName canonicalName)
 {
     _packages.Value.Add(Package.GetPackage(canonicalName));
     Package.GetPackage(canonicalName).IsInstalled = false;
     try {
         Event <PackageRemoved> .Raise(canonicalName);
     }
     catch (Exception e) {
         Logger.Error("CRITICAL: PackageRemoved event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
     }
 }
コード例 #4
0
ファイル: PackageManager.cs プロジェクト: caoxk/coapp
        public Task <Package> GetPackageDetails(CanonicalName canonicalName, bool forceRefresh = false)
        {
            return(Package.GetPackage(canonicalName).AsResultTask());

            /*
             * if (!canonicalName.IsCanonical) {
             *  return InvalidCanonicalNameResult<Package>(canonicalName);
             * }
             *
             * return GetPackage(canonicalName, forceRefresh).Continue(pkg => {
             *  if (forceRefresh || pkg.IsPackageDetailsStale) {
             *      Remote.GetPackageDetails(canonicalName).Wait();
             *  }
             *  return pkg;
             * });
             * */
        }
コード例 #5
0
ファイル: PackageManager.cs プロジェクト: caoxk/coapp
        public Task <Package> GetPackage(CanonicalName canonicalName, bool forceRefresh = false)
        {
            if (null == canonicalName)
            {
                return(CoTask.AsResultTask <Package>(null));
            }
            if (!canonicalName.IsCanonical)
            {
                return(InvalidCanonicalNameResult <Package>(canonicalName));
            }

            var pkg = Package.GetPackage(canonicalName);

            if (forceRefresh || pkg.IsPackageInfoStale)
            {
                return((Remote.FindPackages(canonicalName, null, null, null) as Task <PackageManagerResponseImpl>).Continue(response => pkg));
            }

            return(pkg.AsResultTask());
        }
コード例 #6
0
 public void UnableToInstallPackage(CanonicalName packageCanonicalName)
 {
     throw new PackageInstallFailedException(Package.GetPackage(packageCanonicalName));
 }
コード例 #7
0
 public void PackageHasPotentialUpgrades(CanonicalName packageCanonicalName, IEnumerable <CanonicalName> supercedents)
 {
     UpgradablePackage = Package.GetPackage(packageCanonicalName);
     PotentialUpgrades = supercedents.Select(Package.GetPackage);
     throw new PackageHasPotentialUpgradesException(Package.GetPackage(packageCanonicalName), PotentialUpgrades);
 }
コード例 #8
0
        public void PackageDetails(CanonicalName canonicalName, PackageDetails details)
        {
            var result = Package.GetPackage(canonicalName);

            result.PackageDetails = details;
        }
コード例 #9
0
 static Session()
 {
     UrlEncodedMessage.AddTypeSubstitution <IPackage>((message, objectName, expectedType) => Package.GetPackage(message[objectName + ".CanonicalName"]));
 }