本文整理汇总了C#中SiliconStudio.Assets.Package.LoadAssembliesAndAssets方法的典型用法代码示例。如果您正苦于以下问题:C# Package.LoadAssembliesAndAssets方法的具体用法?C# Package.LoadAssembliesAndAssets怎么用?C# Package.LoadAssembliesAndAssets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.Assets.Package
的用法示例。
在下文中一共展示了Package.LoadAssembliesAndAssets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryLoadAssets
//.........这里部分代码省略.........
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));
}
}
// Load list of assets
var assetFiles = Package.ListAssetFiles(log, package, loadParameters.CancelToken);
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 upgrades
foreach (var pendingPackageUpgrade in pendingPackageUpgrades)
{
var packageUpgrader = pendingPackageUpgrade.PackageUpgrader;
var dependencyPackage = pendingPackageUpgrade.DependencyPackage;
if (!packageUpgrader.Upgrade(session, log, package, pendingPackageUpgrade.Dependency, dependencyPackage, assetFiles))
{
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;
}
// Update dependency to reflect new requirement
pendingPackageUpgrade.Dependency.Version = pendingPackageUpgrade.PackageUpgrader.Attribute.PackageUpdatedVersionRange;
}
// Mark package as dirty
package.IsDirty = true;
}
// Process the package for assets
var newLoadParameters = loadParameters.Clone();
newLoadParameters.AssetFiles = assetFiles;
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;
}
}
// Load assemblies and assets
package.LoadAssembliesAndAssets(log, newLoadParameters);
// Validate assets from package
package.ValidateAssets(newLoadParameters.GenerateNewAssetIds);
// Mark package as ready
package.State = PackageState.AssetsReady;
// Freeze the package after loading the assets
session.FreezePackage(package);
return true;
}
catch (Exception ex)
{
log.Error("Error while loading package [{0}]", ex, package);
return false;
}
}