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


C# Tenant.SubSiteExists方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:52,代码来源:TenantExtensionsTests.cs

示例2: SubSiteExistsInTenant

 public static bool SubSiteExistsInTenant(this Web web, string siteUrl)
 {
     Tenant tenant = new Tenant(web.Context);
     return tenant.SubSiteExists(siteUrl);
 }
开发者ID:JohnKozell,项目名称:PnP,代码行数:5,代码来源:WebExtensions.cs

示例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;
 }
开发者ID:Calisto1980,项目名称:PnP,代码行数:15,代码来源:AbstractSiteProvisioningService.cs


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