本文整理汇总了C#中IPackage.ExtensionFolder方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.ExtensionFolder方法的具体用法?C# IPackage.ExtensionFolder怎么用?C# IPackage.ExtensionFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackage
的用法示例。
在下文中一共展示了IPackage.ExtensionFolder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallPackage
protected PackageInfo InstallPackage(IPackage package, IPackageRepository packageRepository, string location, string applicationPath) {
bool previousInstalled;
// 1. See if extension was previous installed and backup its folder if so
try {
previousInstalled = BackupExtensionFolder(package.ExtensionFolder(), package.ExtensionId());
}
catch (Exception exception) {
throw new OrchardException(T("Unable to backup existing local package directory."), exception);
}
if (previousInstalled) {
// 2. If extension is installed, need to un-install first
try {
UninstallExtensionIfNeeded(package);
}
catch (Exception exception) {
throw new OrchardException(T("Unable to un-install local package before updating."), exception);
}
}
var packageInfo = ExecuteInstall(package, packageRepository, location, applicationPath);
// check the new package is compatible with current Orchard version
var descriptor = package.GetExtensionDescriptor(packageInfo.ExtensionType);
if(descriptor != null) {
if(new FlatPositionComparer().Compare(descriptor.OrchardVersion, typeof(ContentItem).Assembly.GetName().Version.ToString()) >= 0) {
if (previousInstalled) {
// restore the previous version
RestoreExtensionFolder(package.ExtensionFolder(), package.ExtensionId());
}
else {
// just uninstall the new package
Uninstall(package.Id, _virtualPathProvider.MapPath("~\\"));
}
Logger.Error(String.Format("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion));
throw new OrchardException(T("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion));
}
}
return packageInfo;
}
示例2: InstallPackage
protected PackageInfo InstallPackage(IPackage package, IPackageRepository packageRepository, string location, string applicationPath) {
bool previousInstalled;
// 1. See if extension was previous installed and backup its folder if so
try {
previousInstalled = BackupExtensionFolder(package.ExtensionFolder(), package.ExtensionId());
}
catch (Exception exception) {
throw new OrchardException(T("Unable to backup existing local package directory."), exception);
}
if (previousInstalled) {
// 2. If extension is installed, need to un-install first
try {
UninstallExtensionIfNeeded(package);
}
catch (Exception exception) {
throw new OrchardException(T("Unable to un-install local package before updating."), exception);
}
}
return ExecuteInstall(package, packageRepository, location, applicationPath);
}
示例3: InstallPackage
/// <summary>
/// Tries to install the package
/// </summary>
/// <param name="package">The package to install</param>
/// <param name="packageRepository">The repository</param>
/// <param name="location">The virtual location of the package file, usually <c>~/App_Data</c></param>
/// <param name="applicationPath">The virtual app root path, usually <c>~/</c></param>
/// <returns>An instance of <see cref="PackageInfo"/> type</returns>
protected PackageInfo InstallPackage(IPackage package, IPackageRepository packageRepository, string location, string applicationPath)
{
bool previousInstalled;
// 1. See if extension was previous installed and backup its folder if so
try
{
previousInstalled = BackupExtensionFolder(package.ExtensionFolder(), package.ExtensionId());
}
catch (Exception exception)
{
throw new SmartException(T("Admin.Packaging.BackupError"), exception);
}
if (previousInstalled)
{
// 2. If extension is installed, need to un-install first
try
{
UninstallExtensionIfNeeded(package);
}
catch (Exception exception)
{
throw new SmartException(T("Admin.Packaging.UninstallError"), exception);
}
}
var packageInfo = ExecuteInstall(package, packageRepository, location, applicationPath);
// check if the new package is compatible with current SmartStore version
var descriptor = package.GetExtensionDescriptor(packageInfo.Type);
if (descriptor != null)
{
if (!PluginManager.IsAssumedCompatible(descriptor.MinAppVersion))
{
if (previousInstalled)
{
// restore the previous version
RestoreExtensionFolder(package.ExtensionFolder(), package.ExtensionId());
}
else
{
// just uninstall the new package
Uninstall(package.Id, _virtualPathProvider.MapPath("~\\"));
}
var msg = T("Admin.Packaging.IsIncompatible", SmartStoreVersion.CurrentFullVersion);
_logger.Error(msg);
throw new SmartException(msg);
}
}
return packageInfo;
}