本文整理汇总了C#中SiliconStudio.Assets.Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于SiliconStudio.Assets命名空间,在下文中一共展示了Package类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Upgrade
public override bool Upgrade(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, IList<PackageLoadingAssetFile> assetFiles)
{
// Paradox 1.1 projects didn't have their dependency properly updated (they might have been marked as 1.0).
// We know they are 1.1 only because there is a .props file.
// This check shouldn't be necessary from 1.2.
var packagePath = dependentPackage.FullPath;
var propsFilePath = UPath.Combine(packagePath.GetParent(), (UFile)(packagePath.GetFileName() + ".props"));
if (!File.Exists(propsFilePath) && dependency.Version.MinVersion < new PackageVersion("1.1.0-beta"))
{
log.Error("Can't upgrade old projects from {0} 1.0 to 1.1", dependency.Name);
return false;
}
// Nothing to do for now, most of the work is already done by individual asset upgraders
// We can later add logic here for package-wide upgrades (i.e. GameSettingsAsset)
if (dependency.Version.MinVersion < new PackageVersion("1.2.0-beta"))
{
// UIImageGroups and SpriteGroups asset have been merged into a single SpriteSheet => rename the assets and modify the tag
var uiImageGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxuiimage");
var spitesGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxsprite");
RenameAndChangeTag(assetFiles, uiImageGroups, "!UIImageGroup");
RenameAndChangeTag(assetFiles, spitesGroups, "!SpriteGroup");
}
return true;
}
开发者ID:hck509,项目名称:paradox,代码行数:26,代码来源:ParadoxPackageUpgrader.cs
示例2: EffectCompileCommand
public EffectCompileCommand(AssetCompilerContext context, UDirectory baseUrl, string effectName, CompilerParameters compilerParameters, Package package)
{
this.context = context;
this.baseUrl = baseUrl;
this.effectName = effectName;
this.compilerParameters = compilerParameters;
this.package = package;
}
开发者ID:releed,项目名称:paradox,代码行数:8,代码来源:EffectCompileCommand.cs
示例3: AssetMigrationContext
/// <summary>
/// Initializes a new instance of <see cref="AssetMigrationContext"/>.
/// </summary>
/// <param name="package"></param>
/// <param name="assetReference"></param>
/// <param name="assetFullPath"></param>
/// <param name="log"></param>
public AssetMigrationContext(Package package, IReference assetReference, string assetFullPath, ILogger log)
{
if (log == null) throw new ArgumentNullException(nameof(log));
Package = package;
AssetReference = assetReference;
AssetFullPath = assetFullPath;
Log = new AssetLogger(package, assetReference, assetFullPath, log);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:15,代码来源:AssetMigrationContext.cs
示例4: PackageLoadingAssetFile
/// <summary>
/// Initializes a new instance of the <see cref="PackageLoadingAssetFile" /> class.
/// </summary>
/// <param name="package">The package this asset will be part of.</param>
/// <param name="filePath">The relative file path (from default asset folder).</param>
/// <param name="sourceFolder">The source folder (optional, can be null).</param>
/// <exception cref="System.ArgumentException">filePath must be relative</exception>
public PackageLoadingAssetFile(Package package, UFile filePath, UDirectory sourceFolder)
{
if (filePath.IsAbsolute)
throw new ArgumentException("filePath must be relative", filePath);
SourceFolder = UPath.Combine(package.RootDirectory, sourceFolder ?? package.GetDefaultAssetFolder());
FilePath = UPath.Combine(SourceFolder, filePath);
}
开发者ID:robterrell,项目名称:paradox,代码行数:15,代码来源:PackageLoadingAssetFile.cs
示例5: AssetLogger
public AssetLogger(Package package, IReference assetReference, string assetFullPath, ILogger loggerToForward)
{
this.package = package;
this.assetReference = assetReference;
this.assetFullPath = assetFullPath;
this.loggerToForward = loggerToForward;
ActivateLog(LogMessageType.Debug);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:AssetLogger.cs
示例6: PackageStore
/// <summary>
/// Initializes a new instance of the <see cref="PackageStore"/> class.
/// </summary>
/// <exception cref="System.InvalidOperationException">Unable to find a valid Xenko installation path</exception>
private PackageStore(string installationPath = null, string defaultPackageName = "Xenko", string defaultPackageVersion = XenkoVersion.CurrentAsText)
{
// TODO: these are currently hardcoded to Xenko
DefaultPackageName = defaultPackageName;
DefaultPackageVersion = new PackageVersion(defaultPackageVersion);
defaultPackageDirectory = DirectoryHelper.GetPackageDirectory(defaultPackageName);
// 1. Try to use the specified installation path
if (installationPath != null)
{
if (!DirectoryHelper.IsInstallationDirectory(installationPath))
{
throw new ArgumentException("Invalid Xenko installation path [{0}]".ToFormat(installationPath), "installationPath");
}
globalInstallationPath = installationPath;
}
// 2. Try to resolve an installation path from the path of this assembly
// We need to be able to use the package manager from an official Xenko install as well as from a developer folder
if (globalInstallationPath == null)
{
globalInstallationPath = DirectoryHelper.GetInstallationDirectory(DefaultPackageName);
}
// If there is no root, this is an error
if (globalInstallationPath == null)
{
throw new InvalidOperationException("Unable to find a valid Xenko installation or dev path");
}
// Preload default package
var logger = new LoggerResult();
var defaultPackageFile = DirectoryHelper.GetPackageFile(defaultPackageDirectory, DefaultPackageName);
defaultPackage = Package.Load(logger, defaultPackageFile, GetDefaultPackageLoadParameters());
if (defaultPackage == null)
{
throw new InvalidOperationException("Error while loading default package from [{0}]: {1}".ToFormat(defaultPackageFile, logger.ToText()));
}
defaultPackage.IsSystem = true;
// A flag variable just to know if it is a bare bone development directory
isDev = defaultPackageDirectory != null && DirectoryHelper.IsRootDevDirectory(defaultPackageDirectory);
// Check if we are in a root directory with store/packages facilities
if (NugetStore.IsStoreDirectory(globalInstallationPath))
{
packagesDirectory = UPath.Combine(globalInstallationPath, (UDirectory)NugetStore.DefaultGamePackagesDirectory);
store = new NugetStore(globalInstallationPath);
}
else
{
// We should exit from here if NuGet is not configured.
MessageBox.Show($"Unexpected installation. Cannot find a proper NuGet configuration for [{defaultPackageName}] in [{globalInstallationPath}]", "Installation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
开发者ID:cg123,项目名称:xenko,代码行数:61,代码来源:PackageStore.cs
示例7: CreateCompilePackageFromAsset
/// <summary>
/// Create a <see cref="Package"/> that can be used to compile an <see cref="AssetItem"/> by analyzing and resolving its dependencies.
/// </summary>
/// <returns>The package packageSession that can be used to compile the asset item.</returns>
public static Package CreateCompilePackageFromAsset(this PackageSession session, AssetItem originalAssetItem)
{
// create the compile root package and package session
var assetPackageCloned = new Package();
var compilePackageSession = new PackageSession(assetPackageCloned);
AddAssetToCompilePackage(session, originalAssetItem, assetPackageCloned);
return assetPackageCloned;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:PackageSession.Extensions.cs
示例8: FillPackageDependencies
private static void FillPackageDependencies(Package rootPackage, bool isRecursive, ICollection<Package> packagesFound, bool storeOnly = false)
{
var session = rootPackage.Session;
if (session == null && (rootPackage.Meta.Dependencies.Count > 0 || rootPackage.LocalDependencies.Count > 0))
{
throw new InvalidOperationException("Cannot query package with dependencies when it is not attached to a session");
}
// 1. Load store package
foreach (var packageDependency in rootPackage.Meta.Dependencies)
{
var package = session.Packages.Find(packageDependency);
if (package == null)
{
continue;
}
if (!packagesFound.Contains(package))
{
packagesFound.Add(package);
if (isRecursive)
{
FillPackageDependencies(package, isRecursive, packagesFound, storeOnly);
}
}
}
if (storeOnly)
{
return;
}
// 2. Load local packages
foreach (var packageReference in rootPackage.LocalDependencies)
{
var package = session.Packages.Find(packageReference.Id);
if (package == null)
{
continue;
}
if (!packagesFound.Contains(package))
{
packagesFound.Add(package);
if (isRecursive)
{
FillPackageDependencies(package, isRecursive, packagesFound, storeOnly);
}
}
}
}
开发者ID:Powerino73,项目名称:paradox,代码行数:55,代码来源:PackageExtensions.cs
示例9: PackageSession
/// <summary>
/// Initializes a new instance of the <see cref="PackageSession"/> class.
/// </summary>
public PackageSession(Package package)
{
packages = new PackageCollection();
packagesCopy = new PackageCollection();
assemblyContainer = new AssemblyContainer();
packages.CollectionChanged += PackagesCollectionChanged;
if (package != null)
{
Packages.Add(package);
}
}
开发者ID:Powerino73,项目名称:paradox,代码行数:14,代码来源:PackageSession.cs
示例10: GetGraphicsPlatform
public static GraphicsPlatform GetGraphicsPlatform(this AssetCompilerContext context, Package package)
{
// If we have a command line override, use it first
string graphicsApi;
if (context.OptionProperties.TryGetValue("SiliconStudioXenkoGraphicsApi", out graphicsApi))
return (GraphicsPlatform)Enum.Parse(typeof(GraphicsPlatform), graphicsApi);
// Ohterwise, use game settings, or default as fallback
var settings = package.GetGameSettingsAsset();
return settings == null ? context.Platform.GetDefaultGraphicsPlatform() : RenderingSettings.GetGraphicsPlatform(context.Platform, settings.Get<RenderingSettings>(context.Profile).PreferredGraphicsPlatform);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:11,代码来源:AssetCompilerContextExtensions.cs
示例11: PackageSession
/// <summary>
/// Initializes a new instance of the <see cref="PackageSession"/> class.
/// </summary>
public PackageSession(Package package)
{
constraintProvider.AddConstraint(PackageStore.Instance.DefaultPackageName, new VersionSpec(PackageStore.Instance.DefaultPackageVersion.ToSemanticVersion()));
packages = new PackageCollection();
packagesCopy = new PackageCollection();
assemblyContainer = new AssemblyContainer();
packages.CollectionChanged += PackagesCollectionChanged;
if (package != null)
{
Packages.Add(package);
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:16,代码来源:PackageSession.cs
示例12: UpgradeAfterAssetsLoaded
/// <inheritdoc/>
public override bool UpgradeAfterAssetsLoaded(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, PackageVersionRange dependencyVersionBeforeUpdate)
{
if (dependencyVersionBeforeUpdate.MinVersion < new PackageVersion("1.3.0-alpha02"))
{
// Add everything as root assets (since we don't know what the project was doing in the code before)
foreach (var assetItem in dependentPackage.Assets)
{
if (!AssetRegistry.IsAssetTypeAlwaysMarkAsRoot(assetItem.Asset.GetType()))
dependentPackage.RootAssets.Add(new AssetReference<Asset>(assetItem.Id, assetItem.Location));
}
}
return true;
}
开发者ID:RxGamesLtd,项目名称:paradox,代码行数:15,代码来源:ParadoxPackageUpgrader.cs
示例13: TrackPackage
/// <summary>
/// This method is called when a package needs to be tracked
/// </summary>
/// <param name="package">The package to track.</param>
private void TrackPackage(Package package)
{
if (packages.Contains(package))
return;
packages.Add(package);
foreach (var asset in package.Assets)
{
TrackAsset(asset);
}
package.Assets.CollectionChanged += Assets_CollectionChanged;
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:18,代码来源:AssetTracker.cs
示例14: AddLoadingFromSession
public static void AddLoadingFromSession(this ShaderGeneratorContextBase context, Package package)
{
var previousGetAssetFriendlyName = context.GetAssetFriendlyName;
var previousFindAsset = context.FindAsset;
// Setup the GetAssetFriendlyName callback
context.GetAssetFriendlyName = runtimeAsset =>
{
string assetFriendlyName = null;
if (previousGetAssetFriendlyName != null)
{
assetFriendlyName = previousGetAssetFriendlyName(runtimeAsset);
}
if (string.IsNullOrEmpty(assetFriendlyName))
{
var referenceAsset = AttachedReferenceManager.GetAttachedReference(runtimeAsset);
assetFriendlyName = string.Format("{0}:{1}", referenceAsset.Id, referenceAsset.Url);
}
return assetFriendlyName;
};
// Setup the FindAsset callback
context.FindAsset = runtimeAsset =>
{
object newAsset = null;
if (previousFindAsset != null)
{
newAsset = previousFindAsset(runtimeAsset);
}
if (newAsset != null)
{
return newAsset;
}
var reference = AttachedReferenceManager.GetAttachedReference(runtimeAsset);
var assetItem = package.Session.FindAsset(reference.Id) ?? package.Session.FindAsset(reference.Url);
if (assetItem == null)
{
return null;
}
return assetItem.Asset;
};
}
开发者ID:Julyuary,项目名称:paradox,代码行数:50,代码来源:ShaderGeneratorContextExtensions.cs
示例15: UnTrackPackage
/// <summary>
/// This method is called when a package needs to be un-tracked
/// </summary>
/// <param name="package">The package to un-track.</param>
private void UnTrackPackage(Package package)
{
if (!packages.Contains(package))
return;
package.Assets.CollectionChanged -= Assets_CollectionChanged;
foreach (var asset in package.Assets)
{
UnTrackAsset(asset);
}
packages.Remove(package);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:18,代码来源:AssetTracker.cs
示例16: NewPackage
/// <summary>
/// Creates a new Paradox package with the specified name
/// </summary>
/// <param name="name">Name of the package</param>
/// <returns>A new package instance</returns>
public static Package NewPackage(string name)
{
var package = new Package
{
Meta =
{
Name = name,
Version = new PackageVersion("1.0.0.0")
},
};
// Add dependency to latest Paradox package
package.Meta.Dependencies.Add(ParadoxConfig.GetLatestPackageDependency());
// Setup the assets folder by default
package.Profiles.Add(PackageProfile.NewShared());
return package;
}
开发者ID:RainsSoft,项目名称:paradox,代码行数:24,代码来源:PackageUnitTestGenerator.cs
示例17: AddLoadingFromSession
public static void AddLoadingFromSession(this ShaderGeneratorContextBase shaderGeneratorContext, Package package)
{
shaderGeneratorContext.FindAsset = material =>
{
if (material.Descriptor != null)
{
return material.Descriptor;
}
var reference = AttachedReferenceManager.GetAttachedReference(material);
var assetItem = package.Session.FindAsset(reference.Id) ?? package.Session.FindAsset(reference.Url);
if (assetItem == null)
{
return null;
}
return (IMaterialDescriptor)assetItem.Asset;
};
}
开发者ID:Powerino73,项目名称:paradox,代码行数:20,代码来源:ShaderGeneratorContextExtensions.cs
示例18: CreateCompilePackageFromAsset
/// <summary>
/// Create a <see cref="PackageSession"/> that can be used to compile an <see cref="AssetItem"/> by analyzing and resolving its dependencies.
/// </summary>
/// <returns>The package packageSession that can be used to compile the asset item.</returns>
public static PackageSession CreateCompilePackageFromAsset(this PackageSession session, AssetItem originalAssetItem)
{
if (originalAssetItem == null) throw new ArgumentNullException("originalAssetItem");
// Find the asset from the session
var assetItem = originalAssetItem.Package.FindAsset(originalAssetItem.Id);
if (assetItem == null)
{
throw new ArgumentException("Cannot find the specified AssetItem instance in the session");
}
// Calculate dependencies
var dependencies = session.DependencyManager.ComputeDependencies(assetItem, AssetDependencySearchOptions.Out | AssetDependencySearchOptions.Recursive);
var assetItemRootCloned = dependencies.Item.Clone();
// Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages
assetItemRootCloned.SourceFolder = assetItem.FullPath.GetParent();
// create the compile root package and package session
var assetPackageCloned = new Package();
var compilePackageSession = new PackageSession(assetPackageCloned);
assetPackageCloned.Assets.Add(assetItemRootCloned);
// For each asset item dependency, clone it in the new package
foreach (var assetLink in dependencies.LinksOut)
{
// Only add assets not already added (in case of circular dependencies)
if (assetPackageCloned.Assets.Find(assetLink.Item.Id) == null)
{
// create a copy of the asset item and add it to the appropriate compile package
var itemCloned = assetLink.Item.Clone();
// Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages
itemCloned.SourceFolder = assetLink.Item.FullPath.GetParent();
assetPackageCloned.Assets.Add(itemCloned);
}
}
return compilePackageSession;
}
开发者ID:releed,项目名称:paradox,代码行数:45,代码来源:PackageSession.Extensions.cs
示例19: AddAssetToCompilePackage
public static void AddAssetToCompilePackage(this PackageSession session, AssetItem originalAssetItem, Package assetPackageCloned)
{
if (originalAssetItem == null) throw new ArgumentNullException("originalAssetItem");
// Find the asset from the session
var assetItem = originalAssetItem.Package.FindAsset(originalAssetItem.Id);
if (assetItem == null)
{
throw new ArgumentException("Cannot find the specified AssetItem instance in the session");
}
// Calculate dependencies
// Search only for references
var dependencies = session.DependencyManager.ComputeDependencies(assetItem.Id, AssetDependencySearchOptions.Out | AssetDependencySearchOptions.Recursive, ContentLinkType.Reference);
if (dependencies == null)
throw new InvalidOperationException("The asset doesn't exist in the dependency manager anymore");
var assetItemRootCloned = dependencies.Item.Clone();
// Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages
assetItemRootCloned.SourceFolder = assetItem.FullPath.GetParent();
if (assetPackageCloned.Assets.Find(assetItemRootCloned.Id) == null)
assetPackageCloned.Assets.Add(assetItemRootCloned);
// For each asset item dependency, clone it in the new package
foreach (var assetLink in dependencies.LinksOut)
{
// Only add assets not already added (in case of circular dependencies)
if (assetPackageCloned.Assets.Find(assetLink.Item.Id) == null)
{
// create a copy of the asset item and add it to the appropriate compile package
var itemCloned = assetLink.Item.Clone();
// Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages
itemCloned.SourceFolder = assetLink.Item.FullPath.GetParent();
assetPackageCloned.Assets.Add(itemCloned);
}
}
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:40,代码来源:PackageSession.Extensions.cs
示例20: Build
public static void Build(Package package, string outputDirectory = null)
{
if (package == null) throw new ArgumentNullException("package");
var meta = new NuGet.ManifestMetadata();
package.Meta.ToNugetManifest(meta);
var builder = new NuGet.PackageBuilder();
builder.Populate(meta);
// TODO this is not working
var files = new List<NuGet.ManifestFile>()
{
NewFile(@"Bin\**\*.exe", "Bin"),
NewFile(@"Bin\**\*.vsix", "Bin"),
NewFile(@"Bin\**\*.so", "Bin"),
NewFile(@"Bin\**\*.a", "Bin"),
NewFile(@"Bin\**\*.md", "Bin"),
NewFile(@"Bin\**\*.html", "Bin"),
NewFile(@"Bin\**\*.config", "Bin"),
NewFile(@"Bin\**\*.dll", "Bin"),
NewFile(@"Bin\**\*.xml", "Bin"),
NewFile(@"Bin\**\*.winmd", "Bin"),
NewFile(@"Targets\*.targets", "Targets"),
};
// Handle Assets
var rootDir = package.RootDirectory;
var newPackage = new Package { Meta = package.Meta };
foreach (var profile in package.Profiles)
{
var target = "Assets/" + profile.Name;
foreach (var assetFolder in profile.AssetFolders)
{
// TODO: handle exclude in asset folders
//files.Add(NewFile(source, target, @"**\*.cs;**\*.hlsl;**\*.csproj;**\*.csproj.user;**\obj\**"));
files.Add(NewFile(assetFolder.Path.MakeRelative(rootDir) + "/**/*.pdxsl", target));
files.Add(NewFile(assetFolder.Path.MakeRelative(rootDir) + "/**/*.pdxfx", target));
}
var targetProfile = new PackageProfile(profile.Name);
targetProfile.AssetFolders.Add(new AssetFolder(target));
newPackage.Profiles.Add(targetProfile);
}
// Handle templates
var targetFolder = new TemplateFolder("Templates");
foreach (var templateFolder in package.TemplateFolders)
{
var source = templateFolder.Path.MakeRelative(rootDir) + "/**";
UDirectory target = targetFolder.Path;
if (templateFolder.Group != null)
{
target = UPath.Combine(target, templateFolder.Group);
}
var excludeFiles = templateFolder.Exclude;
files.Add(NewFile(source, target, excludeFiles));
// Add template files
foreach (var templateFile in templateFolder.Files)
{
var newTemplateFile = templateFile.MakeRelative(templateFolder.Path);
if (templateFolder.Group != null)
{
newTemplateFile = UPath.Combine(templateFolder.Group, newTemplateFile);
}
newTemplateFile = UPath.Combine(targetFolder.Path, newTemplateFile);
targetFolder.Files.Add(newTemplateFile);
}
}
// Create temp package for archive
newPackage.TemplateFolders.Add(targetFolder);
var newPackageFileName = "temp" + Guid.NewGuid() + ".pdxpkg";
newPackage.FullPath = package.RootDirectory + "/" + newPackageFileName;
var result = newPackage.Save();
if (result.HasErrors)
{
throw new InvalidOperationException(result.ToText());
// TODO throw error
}
files.Add(NewFile(newPackageFileName, package.Meta.Name + Package.PackageFileExtension));
// Add files
builder.PopulateFiles(package.RootDirectory, files);
outputDirectory = outputDirectory ?? Environment.CurrentDirectory;
// Save the nupkg
var outputPath = GetOutputPath(builder, outputDirectory);
bool isExistingPackage = File.Exists(outputPath);
if (isExistingPackage)
{
File.Delete(outputPath);
}
//.........这里部分代码省略.........
开发者ID:Powerino73,项目名称:paradox,代码行数:101,代码来源:PackageArchive.cs
注:本文中的SiliconStudio.Assets.Package类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论