PageRenderTime 25ms CodeModel.GetById 12ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/src/AddIns/Misc/PackageManagement/Project/Src/PackageFromRepository.cs

https://github.com/ajadex/SharpDevelop
C# | 215 lines | 156 code | 42 blank | 17 comment | 6 complexity | def48702b3d68fdd235f0a95dbb14db1 MD5 | raw file
  1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
  2// 
  3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4// software and associated documentation files (the "Software"), to deal in the Software
  5// without restriction, including without limitation the rights to use, copy, modify, merge,
  6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7// to whom the Software is furnished to do so, subject to the following conditions:
  8// 
  9// The above copyright notice and this permission notice shall be included in all copies or
 10// substantial portions of the Software.
 11// 
 12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 17// DEALINGS IN THE SOFTWARE.
 18
 19using System;
 20using System.Collections.Generic;
 21using System.IO;
 22using System.Runtime.Versioning;
 23
 24using NuGet;
 25
 26namespace ICSharpCode.PackageManagement
 27{
 28	public class PackageFromRepository : IPackageFromRepository
 29	{
 30		IPackage package;
 31		bool? hasDependencies;
 32		
 33		public PackageFromRepository(IPackage package, IPackageRepository repository)
 34		{
 35			this.package = package;
 36			this.Repository = repository;
 37		}
 38
 39		public IPackageRepository Repository { get; private set; }
 40		
 41		public IEnumerable<IPackageAssemblyReference> AssemblyReferences {
 42			get { return package.AssemblyReferences; }
 43		}
 44		
 45		public string Id {
 46			get { return package.Id; }
 47		}
 48		
 49		public SemanticVersion Version {
 50			get { return package.Version; }
 51		}
 52		
 53		public string Title {
 54			get { return package.Title; }
 55		}
 56		
 57		public IEnumerable<string> Authors {
 58			get { return package.Authors; }
 59		}
 60		
 61		public IEnumerable<string> Owners {
 62			get { return package.Owners; }
 63		}
 64		
 65		public Uri IconUrl {
 66			get { return package.IconUrl; }
 67		}
 68		
 69		public Uri LicenseUrl {
 70			get { return package.LicenseUrl; }
 71		}
 72		
 73		public Uri ProjectUrl {
 74			get { return package.ProjectUrl;}
 75		}
 76		
 77		public bool RequireLicenseAcceptance {
 78			get { return package.RequireLicenseAcceptance; }
 79		}
 80		
 81		public string Description {
 82			get { return package.Description; }
 83		}
 84		
 85		public string Summary {
 86			get { return package.Summary; }
 87		}
 88		
 89		public string Language {
 90			get { return package.Language; }
 91		}
 92		
 93		public string Tags {
 94			get { return package.Tags; }
 95		}
 96		
 97		public IEnumerable<FrameworkAssemblyReference> FrameworkAssemblies {
 98			get { return package.FrameworkAssemblies; }
 99		}
100		
101		public IEnumerable<PackageDependency> Dependencies {
102			get { return package.GetCompatiblePackageDependencies(null); }
103		}
104		
105		public Uri ReportAbuseUrl {
106			get { return package.ReportAbuseUrl; }
107		}
108		
109		public int DownloadCount {
110			get { return package.DownloadCount; }
111		}
112		
113		public DateTime? LastUpdated {
114			get { return GetLastUpdated(); }
115		}
116		
117		DateTime? GetLastUpdated()
118		{
119			DateTimeOffset? lastUpdated = GetDataServicePackageLastUpdated();
120			if (lastUpdated.HasValue) {
121				return lastUpdated.Value.DateTime;
122			}
123			return null;
124		}
125		
126		protected virtual DateTimeOffset? GetDataServicePackageLastUpdated()
127		{
128			var dataServicePackage = package as DataServicePackage;
129			if (dataServicePackage != null) {
130				return dataServicePackage.LastUpdated;
131			}
132			return null;
133		}
134		
135		public IEnumerable<IPackageFile> GetFiles()
136		{
137			return package.GetFiles();
138		}
139		
140		public Stream GetStream()
141		{
142			return package.GetStream();
143		}
144		
145		public bool HasDependencies {
146			get {
147				if (!hasDependencies.HasValue) {
148					IEnumerator<PackageDependency> enumerator = Dependencies.GetEnumerator();
149					hasDependencies = enumerator.MoveNext();
150				}
151				return hasDependencies.Value;
152			}
153		}
154		
155		public bool IsLatestVersion {
156			get { return package.IsLatestVersion; }
157		}
158		
159		public Nullable<DateTimeOffset> Published {
160			get { return package.Published; }
161		}
162		
163		public string ReleaseNotes {
164			get { return package.ReleaseNotes; }
165		}
166		
167		public string Copyright {
168			get { return package.Copyright; }
169		}
170		
171		public bool IsAbsoluteLatestVersion {
172			get { return package.IsAbsoluteLatestVersion; }
173		}
174		
175		public bool Listed {
176			get { return package.Listed; }
177		}
178		
179		public IEnumerable<PackageDependencySet> DependencySets {
180			get { return package.DependencySets; }
181		}
182		
183		public IEnumerable<FrameworkName> GetSupportedFrameworks()
184		{
185			return package.GetSupportedFrameworks();
186		}
187		
188		public override string ToString()
189		{
190			return package.ToString();
191		}
192		
193		public ICollection<PackageReferenceSet> PackageAssemblyReferences {
194			get { return package.PackageAssemblyReferences; }
195		}
196		
197		public Version MinClientVersion {
198			get { return package.MinClientVersion; }
199		}
200		
201		public Uri GalleryUrl {
202			get {
203				var dataServicePackage = package as DataServicePackage;
204				if (dataServicePackage != null) {
205					return dataServicePackage.GalleryDetailsUrl;
206				}
207				return null;
208			}
209		}
210		
211		public bool DevelopmentDependency {
212			get { return package.DevelopmentDependency; }
213		}
214	}
215}