本文整理汇总了C#中Tenant.SubSiteExists方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.SubSiteExists方法的具体用法?C# Tenant.SubSiteExists怎么用?C# Tenant.SubSiteExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tenant
的用法示例。
在下文中一共展示了Tenant.SubSiteExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubSiteExistsTest
public void SubSiteExistsTest()
{
using (var tenantContext = TestCommon.CreateTenantClientContext())
{
var tenant = new Tenant(tenantContext);
string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
Console.WriteLine("SubSiteExistsTest: step 1");
string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
Console.WriteLine("SubSiteExistsTest: step 1.1");
string subSiteUrlGood = "";
string subSiteUrlWrong = "";
Site site = tenant.GetSiteByUrl(siteToCreateUrl);
tenant.Context.Load(site);
tenant.Context.ExecuteQueryRetry();
Web web = site.RootWeb;
web.Context.Load(web);
web.Context.ExecuteQueryRetry();
Console.WriteLine("SubSiteExistsTest: step 1.2");
//Create sub site
SiteEntity sub = new SiteEntity() { Title = "Test Sub", Url = "sub", Description = "Test" };
web.CreateWeb(sub);
siteToCreateUrl = UrlUtility.EnsureTrailingSlash(siteToCreateUrl);
subSiteUrlGood = String.Format("{0}{1}", siteToCreateUrl, sub.Url);
subSiteUrlWrong = String.Format("{0}{1}", siteToCreateUrl, "8988980");
// Check real sub site
Console.WriteLine("SubSiteExistsTest: step 2");
bool subSiteExists = tenant.SubSiteExists(subSiteUrlGood);
Console.WriteLine("SubSiteExistsTest: step 2.1");
Assert.IsTrue(subSiteExists);
// check non existing sub site
Console.WriteLine("SubSiteExistsTest: step 3");
bool subSiteExists2 = tenant.SubSiteExists(subSiteUrlWrong);
Console.WriteLine("SubSiteExistsTest: step 3.1");
Assert.IsFalse(subSiteExists2);
// check root site (= site collection). Will return true when existing
Console.WriteLine("SubSiteExistsTest: step 4");
bool subSiteExists3 = tenant.SubSiteExists(siteToCreateUrl);
Console.WriteLine("SubSiteExistsTest: step 4.1");
Assert.IsTrue(subSiteExists3);
// check root site (= site collection) that does not exist. Will return false when non-existant
Console.WriteLine("SubSiteExistsTest: step 5");
bool subSiteExists4 = tenant.SubSiteExists(siteToCreateUrl + "8808809808");
Console.WriteLine("SubSiteExistsTest: step 5.1");
Assert.IsFalse(subSiteExists4);
}
}
示例2: SubSiteExistsInTenant
public static bool SubSiteExistsInTenant(this Web web, string siteUrl)
{
Tenant tenant = new Tenant(web.Context);
return tenant.SubSiteExists(siteUrl);
}
示例3: SubSiteExists
/// <summary>
/// Checks to see if a sub site already exists.
/// </summary>
/// <param name="siteUrl"></param>
/// <returns></returns>
public bool SubSiteExists(string siteUrl)
{
bool _doesSiteExist = false;
UsingContext(ctx =>
{
var tenant = new Tenant(ctx);
_doesSiteExist = tenant.SubSiteExists(siteUrl);
});
return _doesSiteExist;
}