当前位置: 首页>>代码示例>>C#>>正文


C# IPackage.ExtensionId方法代码示例

本文整理汇总了C#中IPackage.ExtensionId方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.ExtensionId方法的具体用法?C# IPackage.ExtensionId怎么用?C# IPackage.ExtensionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPackage的用法示例。


在下文中一共展示了IPackage.ExtensionId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
开发者ID:kerrjon,项目名称:MNFathers,代码行数:44,代码来源:PackageInstaller.cs

示例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);
        }
开发者ID:rupertwhitlock,项目名称:IncreasinglyAbsorbing,代码行数:23,代码来源:PackageInstaller.cs

示例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;
		}
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:64,代码来源:PackageInstaller.cs

示例4: UninstallExtensionIfNeeded

 private void UninstallExtensionIfNeeded(IPackage package) {
     // Nuget requires to un-install the currently installed packages if the new
     // package is the same version or an older version
     try {
         Uninstall(package.Id, _virtualPathProvider.MapPath("~\\"));
         _notifier.Information(T("Successfully un-installed local package {0}", package.ExtensionId()));
     }
     catch {}
 }
开发者ID:kerrjon,项目名称:MNFathers,代码行数:9,代码来源:PackageInstaller.cs


注:本文中的IPackage.ExtensionId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。