本文整理汇总了C#中Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于命名空间,在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadPackage
private static void DownloadPackage(Package package, int index, int count)
{
var http_response = package.Download ();
if (http_response == null) {
throw new IOException ();
}
Directory.CreateDirectory (Path.GetDirectoryName (package.RelativeLocation));
File.Delete (package.RelativeLocation);
var xfer_stats = new RepoTransferStatistics () {
Label = package.Name,
Index = index,
Count = count,
TotalSize = http_response.ContentLength
};
using (var http_stream = http_response.GetResponseStream ()) {
using (var file_stream = File.OpenWrite (package.RelativeLocation)) {
http_stream.TransferTo (file_stream,
(total_read, final_block, block, block_size) =>
xfer_stats.CommitNewBlock (block, block_size, final_block));
}
File.SetCreationTime (package.RelativeLocation, package.FileTime);
File.SetLastWriteTime (package.RelativeLocation, package.FileTime);
File.SetLastAccessTime (package.RelativeLocation, package.FileTime);
}
}
示例2: TheCtorSortsPackageVersionsProperly
public void TheCtorSortsPackageVersionsProperly()
{
var package = new Package
{
Dependencies = Enumerable.Empty<PackageDependency>().ToList(),
PackageRegistration = new PackageRegistration
{
Owners = Enumerable.Empty<User>().ToList(),
}
};
package.PackageRegistration.Packages = new Package[]
{
new Package {Version = "1.0.0alpha2", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.0", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.0alpha", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.0beta", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.2beta", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.2", PackageRegistration = package.PackageRegistration},
new Package {Version = "1.0.10", PackageRegistration = package.PackageRegistration}
};
var packageVersions = new DisplayPackageViewModel(package).PackageVersions.ToList();
// Descending
Assert.Equal("1.0.0alpha", packageVersions[6].Version);
Assert.Equal("1.0.0alpha2", packageVersions[5].Version);
Assert.Equal("1.0.0beta", packageVersions[4].Version);
Assert.Equal("1.0.0", packageVersions[3].Version);
Assert.Equal("1.0.2beta", packageVersions[2].Version);
Assert.Equal("1.0.2", packageVersions[1].Version);
Assert.Equal("1.0.10", packageVersions[0].Version);
}
示例3: SendPackage
public void SendPackage(Package package)
{
var dt = DateTime.Now;
_writer.Write(dt.ToString("mm:ss.fff") + " : ");
_writer.WriteLine(package.ToString());
_writer.Flush();
}
示例4: VariablesMove
public VariablesMove(Package package, string selectedContainerId, int selectedVariablesCount)
{
this.selectedContainerId = selectedContainerId;
InitializeComponent();
IterateContainers(package, this.treeView.Nodes, selectedContainerId);
// Expand root node, the package
this.treeView.Nodes[0].Expand();
this.Icon = BIDSHelper.Resources.Common.Copy;
// Change caption based on count of selected variables,
// makes form less clutered and easier to read.
if (selectedVariablesCount > 1)
{
this.radCopy.Text = "Copy variables to...";
this.radMove.Text = "Move variables to...";
}
else
{
this.radCopy.Text = "Copy variable to...";
this.radMove.Text = "Move variable to...";
}
}
示例5: Parameterize
protected virtual void Parameterize(IEnumerable<EtlParameter> parameters, ref Package package)
{
foreach (var param in parameters)
{
package.Parameters[param.Name].Value = param.StringValue;
}
}
示例6: CreateNuGetExeDownloadExtractsFileIfItExistsButIsNotRecent
public void CreateNuGetExeDownloadExtractsFileIfItExistsButIsNotRecent()
{
// Arrange
var fileSystem = new Mock<IFileSystemService>(MockBehavior.Strict);
fileSystem.Setup(s => s.FileExists(_exePath)).Returns(true);
fileSystem.Setup(s => s.GetCreationTimeUtc(_exePath))
.Returns(DateTime.UtcNow.Subtract(TimeSpan.FromHours(32)));
fileSystem.Setup(s => s.OpenWrite(_exePath)).Returns(Stream.Null);
var package = new Package { Version = "2.0.0" };
var packageService = new Mock<IPackageService>(MockBehavior.Strict);
packageService.Setup(s => s.FindPackageByIdAndVersion("NuGet.CommandLine", null, false))
.Returns(package)
.Verifiable();
var packageFileSvc = new Mock<IPackageFileService>(MockBehavior.Strict);
packageFileSvc.Setup(s => s.DownloadPackageFile(package))
.Returns(CreateCommandLinePackage)
.Verifiable();
// Act
var downloaderSvc = GetDownloaderService(packageService, packageFileSvc, fileSystem);
var result = downloaderSvc.CreateNuGetExeDownloadActionnResult();
// Assert
packageFileSvc.Verify();
packageService.Verify();
AssertActionResult(result);
}
示例7: EditPackageDialog
public EditPackageDialog(Package package, bool bCreateNew)
: base()
{
InitializeComponent();
InitializeDialogPanel(true/*bModal*/, x_Name);
base.Closed += OnDialogClosed;
m_Title = x_Title;
m_ParentSearch = null;
m_DataGrid = x_DataGrid;
m_ListControl = x_ListControl;
m_Prev = x_Prev;
m_Next = x_Next;
m_RootPackageOrig = package;
m_RootPackage = m_RootPackageOrig.DeepClone();
m_bCreateNew = bCreateNew;
if (m_bCreateNew)
{
ProfileDate startProfileDate = ProfileCode.StartOfPlan.ToProfileDate();// or App.Model.ProfileHolder.Profile.StartProfileDate, or DateTime.Now.ToJulian()
ProfileDate endProfileDate = ProfileCode.EndOfPlan.ToProfileDate();// or App.Model.ProfileHolder.Profile.EndProfileDate;
m_RootPackage.SetDates(startProfileDate, endProfileDate);
m_RootPackage.MustHaveATransaction();
}
m_TitleFormat = (m_bCreateNew ? "Add" : "Edit") + " the '{0}' spending source";
}
示例8: Transform
public void Transform(Engine engine, Package package)
{
if (package.GetByName(Package.PageName) == null) return;
comm.Page page = (comm.Page)engine.GetObject(package.GetByName(Package.PageName));
Dictionary<string, List<ComponentPresentation>> lists = new Dictionary<string, List<ComponentPresentation>>();
string matchTokens = package.GetValue("ComponentTemplateTitleMatchTokens");
if (!String.IsNullOrEmpty(matchTokens))
{
foreach (string token in matchTokens.Split(','))
{
_matchTokens.Add(token.Trim());
}
}
foreach (comm.ComponentPresentation cp in page.ComponentPresentations)
{
string ct = GetPresentationType(cp.ComponentTemplate.Title);
if (!lists.ContainsKey(ct))
lists.Add(ct, new List<ComponentPresentation>());
lists[ct].Add(new ComponentPresentation(cp.Component.Id, cp.ComponentTemplate.Id));
}
foreach (string token in lists.Keys)
{
Item item = package.CreateStringItem(ContentType.ComponentArray, ComponentPresentationList.ToXml(lists[token]));
package.PushItem(token + "Components", item);
}
}
示例9: Process
protected override bool Process(Package package)
{
var account = package.Account;
if (account.IncomingProcessing != true ||
account.CreateActivity != true)
{
return false;
}
var message = package.Message;
if (message.IsIncome != true) return false;
if (message.RefNoteID != null) return false;
PXSelect<Contact,
Where<Contact.eMail, Equal<Required<Contact.eMail>>>>.
Clear(package.Graph);
var contact = (Contact)PXSelect<Contact,
Where<Contact.eMail, Equal<Required<Contact.eMail>>>>.
SelectWindowed(package.Graph, 0, 1, package.Address);
if (contact != null && contact.ContactID != null)
{
PXSelect<BAccount,
Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.
Clear(package.Graph);
var accountNoteId = contact.BAccountID.
With(_ => (BAccount)PXSelect<BAccount,
Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.
Select(package.Graph, _.Value)).
With(_ => _.NoteID);
message.RefNoteID = contact.NoteID;
message.ParentRefNoteID = accountNoteId;
return true;
}
return false;
}
示例10: SendPackage
public void SendPackage(Package.Package package)
{
using (var client = CreateClient())
{
var task = client.PostAsJsonAsync(client.BaseAddress, package).Result;
}
}
示例11: CreateNuGetExeDownloadExtractsFileIfItDoesNotExist
public void CreateNuGetExeDownloadExtractsFileIfItDoesNotExist()
{
// Arrange
var fileStorage = new Mock<IFileStorageService>(MockBehavior.Strict);
fileStorage.Setup(s => s.FileExists("downloads", "nuget.exe")).Returns(false);
fileStorage.Setup(s => s.SaveFile("downloads", "nuget.exe", It.IsAny<Stream>()))
.Verifiable();
fileStorage.Setup(s => s.CreateDownloadFileActionResult("downloads", "nuget.exe"))
.Returns(Mock.Of<ActionResult>())
.Verifiable();
var package = new Package { Version = "2.0.0" };
var packageService = new Mock<IPackageService>(MockBehavior.Strict);
packageService.Setup(s => s.FindPackageByIdAndVersion("NuGet.CommandLine", null, false))
.Returns(package)
.Verifiable();
var packageFileSvc = new Mock<IPackageFileService>(MockBehavior.Strict);
packageFileSvc.Setup(s => s.DownloadPackageFile(package))
.Returns(CreateCommandLinePackage)
.Verifiable();
// Act
var downloaderSvc = GetDownloaderService(packageService, packageFileSvc, fileStorage);
downloaderSvc.CreateNuGetExeDownloadActionResult();
// Assert
packageFileSvc.Verify();
packageService.Verify();
}
示例12: Should_Generate_HTML_References_with_pre_and_post_text
public void Should_Generate_HTML_References_with_pre_and_post_text()
{
// Arrange
var compilers = new[] { new JQueryTemplateCompiler(), };
var referencer = new LABjsScriptReference();
var package = new Package(".", compilers, referencer);
var references = new[]
{
new SystemReference(new DirectoryInfo("C:/Root/"), new FileInfo("C:/Root/Scripts/depper1.js"), "depper1.js")
{
Type = Reference.TypeEnum.App
}
};
// Act
var result = package.GenerateReferences(references, new HelperOptions { GenerateHeaderAndFooter = true });
// Assert
result.ShouldBe(
@"<script>
$LAB
.script(""/hotglue.axd/Scripts/depper1.js-app"");
</script>
");
}
示例13: Read
public override object Read(object target, Package package, BinaryReader reader, long end)
{
var rootObject = (RootObject)target;
if (rootObject.Export != null && rootObject.Export.ObjectClassReference != null)
return AttributeDictionary.Load(package, reader);
return null;
}
示例14: TestWithParts
public void TestWithParts()
{
// Create a derivative asset with asset parts
var project = new Package();
var assets = new List<TestAssetWithParts>();
var assetItems = new List<AssetItem>();
assets.Add(new TestAssetWithParts()
{
Parts =
{
new AssetPart(Guid.NewGuid()),
new AssetPart(Guid.NewGuid())
}
});
assetItems.Add(new AssetItem("asset-0", assets[0]));
project.Assets.Add(assetItems[0]);
var childAsset = (TestAssetWithParts)assetItems[0].CreateChildAsset();
// Check that child asset has a base
Assert.NotNull(childAsset.Base);
// Check base asset
Assert.AreEqual(assets[0].Id, childAsset.Base.Id);
// Check that base is correctly setup for the part
Assert.AreEqual(assets[0].Parts[0].Id, childAsset.Parts[0].BaseId);
}
示例15: TestUpdateAssetUrl
public void TestUpdateAssetUrl()
{
var projectDir = new UFile(Path.Combine(Environment.CurrentDirectory, "testxk"));
// Create a project with an asset reference a raw file
var project = new Package { FullPath = projectDir };
var assetItem = new AssetItem("test", new AssetObjectTest() { Reference = new AssetReference<AssetObjectTest>(Guid.Empty, "good/location")});
project.Assets.Add(assetItem);
var goodAsset = new AssetObjectTest();
project.Assets.Add(new AssetItem("good/location", goodAsset));
// Add the project to the session to make sure analysis will run correctly
var session = new PackageSession(project);
// Create a session with this project
var analysis = new PackageAnalysis(project,
new PackageAnalysisParameters()
{
IsProcessingAssetReferences = true,
ConvertUPathTo = UPathType.Absolute,
IsProcessingUPaths = true
});
var result = analysis.Run();
Assert.IsFalse(result.HasErrors);
Assert.AreEqual(1, result.Messages.Count);
Assert.IsTrue(result.Messages[0].ToString().Contains("changed"));
var asset = (AssetObjectTest)assetItem.Asset;
Assert.AreEqual(goodAsset.Id, asset.Reference.Id);
Assert.AreEqual("good/location", asset.Reference.Location);
}