本文整理汇总了C#中Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于命名空间,在下文中一共展示了Package类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:abock,项目名称:rpm-repo-clone,代码行数:29,代码来源:Entry.cs
示例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);
}
开发者ID:aldion,项目名称:NuGetGallery,代码行数:34,代码来源:DisplayPackageViewModel.cs
示例3: SendPackage
public void SendPackage(Package package)
{
var dt = DateTime.Now;
_writer.Write(dt.ToString("mm:ss.fff") + " : ");
_writer.WriteLine(package.ToString());
_writer.Flush();
}
开发者ID:vchernokulsky,项目名称:Illuminate,代码行数:7,代码来源:FakePackageSender.cs
示例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...";
}
}
开发者ID:japj,项目名称:bidshelper,代码行数:26,代码来源:VariablesMove.cs
示例5: Parameterize
protected virtual void Parameterize(IEnumerable<EtlParameter> parameters, ref Package package)
{
foreach (var param in parameters)
{
package.Parameters[param.Name].Value = param.StringValue;
}
}
开发者ID:zyh329,项目名称:nbi,代码行数:7,代码来源:EtlDtsRunner.cs
示例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);
}
开发者ID:VishalRJoshi,项目名称:NuGetGallery,代码行数:28,代码来源:NuGetExeDownloaderServiceFacts.cs
示例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";
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例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);
}
}
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:28,代码来源:GroupComponentsByTemplate.cs
示例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;
}
开发者ID:PavelMPD,项目名称:SimpleProjects,代码行数:35,代码来源:ContactBAccountEmailProcessor.cs
示例10: SendPackage
public void SendPackage(Package.Package package)
{
using (var client = CreateClient())
{
var task = client.PostAsJsonAsync(client.BaseAddress, package).Result;
}
}
开发者ID:ChrisBellew,项目名称:JobSpawn,代码行数:7,代码来源:PackageClient.cs
示例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();
}
开发者ID:NuGetPrototypes,项目名称:NuGetGallery,代码行数:29,代码来源:NuGetExeDownloaderServiceFacts.cs
示例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>
");
}
开发者ID:nathanpalmer,项目名称:hotglue,代码行数:27,代码来源:GenerateReferenceTests.cs
示例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;
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:7,代码来源:Object.cs
示例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);
}
开发者ID:hsabaleuski,项目名称:paradox,代码行数:29,代码来源:TestAssetInheritance.cs
示例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);
}
开发者ID:cg123,项目名称:xenko,代码行数:31,代码来源:TestAssetReferenceAnalysis.cs
示例16: Transform
public void Transform(Engine engine, Package package)
{
TemplatingLogger log = TemplatingLogger.GetLogger(GetType());
if (package.GetByName(Package.ComponentName) == null)
{
log.Info("This template should only be used with Component Templates. Could not find component in package, exiting");
return;
}
var c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
var container = (Folder)c.OrganizationalItem;
var filter = new OrganizationalItemItemsFilter(engine.GetSession()) { ItemTypes = new[] { ItemType.Component } };
// Always faster to use GetListItems if we only need limited elements
foreach (XmlNode node in container.GetListItems(filter))
{
string componentId = node.Attributes["ID"].Value;
string componentTitle = node.Attributes["Title"].Value;
}
// If we need more info, use GetItems instead
foreach (Component component in container.GetItems(filter))
{
// If your filter is messed up, GetItems will return objects that may
// not be a Component, in which case the code will blow up with an
// InvalidCastException. Be careful with filter.ItemTypes[]
Schema componentSchema = component.Schema;
SchemaPurpose purpose = componentSchema.Purpose;
XmlElement content = component.Content;
}
}
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:30,代码来源:GetComponentsInSameFolder.cs
示例17: BuildPackageDirectory_RemapsCustomNodePaths
public void BuildPackageDirectory_RemapsCustomNodePaths()
{
var files = new[] { @"C:\file1.dyf", @"C:\file2.dyf" };
var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT");
var fs = new RecordedFileSystem((fn) => files.Contains(fn));
var pr = new Mock<IPathRemapper>();
var remappedPaths = new List<Tuple<string, string>>();
pr.Setup(x => x.SetPath(files[0], It.IsAny<string>()))
.Callback((string f, string s) => remappedPaths.Add(new Tuple<string, string>(f, s)));
pr.Setup(x => x.SetPath(files[1], It.IsAny<string>()))
.Callback((string f, string s) => remappedPaths.Add(new Tuple<string, string>(f, s)));
var db = new PackageDirectoryBuilder(fs, pr.Object);
var pkgsDir = @"C:\dynamopackages";
db.BuildDirectory(pkg, pkgsDir, files);
var dyfDir = Path.Combine(pkgsDir, pkg.Name, PackageDirectoryBuilder.CustomNodeDirectoryName);
Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[0] && x.Item2 == dyfDir));
Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[1] && x.Item2 == dyfDir));
}
开发者ID:JinWooShin,项目名称:Dynamo,代码行数:28,代码来源:PackageDirectoryBuilderTests.cs
示例18: Process
protected override bool Process(Package package)
{
var account = package.Account;
if (account.IncomingProcessing != true)
{
return false;
}
var message = package.Message;
if (message.IsIncome != true) return false;
if (message.RefNoteID == null) return false;
var graph = package.Graph;
PXSelect<CROpportunity,
Where<CROpportunity.noteID, Equal<Required<CROpportunity.noteID>>>>.
Clear(graph);
var opportunity = (CROpportunity)PXSelect<CROpportunity,
Where<CROpportunity.noteID, Equal<Required<CROpportunity.noteID>>>>.
Select(graph, message.RefNoteID);
if (opportunity == null || opportunity.OpportunityID == null) return false;
return true;
}
开发者ID:PavelMPD,项目名称:SimpleProjects,代码行数:27,代码来源:OpportunityEmailProcessor.cs
示例19: Transform
public void Transform(Engine engine, Package package)
{
if (package.GetByName(Package.PageName) == null) return;
Page page = (Page)engine.GetObject(package.GetByName(Package.PageName));
bool hasHeader = false;
bool hasFooter = false;
foreach (CP cp in page.ComponentPresentations)
{
if (cp.ComponentTemplate.Title.ToLower().Contains("header")) hasHeader = true;
if (cp.ComponentTemplate.Title.ToLower().Contains("footer")) hasFooter = true;
}
if (!hasHeader)
{
ComponentTemplate headerCt = (ComponentTemplate)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + HeaderComponentTemplateUrl);
Component header = (Component)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + HeaderComponentUrl);
package.PushItem("headerCP", package.CreateStringItem(ContentType.Html, string.Format("<tcdl:ComponentPresentation type=\"Dynamic\" componentURI=\"{0}\" templateURI=\"{1}\" />", header.Id, headerCt.Id)));
}
if (!hasFooter)
{
ComponentTemplate footerCt = (ComponentTemplate)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + FooterComponentTemplateUrl);
Component footer = (Component)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + FooterComponentUrl);
package.PushItem("footerCP", package.CreateStringItem(ContentType.Html, string.Format("<tcdl:ComponentPresentation type=\"Dynamic\" componentURI=\"{0}\" templateURI=\"{1}\" />", footer.Id, footerCt.Id)));
}
}
开发者ID:mhassan26,项目名称:SDL-Tridion-Template-Tools,代码行数:26,代码来源:AddHeaderAndFooterToPage.cs
示例20: Transform
public void Transform(Engine engine, Package package)
{
this.package = package;
this.engine = engine;
if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
{
if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
{
log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java");
return;
}
}
Item outputItem = package.GetByName("Output");
String inputValue = package.GetValue("Output");
if (inputValue == null || inputValue.Length == 0)
{
log.Warning("Could not find 'Output' in the package, nothing to transform");
return;
}
// Combine the 'to lower' and 'to java' functions, since there is no reason to have one without the other.
// Note: it is still possible (for backwards compatibility) to have a separate ToLower TBB in your templates.
// In that case, the first letter of each element will be converted into lower case twice, which doesn't do any harm.
string outputValue = LowerCaseConverter.Convert(inputValue);
outputValue = XmlToJavaConverter.Convert(outputValue);
// outputValue = XmlMinimizer.Convert(outputValue);
// replace the Output item in the package
package.Remove(outputItem);
outputItem.SetAsString(outputValue);
package.PushItem("Output", outputItem);
}
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:35,代码来源:ConvertXmlToJava.cs
注:本文中的Package类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论