本文整理汇总了C#中Kudu.Contracts.SiteExtensions.SiteExtensionInfo类的典型用法代码示例。如果您正苦于以下问题:C# SiteExtensionInfo类的具体用法?C# SiteExtensionInfo怎么用?C# SiteExtensionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SiteExtensionInfo类属于Kudu.Contracts.SiteExtensions命名空间,在下文中一共展示了SiteExtensionInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallExtension
public SiteExtensionInfo InstallExtension(string id, SiteExtensionInfo requestInfo)
{
if (requestInfo == null)
{
requestInfo = new SiteExtensionInfo();
}
SiteExtensionInfo extension;
try
{
extension = _manager.InstallExtension(id, requestInfo.Version, requestInfo.FeedUrl);
}
catch (WebException e)
{
// This can happen for example if a bad feed URL is passed
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Site extension download failure", e));
}
catch (Exception e)
{
// This can happen for example if the exception package is corrupted
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Site extension install exception. The package might be invalid.", e));
}
if (extension == null)
{
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Could not find " + id));
}
return extension;
}
示例2: InstallExtension
public SiteExtensionInfo InstallExtension(SiteExtensionInfo info)
{
SiteExtensionInfo extension = _manager.InstallExtension(info);
if (extension == null)
{
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, info.ToString()));
}
return extension;
}
示例3: InstallExtension
public async Task<HttpResponseMessage> InstallExtension(string id, SiteExtensionInfo requestInfo)
{
var startTime = DateTime.UtcNow;
if (requestInfo == null)
{
requestInfo = new SiteExtensionInfo();
}
SiteExtensionInfo result;
try
{
result = await _manager.InstallExtension(id, requestInfo.Version, requestInfo.FeedUrl);
}
catch (WebException e)
{
// This can happen for example if a bad feed URL is passed
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Site extension download failure", e));
}
catch (Exception e)
{
// This can happen for example if the exception package is corrupted
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Site extension install exception. The package might be invalid.", e));
}
if (result == null)
{
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Could not find " + id));
}
// TODO: xiaowu, when update to real csm async, should return "Accepted" instead of "OK"
var responseMessage = Request.CreateResponse(HttpStatusCode.OK, ArmUtils.AddEnvelopeOnArmRequest<SiteExtensionInfo>(result, Request));
if (result != null // result not null indicate instalation success, when move to async operation, will relying on provisionState instead
&& result.InstalledDateTime.HasValue
&& result.InstalledDateTime.Value > startTime
&& ArmUtils.IsArmRequest(Request))
{
// Populate this header if
// Request is from ARM
// Installation action is performed
responseMessage.Headers.Add("X-MS-SITE-OPERATION", Constants.SiteOperationRestart);
}
return responseMessage;
}
示例4: SiteExtensionInfo
public SiteExtensionInfo(SiteExtensionInfo info)
{
Id = info.Id;
Title = info.Title;
Type = info.Type;
Summary = info.Summary;
Description = info.Description;
Version = info.Version;
ExtensionUrl = info.ExtensionUrl;
ProjectUrl = info.ProjectUrl;
IconUrl = info.IconUrl;
LicenseUrl = info.LicenseUrl;
Authors = info.Authors;
PublishedDateTime = info.PublishedDateTime;
IsLatestVersion = info.IsLatestVersion;
DownloadCount = info.DownloadCount;
LocalIsLatestVersion = info.LocalIsLatestVersion;
LocalPath = info.LocalPath;
InstalledDateTime = info.InstalledDateTime;
}
示例5: ConvertLocalPackageToSiteExtensionInfo
private async Task<SiteExtensionInfo> ConvertLocalPackageToSiteExtensionInfo(UIPackageMetadata package, bool checkLatest, ITracer tracer = null)
{
if (package == null)
{
return null;
}
var info = new SiteExtensionInfo(package);
if (IsInstalledToWebRoot(info.Id))
{
info.Type = SiteExtensionInfo.SiteExtensionType.WebRoot;
}
SetLocalInfo(info);
await TryCheckLocalPackageLatestVersionFromRemote(info, checkLatest, tracer);
return info;
}
示例6: ConvertRemotePackageToSiteExtensionInfo
public SiteExtensionInfo ConvertRemotePackageToSiteExtensionInfo(IPackage package)
{
var info = new SiteExtensionInfo(package);
IPackage localPackage = _localRepository.FindPackage(info.Id);
if (localPackage != null)
{
UpdateLocalInfo(info);
// Assume input package (from remote) is always the latest version.
info.LocalIsLatestVersion = package.Version == localPackage.Version;
}
return info;
}
示例7: CheckRemotePackageLatestVersion
private async Task<SiteExtensionInfo> CheckRemotePackageLatestVersion(SiteExtensionInfo info, string feedUrl)
{
info.FeedUrl = feedUrl;
UIPackageMetadata localPackage = await _localRepository.GetLatestPackageById(info.Id);
if (localPackage != null)
{
SetLocalInfo(info);
// Assume input package (from remote) is always the latest version.
info.LocalIsLatestVersion = NuGetVersion.Parse(info.Version).Equals(localPackage.Identity.Version);
}
return info;
}
示例8: ConvertLocalPackageToSiteExtensionInfo
private SiteExtensionInfo ConvertLocalPackageToSiteExtensionInfo(IPackage package, bool checkLatest)
{
if (package == null)
{
return null;
}
var info = new SiteExtensionInfo(package);
SetLocalInfo(info);
if (checkLatest)
{
// FindPackage gets back the latest version.
IPackage latestPackage = GetRemoteRepository(info.FeedUrl).FindPackage(info.Id);
if (latestPackage != null)
{
info.LocalIsLatestVersion = package.Version == latestPackage.Version;
info.DownloadCount = latestPackage.DownloadCount;
info.PublishedDateTime = latestPackage.Published;
}
}
return info;
}
示例9: SetPreInstalledExtensionInfo
private static void SetPreInstalledExtensionInfo(SiteExtensionInfo info)
{
string directory = GetPreInstalledDirectory(info.Id);
if (FileSystemHelpers.DirectoryExists(directory))
{
if (info.Type == SiteExtensionInfo.SiteExtensionType.PreInstalledMonaco)
{
info.Version = GetPreInstalledLatestVersion(directory);
}
else if (info.Type == SiteExtensionInfo.SiteExtensionType.PreInstalledEnabled)
{
info.Version = typeof(SiteExtensionManager).Assembly.GetName().Version.ToString();
}
info.PublishedDateTime = FileSystemHelpers.GetLastWriteTimeUtc(directory);
}
else
{
info.Version = null;
info.PublishedDateTime = null;
}
info.LocalIsLatestVersion = true;
}
示例10: EnablePreInstalledExtension
private SiteExtensionInfo EnablePreInstalledExtension(SiteExtensionInfo info)
{
string id = info.Id;
string installationDirectory = GetInstallationDirectory(id);
try
{
if (FileSystemHelpers.DirectoryExists(installationDirectory))
{
FileSystemHelpers.DeleteDirectorySafe(installationDirectory);
}
if (ExtensionRequiresApplicationHost(info))
{
if (info.Type == SiteExtensionInfo.SiteExtensionType.PreInstalledMonaco)
{
GenerateApplicationHostXdt(installationDirectory,
_preInstalledExtensionDictionary[id].ExtensionUrl, isPreInstalled: true);
}
}
else
{
FileSystemHelpers.CreateDirectory(installationDirectory);
}
}
catch (Exception ex)
{
ITracer tracer = _traceFactory.GetTracer();
tracer.TraceError(ex);
FileSystemHelpers.DeleteDirectorySafe(installationDirectory);
return null;
}
return GetPreInstalledExtension(id);
}
示例11: GetUrlFromApplicationHost
private static string GetUrlFromApplicationHost(SiteExtensionInfo info)
{
try
{
var appHostDoc = new XmlDocument();
appHostDoc.Load(Path.Combine(info.LocalPath, _applicationHostFile));
// Get the 'path' property of the first 'application' element, which is the relative url.
XmlNode pathPropertyNode = appHostDoc.SelectSingleNode("//application[@path]/@path");
return pathPropertyNode.Value;
}
catch (SystemException)
{
return null;
}
}
示例12: FillSiteExtensionInfo
public void FillSiteExtensionInfo(SiteExtensionInfo info, string defaultProvisionState = null)
{
info.ProvisioningState = ProvisioningState ?? defaultProvisionState;
info.Comment = Comment;
}
示例13: ReadSiteExtensionInfo
public void ReadSiteExtensionInfo(SiteExtensionInfo info)
{
ProvisioningState = info.ProvisioningState;
Comment = info.Comment;
}
示例14: ExtensionRequiresApplicationHost
private static bool ExtensionRequiresApplicationHost(SiteExtensionInfo info)
{
string appSettingName = info.Id.ToUpper(CultureInfo.CurrentCulture) + "_EXTENSION_VERSION";
return ConfigurationManager.AppSettings[appSettingName] != "beta";
}
示例15: InstallExtension
public async Task<SiteExtensionInfo> InstallExtension(SiteExtensionInfo info)
{
return await Client.PostJsonAsync<SiteExtensionInfo, SiteExtensionInfo>(String.Empty, info);
}