本文整理汇总了C#中SiliconStudio.Assets.Package.FindDependencies方法的典型用法代码示例。如果您正苦于以下问题:C# Package.FindDependencies方法的具体用法?C# Package.FindDependencies怎么用?C# Package.FindDependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.Assets.Package
的用法示例。
在下文中一共展示了Package.FindDependencies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveProperties
/// <summary>
/// Saves a .props file for the specified package, containing the paradox version (only Major.Minor)
/// used to compile the package.
/// </summary>
/// <param name="package">The package.</param>
public static void SaveProperties(Package package)
{
// Props file is in the same folder as the pdxpkg file, just with a ".props" extension.
var packagePath = package.FullPath;
var propsFilePath = UPath.Combine(packagePath.GetParent(), (UFile)(packagePath.GetFileName() + ".props")) ;
var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection();
var project = new Microsoft.Build.Evaluation.Project(projectCollection);
var commonPropertyGroup = project.Xml.AddPropertyGroup();
var dependencies = package.FindDependencies(false, false, true);
// Add Paradox version
var pdxVersion = dependencies.FirstOrDefault(d => d.Meta.Name == "Paradox");
if (pdxVersion != null)
{
var versionText = pdxVersion.Meta.Version.Version.Major + "." + pdxVersion.Meta.Version.Version.Minor;
commonPropertyGroup.AddProperty("SiliconStudioPackageParadoxVersion", versionText);
}
if (File.Exists(propsFilePath))
{
File.Delete(propsFilePath);
}
project.Save(propsFilePath);
}
示例2: TryLoadAssets
private static bool TryLoadAssets(PackageSession session, ILogger log, Package package, PackageLoadParameters loadParameters)
{
// Already loaded
if (package.State >= PackageState.AssetsReady)
return true;
// Dependencies could not properly be loaded
if (package.State < PackageState.DependenciesReady)
return false;
// A package upgrade has previously been tried and denied, so let's keep the package in this state
if (package.State == PackageState.UpgradeFailed)
return false;
try
{
// First, check that dependencies have their assets loaded
bool dependencyError = false;
foreach (var dependency in package.FindDependencies(false, false))
{
if (!TryLoadAssets(session, log, dependency, loadParameters))
dependencyError = true;
}
if (dependencyError)
return false;
var pendingPackageUpgrades = new List<PendingPackageUpgrade>();
// Note: Default state is upgrade failed (for early exit on error/exceptions)
// We will update to success as soon as loading is finished.
package.State = PackageState.UpgradeFailed;
// Process store dependencies for upgraders
foreach (var packageDependency in package.Meta.Dependencies)
{
var dependencyPackage = session.Packages.Find(packageDependency);
if (dependencyPackage == null)
{
continue;
}
// Check for upgraders
var packageUpgrader = session.CheckPackageUpgrade(log, package, packageDependency, dependencyPackage);
if (packageUpgrader != null)
{
pendingPackageUpgrades.Add(new PendingPackageUpgrade(packageUpgrader, packageDependency, dependencyPackage));
}
}
// Prepare asset loading
var newLoadParameters = loadParameters.Clone();
newLoadParameters.AssemblyContainer = session.assemblyContainer;
// Default package version override
newLoadParameters.ExtraCompileProperties = new Dictionary<string, string>();
var defaultPackageOverride = NugetStore.GetPackageVersionVariable(PackageStore.Instance.DefaultPackageName) + "Override";
var defaultPackageVersion = PackageStore.Instance.DefaultPackageVersion.Version;
newLoadParameters.ExtraCompileProperties.Add(defaultPackageOverride, new Version(defaultPackageVersion.Major, defaultPackageVersion.Minor).ToString());
if (loadParameters.ExtraCompileProperties != null)
{
foreach (var property in loadParameters.ExtraCompileProperties)
{
newLoadParameters.ExtraCompileProperties[property.Key] = property.Value;
}
}
if (pendingPackageUpgrades.Count > 0)
{
var upgradeAllowed = true;
// Need upgrades, let's ask user confirmation
if (loadParameters.PackageUpgradeRequested != null)
{
upgradeAllowed = loadParameters.PackageUpgradeRequested(package, pendingPackageUpgrades);
}
if (!upgradeAllowed)
{
log.Error("Necessary package migration for [{0}] has not been allowed", package.Meta.Name);
return false;
}
// Perform pre assembly load upgrade
foreach (var pendingPackageUpgrade in pendingPackageUpgrades)
{
var packageUpgrader = pendingPackageUpgrade.PackageUpgrader;
var dependencyPackage = pendingPackageUpgrade.DependencyPackage;
if (!packageUpgrader.UpgradeBeforeAssembliesLoaded(session, log, package, pendingPackageUpgrade.Dependency, dependencyPackage))
{
log.Error("Error while upgrading package [{0}] for [{1}] from version [{2}] to [{3}]", package.Meta.Name, dependencyPackage.Meta.Name, pendingPackageUpgrade.Dependency.Version, dependencyPackage.Meta.Version);
return false;
}
}
}
// Load assemblies. Set the package filename to the path on disk, in case of renaming.
// TODO: Could referenced projects be associated to other packages than this one?
newLoadParameters.ExtraCompileProperties.Add("SiliconStudioCurrentPackagePath", package.FullPath);
package.LoadAssemblies(log, newLoadParameters);
//.........这里部分代码省略.........