本文整理汇总了C#中IPackage.GetFiles方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.GetFiles方法的具体用法?C# IPackage.GetFiles怎么用?C# IPackage.GetFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackage
的用法示例。
在下文中一共展示了IPackage.GetFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: is_valid
public override PackageValidationOutput is_valid(IPackage package)
{
var valid = true;
var files = package.GetFiles().or_empty_list_if_null();
foreach (var packageFile in files.or_empty_list_if_null())
{
string extension = Path.GetExtension(packageFile.Path).to_lower();
if (extension != ".ps1" && extension != ".psm1") continue;
var contents = packageFile.GetStream().ReadToEnd().to_lower();
if (contents.Contains("install-chocolateypackage") ||
contents.Contains("start-chocolateyprocessasadmin") ||
contents.Contains("install-chocolateyinstallpackage") ||
contents.Contains("install-chocolateyenvironmentvariable") ||
contents.Contains("install-chocolateyexplorermenuitem") ||
contents.Contains("install-chocolateyfileassociation"))
{
valid = package.Tags.to_string().Split(' ').Any(tag => tag.ToLower() == "admin");
}
}
return valid;
}
开发者ID:pkdevboxy,项目名称:package-validator,代码行数:26,代码来源:AdminTagShouldBeIncludedWhenUsingAdminHelpersGuideline.cs
示例2: Validate
public IEnumerable<PackageIssue> Validate(IPackage package)
{
foreach (IPackageFile file in package.GetFiles())
{
string path = file.Path;
string directory = Path.GetDirectoryName(path);
// if under 'lib' directly
if (directory.Equals(Constants.LibDirectory, StringComparison.OrdinalIgnoreCase))
{
if (PackageHelper.IsAssembly(path))
{
yield return CreatePackageIssueForAssembliesUnderLib(path);
}
}
else if (!directory.StartsWith(Constants.LibDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
// when checking for assemblies outside 'lib' folder, only check .dll files.
// .exe files are often legitimate outside 'lib'.
if (path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
path.EndsWith(".winmd", StringComparison.OrdinalIgnoreCase))
{
yield return CreatePackageIssueForAssembliesOutsideLib(path);
}
}
}
}
示例3: Validate
public IEnumerable<PackageIssue> Validate(IPackage package)
{
foreach (IPackageFile file in package.GetFiles())
{
string path = file.Path;
if (!path.EndsWith(ScriptExtension, StringComparison.OrdinalIgnoreCase))
{
continue;
}
if (!path.StartsWith(Constants.ToolsDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
yield return CreatePackageIssueForMisplacedScript(path);
}
else
{
string directory = Path.GetDirectoryName(path);
string name = Path.GetFileNameWithoutExtension(path);
if (!directory.Equals(Constants.ToolsDirectory, StringComparison.OrdinalIgnoreCase) ||
!name.Equals("install", StringComparison.OrdinalIgnoreCase) &&
!name.Equals("uninstall", StringComparison.OrdinalIgnoreCase) &&
!name.Equals("init", StringComparison.OrdinalIgnoreCase))
{
yield return CreatePackageIssueForUnrecognizedScripts(path);
}
}
}
}
示例4: UnzipPackageAsync
public async Task UnzipPackageAsync(IPackage package)
{
var dir = GetPackageSymbolPath(package);
Directory.CreateDirectory(dir);
var visitedDirectories = new HashSet<string>();
foreach (var file in package.GetFiles())
{
var filePath = Path.Combine(dir, file.Path);
var fileDir = Path.GetDirectoryName(filePath);
if (fileDir != null && !visitedDirectories.Contains(fileDir))
{
Directory.CreateDirectory(fileDir);
visitedDirectories.Add(fileDir);
}
using (var writeStream = File.OpenWrite(filePath))
{
using (var readStream = file.GetStream())
{
await readStream.CopyToAsync(writeStream);
}
}
}
}
示例5: PackageViewModel
internal PackageViewModel(
IPackage package,
string source,
IMruManager mruManager,
IUIServices uiServices,
IPackageEditorService editorService,
ISettingsManager settingsManager)
{
if (package == null) {
throw new ArgumentNullException("package");
}
if (mruManager == null) {
throw new ArgumentNullException("mruManager");
}
if (uiServices == null) {
throw new ArgumentNullException("uiServices");
}
if (editorService == null) {
throw new ArgumentNullException("editorService");
}
if (settingsManager == null) {
throw new ArgumentNullException("settingsManager");
}
_settingsManager = settingsManager;
_editorService = editorService;
_uiServices = uiServices;
_mruManager = mruManager;
_package = package;
_packageMetadata = new EditablePackageMetadata(_package);
PackageSource = source;
_packageRoot = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);
}
示例6: Extract
public NuDeployPackageInfo Extract(IPackage package, string targetFolder)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
if (string.IsNullOrWhiteSpace(targetFolder))
{
throw new ArgumentException("targetFolder");
}
string packageFolderName = string.Format("{0}.{1}", package.Id, package.Version);
string packageFolderPath = Path.Combine(targetFolder, packageFolderName);
if (this.fileSystemAccessor.DirectoryExists(packageFolderPath))
{
if (!this.fileSystemAccessor.DeleteDirectory(packageFolderPath))
{
return null;
}
}
try
{
foreach (var file in package.GetFiles())
{
using (Stream reader = file.GetStream())
{
if (reader == null)
{
return null;
}
string targetPath = Path.Combine(packageFolderPath, file.Path);
using (Stream writeStream = this.fileSystemAccessor.GetWriteStream(targetPath))
{
if (writeStream == null)
{
return null;
}
reader.CopyTo(writeStream);
}
}
}
return new NuDeployPackageInfo
{
Id = package.Id,
Version = package.Version,
Folder = packageFolderPath,
IsInstalled = false
};
}
catch (Exception)
{
return null;
}
}
示例7: is_valid
protected override PackageValidationOutput is_valid(IPackage package)
{
var files = package.GetFiles().or_empty_list_if_null();
var hasBadInstallScripts = files.Any(f => f.Path.to_lower().Contains("install.ps1")) && !files.Any(f => f.Path.to_lower().Contains("chocolateyinstall.ps1"));
return !hasBadInstallScripts;
}
示例8: FindReadMeFileInPackage
string FindReadMeFileInPackage (string installPath, IPackage package)
{
return package.GetFiles ()
.Where (file => "readme.txt".Equals (file.Path, StringComparison.OrdinalIgnoreCase))
.Select (file => Path.Combine (installPath, file.Path))
.FirstOrDefault ();
}
示例9: Curate
public override void Curate(
Package galleryPackage,
IPackage nugetPackage)
{
var curatedFeed = GetService<ICuratedFeedByNameQuery>().Execute("webmatrix");
if (curatedFeed == null)
return;
if (!galleryPackage.IsLatestStable)
return;
var shouldBeIncluded = galleryPackage.Tags != null && galleryPackage.Tags.ToLowerInvariant().Contains("aspnetwebpages");
if (!shouldBeIncluded)
{
shouldBeIncluded = true;
foreach (var file in nugetPackage.GetFiles())
{
var fi = new FileInfo(file.Path);
if (fi.Extension == ".ps1" || fi.Extension == ".t4")
{
shouldBeIncluded = false;
break;
}
}
}
if (shouldBeIncluded)
GetService<ICreateCuratedPackageCommand>().Execute(
curatedFeed.Key,
galleryPackage.PackageRegistration.Key,
automaticallyCurated: true);
}
示例10: is_valid
public override PackageValidationOutput is_valid(IPackage package)
{
var files = package.GetFiles().or_empty_list_if_null();
var hasBadInstallScripts = files.Any(f => StringExtensions.to_lower(f.Path).Contains("uninstall.ps1")) && !files.Any(f => f.Path.to_lower().Contains("chocolateyuninstall.ps1"));
return !hasBadInstallScripts;
}
开发者ID:pkdevboxy,项目名称:package-validator,代码行数:7,代码来源:UninstallAutomationScriptNamedCorrectlyRequirement.cs
示例11: is_valid
public override PackageValidationOutput is_valid(IPackage package)
{
var files = package.GetFiles().or_empty_list_if_null();
return !files.Any(
f => f.Path.to_lower().Contains("thumbs.db")
|| f.Path.to_lower().Contains(".ds_store")
);
}
开发者ID:gep13,项目名称:package-validator,代码行数:8,代码来源:OperatingSystemIndexFilesAreNotPackagedRequirement.cs
示例12: Validate
public IEnumerable<PackageVerifierIssue> Validate(IPackageRepository packageRepo, IPackage package, IPackageVerifierLogger logger)
{
foreach (IPackageFile currentFile in package.GetFiles())
{
string extension = Path.GetExtension(currentFile.Path);
if (extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) ||
extension.Equals(".exe", StringComparison.OrdinalIgnoreCase))
{
string assemblyPath = Path.ChangeExtension(Path.Combine(Path.GetTempPath(), Path.GetTempFileName()), extension);
var isManagedCode = false;
var isStrongNameSigned = false;
int hresult = 0;
try
{
using (Stream packageFileStream = currentFile.GetStream())
{
var _assemblyBytes = new byte[packageFileStream.Length];
packageFileStream.Read(_assemblyBytes, 0, _assemblyBytes.Length);
using (var fileStream = new FileStream(assemblyPath, FileMode.Create))
{
packageFileStream.Seek(0, SeekOrigin.Begin);
packageFileStream.CopyTo(fileStream);
fileStream.Flush(true);
}
if (AssemblyHelpers.IsAssemblyManaged(assemblyPath))
{
isManagedCode = true;
var clrStrongName = (IClrStrongName)RuntimeEnvironment.GetRuntimeInterfaceAsObject(new Guid("B79B0ACD-F5CD-409b-B5A5-A16244610B92"), new Guid("9FD93CCF-3280-4391-B3A9-96E1CDE77C8D"));
bool verificationForced;
hresult = clrStrongName.StrongNameSignatureVerificationEx(assemblyPath, true, out verificationForced);
if (hresult == 0)
{
isStrongNameSigned = true;
}
}
}
}
catch (Exception ex)
{
logger.LogError("Error while verifying strong name signature for {0}: {1}", currentFile.Path, ex.Message);
}
finally
{
if (File.Exists(assemblyPath))
{
File.Delete(assemblyPath);
}
}
if (isManagedCode && !isStrongNameSigned)
{
yield return PackageIssueFactory.AssemblyNotStrongNameSigned(currentFile.Path, hresult);
}
}
}
yield break;
}
示例13: is_valid
public override PackageValidationOutput is_valid(IPackage package)
{
var files = package.GetFiles().or_empty_list_if_null();
return !files.Any(
f => f.Path.to_lower().Contains(".git\\")
|| f.Path.to_lower().Contains(".svn\\")
|| f.Path.to_lower().Contains(".hg\\")
);
}
开发者ID:pkdevboxy,项目名称:package-validator,代码行数:9,代码来源:SourceControlInternalFilesAreNotPackagedRequirement.cs
示例14: is_valid
public override PackageValidationOutput is_valid(IPackage package)
{
return !package.GetFiles().or_empty_list_if_null().Any(
f =>
f.Path.to_lower().EndsWith(".exe") ||
f.Path.to_lower().EndsWith(".msi") ||
f.Path.to_lower().EndsWith(".zip")
);
}
示例15: AndGivenAPackageForANewerVersionOfTheApp
void AndGivenAPackageForANewerVersionOfTheApp()
{
_package = Packages.FromVersions(TestConstants.AppPackageId, new Version(1, 1)).Single();
_appFiles = GetAppFileSubstitutes("app", "app.exe", "app.exe.config", "nuget.dll", @"content\logo.png").ToArray();
_otherFiles = GetAppFileSubstitutes("", "README.md").ToArray();
var packageFiles = _appFiles.Concat(_otherFiles);
_package.GetFiles().Returns(packageFiles);
}