本文整理汇总了C#中Kooboo.CMS.Sites.Models.Site.AsActual方法的典型用法代码示例。如果您正苦于以下问题:C# Site.AsActual方法的具体用法?C# Site.AsActual怎么用?C# Site.AsActual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Sites.Models.Site
的用法示例。
在下文中一共展示了Site.AsActual方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScriptFileUrl
/// <summary>
/// The script file url o fsite
/// </summary>
/// <param name="frontUrlHelper">The front url helper</param>
/// <param name="site">The site</param>
/// <param name="baseUri">Base uri</param>
/// <param name="relativeScriptFilePath">The relative script file path of site</param>
/// <returns></returns>
public static IHtmlString ScriptFileUrl(this FrontUrlHelper frontUrlHelper, Site site, string baseUri, string relativeScriptFilePath, bool forceSSL = false)
{
string resourceDomain = site.ResourceDomain.FormatUrlWithProtocol(forceSSL);
bool scriptFileExists = false;
string scriptFileUrl = String.Empty;
string scriptFilePhysicalPath = String.Empty;
do
{
site = site.AsActual();
ScriptFile scriptFile = new ScriptFile(site, String.Empty);
if (scriptFile != null)
{
scriptFileUrl = UrlUtility.Combine(scriptFile.VirtualPath, relativeScriptFilePath);
scriptFilePhysicalPath = HttpContext.Current.Server.MapPath(scriptFileUrl);
scriptFileExists = File.Exists(scriptFilePhysicalPath);
}
site = site.Parent;
} while (site != null && !scriptFileExists);
if (!String.IsNullOrEmpty(resourceDomain))
{
baseUri = resourceDomain; // CDN have high priority
}
return new HtmlString(UrlUtility.ToHttpAbsolute(baseUri, scriptFileUrl));
}
示例2: Decrypt
public static string Decrypt(Site site, string cryptedString)
{
if (String.IsNullOrEmpty(cryptedString))
{
return cryptedString;
}
var key = GetKey(site.AsActual());
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream
(Convert.FromBase64String(cryptedString));
CryptoStream cryptoStream = new CryptoStream(memoryStream,
cryptoProvider.CreateDecryptor(key, key), CryptoStreamMode.Read);
StreamReader reader = new StreamReader(cryptoStream);
return reader.ReadToEnd();
}
示例3: OnExcluded
public void OnExcluded(Site site)
{
var repository = site.AsActual().GetRepository();
if (repository != null)
{
TextFolder productFolder = new TextFolder(repository, "Product");
if (productFolder.AsActual() != null)
{
_textFolderManager.Remove(repository, productFolder);
}
Schema productSchema = new Schema(repository, "Product");
if (productSchema.AsActual() != null)
{
_schemaManager.Remove(repository, productSchema);
}
}
}
示例4: PageRequestContext
/// <summary>
/// Initializes a new instance of the <see cref="FrontRequestContext"/> class.
/// </summary>
/// <param name="site">The site.</param>
/// <param name="page">The page.</param>
/// <param name="requestChannel">The request channel.</param>
/// <param name="httpContext">The HTTP context.</param>
/// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
public PageRequestContext(ControllerContext controllerContext, Site site, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
{
RouteValues = new RouteValueDictionary();
this.ControllerContext = controllerContext;
var httpContext = HttpContext.Current;
this.Site = site.AsActual();
this.Page = page.AsActual();
this.RequestChannel = requestChannel;
this.AllQueryString = new NameValueCollection(httpContext.Request.QueryString);
HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);
if (routeData != null)
{
RouteValues = routeData.Values;
//Combine page parameters to [QueryString].
foreach (var item in RouteValues)
{
if (item.Value != null)
{
AllQueryString[item.Key] = item.Value.ToString();
}
}
}
var moduleUrl = AllQueryString[ModuleUrlSegment];
ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
}
示例5: WrapperUrl
public static IHtmlString WrapperUrl(string url, Site site, FrontRequestChannel channel, bool? requireSSL)
{
if (string.IsNullOrEmpty(url))
{
return new HtmlString(url);
}
var applicationPath = HttpContext.Current.Request.ApplicationPath.TrimStart(new char[] { '/' });
if (!url.StartsWith("/") && !string.IsNullOrEmpty(applicationPath))
{
url = "/" + applicationPath + "/" + url;
}
var sitePath = site.AsActual().SitePath;
if (channel == FrontRequestChannel.Debug || channel == FrontRequestChannel.Design || channel == FrontRequestChannel.Unknown)
{
sitePath = SiteHelper.PREFIX_FRONT_DEBUG_URL + site.FullName;
}
var urlSplit = url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
IEnumerable<string> urlPaths = urlSplit;
if (!string.IsNullOrEmpty(sitePath))
{
if (urlSplit.Length > 0 && applicationPath.EqualsOrNullEmpty(urlSplit[0], StringComparison.OrdinalIgnoreCase))
{
urlPaths = new string[] { applicationPath, sitePath }.Concat(urlSplit.Skip(1));
}
else
{
urlPaths = new string[] { sitePath }.Concat(urlSplit);
}
}
var endWithSlash = url.EndsWith("/");
url = "/" + string.Join("/", urlPaths.ToArray());
if (endWithSlash && !url.EndsWith("/"))
{
url = url + "/";
}
#region SSL
if (requireSSL.HasValue)
{
if (channel == FrontRequestChannel.Host || channel == FrontRequestChannel.HostNPath)
{
if (HttpContext.Current.Request.IsSecureConnection)
{
//if (!requireSSL.Value)
//{
// url = "http://" + HttpContext.Current.Request.Url.Host + url;
//}
}
else if (requireSSL.Value)
{
url = "https://" + HttpContext.Current.Request.Url.Host + url;
}
}
}
#endregion
return new HtmlString(url);
}
示例6: PageRequestContext
/// <summary>
/// Initializes a new instance of the <see cref="PageRequestContext" /> class.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="rawSite">The raw.</param>
/// <param name="site">The site.</param>
/// <param name="page">The page.</param>
/// <param name="requestChannel">The request channel.</param>
/// <param name="pageRequestUrl">The page request url with out page virtual path.</param>
public PageRequestContext(ControllerContext controllerContext, Site rawSite, Site site, Page rawPage, Page page, FrontRequestChannel requestChannel, string pageRequestUrl)
{
RouteValues = new RouteValueDictionary();
this.ControllerContext = controllerContext;
var httpContext = HttpContext.Current;
this.RawSite = rawSite;
this.RawPage = rawPage;
this.Site = site.AsActual();
this.Page = page.AsActual();
this.RequestChannel = requestChannel;
this.AllQueryString = new NameValueCollection();
var queryString = httpContext.Request.QueryString;
foreach (var key in queryString.AllKeys)
{
var value = queryString[key];
if (!string.IsNullOrEmpty(value))
{
AllQueryString[HttpUtility.HtmlEncode(key)] = HttpUtility.HtmlEncode(value);
}
else
{
AllQueryString[HttpUtility.HtmlEncode(key)] = value;
}
}
HttpContextBase pageContext = new PageHttpContenxt(httpContext, new PageHttpRequest(httpContext.Request, "~/" + pageRequestUrl, ""));
var routeData = page.Route.ToMvcRoute().GetRouteData(pageContext);
if (routeData != null)
{
RouteValues = routeData.Values;
//Combine page parameters to [QueryString].
foreach (var item in RouteValues)
{
if (item.Value != null)
{
AllQueryString[item.Key] = item.Value.ToString();
}
}
}
var moduleUrl = AllQueryString[ModuleUrlContext.ModuleUrlSegment];
ModuleUrlContext = new ModuleUrlContext(this, moduleUrl);
}
示例7: ThemeFileUrl
/// <summary>
/// The theme file url of site
/// </summary>
/// <param name="frontUrlHelper">The front url helper</param>
/// <param name="site">The site</param>
/// <param name="baseUri">Base uri</param>
/// <param name="relativeThemeFilePath">The relative theme file path of site</param>
/// <returns></returns>
public static IHtmlString ThemeFileUrl(this FrontUrlHelper frontUrlHelper, Site site, string baseUri, string relativeThemeFilePath)
{
string resourceDomain = site.ResourceDomain;
bool themeFileExists = false;
string themeFileUrl = String.Empty;
string themeFilePhysicalPath = String.Empty;
do
{
site = site.AsActual();
Theme theme = new Theme(site, site.Theme).LastVersion();
themeFileUrl = UrlUtility.Combine(theme.VirtualPath, relativeThemeFilePath);
themeFilePhysicalPath = HttpContext.Current.Server.MapPath(themeFileUrl);
themeFileExists = File.Exists(themeFilePhysicalPath);
site = theme.Site.Parent;
} while (site != null && !themeFileExists);
if (!String.IsNullOrEmpty(resourceDomain))
{
baseUri = resourceDomain; // CDN have high priority
}
return new HtmlString(UrlUtility.ToHttpAbsolute(baseUri, themeFileUrl));
}
示例8: FlushWebResourceCache
protected virtual void FlushWebResourceCache(Site site, PathResource resource)
{
site = site.AsActual();
var ticks = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
var versions = (string.IsNullOrEmpty(site.Version) ? "1.0.0.0" : site.Version).Split('.');
versions[versions.Length - 1] = ticks;
site.Version = string.Join(".", versions);
ServiceFactory.SiteManager.Update(site);
}
示例9: WrapperUrl
public static IHtmlString WrapperUrl(string url, Site site, FrontRequestChannel channel)
{
if (string.IsNullOrEmpty(url))
{
return new HtmlString(url);
}
var applicationPath = HttpContext.Current.Request.ApplicationPath.TrimStart(new char[] { '/' });
if (!url.StartsWith("/") && !string.IsNullOrEmpty(applicationPath))
{
url = "/" + applicationPath + "/" + url;
}
var urlSplit = url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
var sitePath = site.AsActual().SitePath;
if(channel == FrontRequestChannel.Debug || channel == FrontRequestChannel.Design || channel == FrontRequestChannel.Unknown)
{
sitePath = SiteHelper.PREFIX_FRONT_DEBUG_URL + site.FullName;
}
IEnumerable<string> urlPaths = urlSplit;
if (!string.IsNullOrEmpty(sitePath))
{
if (urlSplit.Length > 0 && applicationPath.EqualsOrNullEmpty(urlSplit[0], StringComparison.OrdinalIgnoreCase))
{
urlPaths = new string[] { applicationPath, sitePath }.Concat(urlSplit.Skip(1));
}
else
{
urlPaths = new string[] { sitePath }.Concat(urlSplit);
}
}
url = "/" + string.Join("/", urlPaths.ToArray());
return new HtmlString(url);
}
示例10: OnIncluded
public void OnIncluded(Site site)
{
var repository = site.AsActual().GetRepository();
if (repository != null)
{
//import the content types. the zip file contains "Category" content type.
//var contentTypePath = new ModulePathHelper(ModuleAreaRegistration.ModuleName).GetModuleInstallationFilePath("ContentType.zip");
//if (File.Exists(contentTypePath.PhysicalPath))
//{
// using (FileStream fs = new FileStream(contentTypePath.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
// {
// _schemaManager.Import(repository, fs, true);
// }
//}
Schema productSchema = new Schema(repository, "Product");
productSchema.AddColumn("ProductName", "TextBox", DataType.String, "", true, true);
productSchema.AddColumn("ProductDetail", "Tinymce", DataType.String, "", false, true);
if (productSchema.AsActual() == null)
{
_schemaManager.Add(repository, productSchema);
}
TextFolder productFolder = new TextFolder(repository, "Product")
{
SchemaName = "Product"
};
if (productFolder.AsActual() == null)
{
_textFolderManager.Add(repository, productFolder);
}
}
}