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


C# Web.IsObjectPropertyInstantiated方法代码示例

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


在下文中一共展示了Web.IsObjectPropertyInstantiated方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

        private void Delete(Web web)
        {
            if (!base.ShouldProcess(Identity.ToString()))
                return;

            var ctx = base.Context;
            if (!web.IsObjectPropertyInstantiated("Webs"))
            {
                ctx.Load(web.Webs);
                ctx.ExecuteQuery();
            }
            if (web.Webs.Count > 0)
            {
                foreach (Web childWeb in web.Webs)
                {
                    Delete(childWeb);
                }
                if (web.Webs.Count == 0)
                {
                    web.DeleteObject();
                    web.Context.ExecuteQuery();
                }
            }
            else
            {
                web.DeleteObject();
                web.Context.ExecuteQuery();
            }
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:29,代码来源:RemoveSPOWeb.cs

示例2: EnsureWeb

 /// <summary>
 /// Check if the property is loaded on the web object, if not the web object will be reloaded
 /// </summary>
 /// <param name="cc">Context to execute upon</param>
 /// <param name="web">Web to execute upon</param>
 /// <param name="propertyToCheck">Property to check</param>
 /// <returns>A reloaded web object</returns>
 public static Web EnsureWeb(ClientRuntimeContext cc, Web web, string propertyToCheck)
 {
     if (!web.IsObjectPropertyInstantiated(propertyToCheck))
     {
         // get instances to root web, since we are processing currently sub site
         cc.Load(web);
         cc.ExecuteQuery();
     }
     return web;
 }
开发者ID:xaviayala,项目名称:Birchman,代码行数:17,代码来源:Utility.cs

示例3: AddNewThemeOptionToSite

        public static void AddNewThemeOptionToSite(Web web, string themeName, string colorFilePath, string fontFilePath, string backGroundPath, string masterPageName)
        {
            // Let's get instance to the composite look gallery
            List themesOverviewList = web.GetCatalog(124);
            web.Context.Load(themesOverviewList);
            web.Context.ExecuteQuery();
            // Do not add duplicate, if the theme is already there
            if (!ThemeEntryExists(web, themesOverviewList, themeName))
            {
                // if web information is not available, load it
                if (!web.IsObjectPropertyInstantiated("ServerRelativeUrl"))
                {
                    web.Context.Load(web);
                    web.Context.ExecuteQuery();
                }
                // Let's create new theme entry. Notice that theme selection is not available from UI in personal sites, so this is just for consistency sake
                ListItemCreationInformation itemInfo = new ListItemCreationInformation();
                Microsoft.SharePoint.Client.ListItem item = themesOverviewList.AddItem(itemInfo);
                item["Name"] = themeName;
                item["Title"] = themeName;
                if (!string.IsNullOrEmpty(colorFilePath))
                {
                    item["ThemeUrl"] = URLCombine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(colorFilePath)));
                }
                if (!string.IsNullOrEmpty(fontFilePath))
                {
                    item["FontSchemeUrl"] = URLCombine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(fontFilePath)));
                }
                if (!string.IsNullOrEmpty(backGroundPath))
                {
                    item["ImageUrl"] = URLCombine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(backGroundPath)));
                }
                // we use seattle master if anythign else is not set
                if (string.IsNullOrEmpty(masterPageName))
                {
                    item["MasterPageUrl"] = URLCombine(web.ServerRelativeUrl, "/_catalogs/masterpage/seattle.master");
                }
                else
                {
                    item["MasterPageUrl"] = URLCombine(web.ServerRelativeUrl, string.Format("/_catalogs/masterpage/{0}", Path.GetFileName(masterPageName)));
                }

                item["DisplayOrder"] = 11;
                item.Update();
                web.Context.ExecuteQuery();
            }

        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:48,代码来源:Functions.cs

示例4: AddComposedLooks

        private void AddComposedLooks(Microsoft.SharePoint.Client.ClientContext context, ShWeb configWeb, Web web, ShComposedLook composedLook)
        {
            if (composedLook != null)
            {
                Log.Debug("Setting Composed Look for web " + configWeb.Name);
                var themeUrl = string.Empty;
                var fontSchemeUrl = string.Empty;

                List themeList = web.GetCatalog(124);
                web.Context.Load(themeList);
                web.Context.ExecuteQuery();

                // We are assuming that the theme exists
                CamlQuery query = new CamlQuery();
                string camlString = @"
                <View>
                    <Query>
                        <Where>
                            <Eq>
                                <FieldRef Name='Name' />
                                <Value Type='Text'>{0}</Value>
                            </Eq>
                        </Where>
                        </Query>
                </View>";
                camlString = string.Format(camlString, composedLook.Name);
                query.ViewXml = camlString;
                var found = themeList.GetItems(query);
                web.Context.Load(found);
                web.Context.ExecuteQuery();

                if (found.Count == 0)
                {
                    if (!web.IsObjectPropertyInstantiated("ServerRelativeUrl"))
                    {
                        context.Load(web);
                        context.ExecuteQuery();
                    }

                    ListItemCreationInformation itemInfo = new ListItemCreationInformation();
                    Microsoft.SharePoint.Client.ListItem item = themeList.AddItem(itemInfo);
                    item["Name"] = composedLook.Name;
                    item["Title"] = composedLook.Title;
                    if (!string.IsNullOrEmpty(composedLook.ThemeUrl))
                    {
                        themeUrl = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(composedLook.ThemeUrl)));
                        item["ThemeUrl"] = themeUrl;
                    }
                    if (!string.IsNullOrEmpty(composedLook.FontSchemeUrl))
                    {
                        fontSchemeUrl = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(composedLook.FontSchemeUrl)));
                        item["FontSchemeUrl"] = fontSchemeUrl;
                    }
                    if (string.IsNullOrEmpty(composedLook.MasterPageUrl))
                    {
                        item["MasterPageUrl"] = Url.Combine(web.ServerRelativeUrl, "/_catalogs/masterpage/seattle.master");
                    }
                    else
                    {
                        item["MasterPageUrl"] = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/masterpage/{0}", Path.GetFileName(composedLook.MasterPageUrl)));
                    }
                    item["DisplayOrder"] = 11;
                    item.Update();
                    context.ExecuteQuery();
                }
                else
                {
                    Microsoft.SharePoint.Client.ListItem item = found[0];
                    themeUrl = MakeAsRelativeUrl((item["ThemeUrl"] as FieldUrlValue).Url);
                    fontSchemeUrl = MakeAsRelativeUrl((item["FontSchemeUrl"] as FieldUrlValue).Url);
                }

                web.ApplyTheme(themeUrl, fontSchemeUrl, null, false);
                context.ExecuteQuery();
            }
        }
开发者ID:damsleth,项目名称:sherpa,代码行数:76,代码来源:SiteSetupManager.cs

示例5: CreateEntities

        public override ProvisioningTemplate CreateEntities(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {            
            // Load object if not there
            bool executeQueryNeeded = false;
            if (!web.IsObjectPropertyInstantiated("AlternateCssUrl"))
            {
                web.Context.Load(web);
                executeQueryNeeded = true;
            }
            if (!web.IsObjectPropertyInstantiated("Url"))
            {
                web.Context.Load(web);
                executeQueryNeeded = true;
            }

            if (executeQueryNeeded)
            {
                web.Context.ExecuteQuery();
            }

            // Information coming from the site
            template.ComposedLook.AlternateCSS = Tokenize(web.AlternateCssUrl, web.Url);
            template.ComposedLook.MasterPage = Tokenize(web.MasterUrl, web.Url);
            template.ComposedLook.SiteLogo = Tokenize(web.SiteLogoUrl, web.Url);

            var theme = web.GetCurrentComposedLook();

            if (theme != null)
            {
                template.ComposedLook.Name = theme.Name;

                if (theme.IsCustomComposedLook)
                {
                    if (creationInfo.PersistComposedLookFiles && creationInfo.FileConnector != null)
                    {
                        Site site = (web.Context as ClientContext).Site;
                        if (!site.IsObjectPropertyInstantiated("Url"))
                        {
                            web.Context.Load(site);
                            web.Context.ExecuteQueryRetry();
                        }

                        // Let's create a SharePoint connector since our files anyhow are in SharePoint at this moment
                        SharePointConnector spConnector = new SharePointConnector(web.Context, web.Url, "dummy");

                        // to get files from theme catalog we need a connector linked to the root site
                        SharePointConnector spConnectorRoot;
                        if (!site.Url.Equals(web.Url, StringComparison.InvariantCultureIgnoreCase))
                        {
                            spConnectorRoot = new SharePointConnector(web.Context.Clone(site.Url), site.Url, "dummy");
                        }
                        else
                        {
                            spConnectorRoot = spConnector;
                        }                        

                        // Download the theme/branding specific files
                        DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.AlternateCssUrl);
                        DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, web.SiteLogoUrl);
                        DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.BackgroundImage);
                        DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Theme);
                        DownLoadFile(spConnector, spConnectorRoot, creationInfo.FileConnector, web.Url, theme.Font);
                    }

                    template.ComposedLook.BackgroundFile = Tokenize(theme.BackgroundImage, web.Url);
                    template.ComposedLook.ColorFile = Tokenize(theme.Theme, web.Url);
                    template.ComposedLook.FontFile = Tokenize(theme.Font, web.Url);

                    // Create file entries for the custom theme files  
                    if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
                    {
                        template.Files.Add(GetComposedLookFile(template.ComposedLook.BackgroundFile));
                    }
                    if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
                    {
                        template.Files.Add(GetComposedLookFile(template.ComposedLook.ColorFile));
                    }
                    if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
                    {
                        template.Files.Add(GetComposedLookFile(template.ComposedLook.FontFile));
                    }
                    if (!string.IsNullOrEmpty(template.ComposedLook.SiteLogo))
                    {
                        template.Files.Add(GetComposedLookFile(template.ComposedLook.SiteLogo));
                    }

                    // If a base template is specified then use that one to "cleanup" the generated template model
                    if (creationInfo.BaseTemplate != null)
                    {
                        template = CleanupEntities(template, creationInfo.BaseTemplate);
                    }
                }
                else
                {
                    template.ComposedLook.BackgroundFile = "";
                    template.ComposedLook.ColorFile = "";
                    template.ComposedLook.FontFile = "";
                }
            }
            else
//.........这里部分代码省略.........
开发者ID:danibenal,项目名称:PnP,代码行数:101,代码来源:ObjectComposedLook.cs

示例6: IsPublishingWeb

        private bool IsPublishingWeb(ClientContext clientContext, Web web)
        {
            Logger.AddMessageToTraceLogFile(Constants.Logging, "Checking if the current web is a publishing web");
            Console.WriteLine("Checking if the current web is a publishing web");

            Logger.AddMessageToTraceLogFile(Constants.Logging, "Checking for PublishingFeatureActivated ...");
            Console.WriteLine("Checking for PublishingFeatureActivated ...");

            var _IsPublished = false;
            var propName = "__PublishingFeatureActivated";

            try
            {

                //Ensure web properties are loaded
                if (!web.IsObjectPropertyInstantiated("AllProperties"))
                {
                    clientContext.Load(web, w => w.AllProperties);
                    clientContext.ExecuteQuery();
                    Logger.AddMessageToTraceLogFile(Constants.Logging, "Ensure web properties are loaded...");

                }
                //Verify whether publishing feature is activated
                if (web.AllProperties.FieldValues.ContainsKey(propName))
                {
                    bool propVal;
                    Boolean.TryParse((string)web.AllProperties[propName], out propVal);

                    Logger.AddMessageToTraceLogFile(Constants.Logging, "Verify whether publishing feature is activated...");

                    _IsPublished = propVal;
                    return propVal;
                }
            }
            catch (Exception ex)
            {
                ExceptionCsv.WriteException(ExceptionCsv.WebApplication, ExceptionCsv.SiteCollection, ExceptionCsv.WebUrl, "Web Part", ex.Message, ex.ToString(), "IsPublishingWeb", ex.GetType().ToString());
                Logger.AddMessageToTraceLogFile(Constants.Logging, "[EXCEPTION][IsPublishingWeb] Exception Message: " + ex.Message);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[EXCEPTION][IsPublishingWeb] Exception Message: " + ex.Message);
                Console.ForegroundColor = ConsoleColor.Gray;
            }
            return _IsPublished;
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:44,代码来源:WebPartTransformationHelper.cs

示例7: IsPublishingWeb

        private static bool IsPublishingWeb(ClientContext clientContext, Web web)
        {
            Logger.LogInfoMessage("Checking if the current web is a publishing web", false);

            var _IsPublished = false;
            var propName = "__PublishingFeatureActivated";

            try
            {

                //Ensure web properties are loaded
                if (!web.IsObjectPropertyInstantiated("AllProperties"))
                {
                    clientContext.Load(web, w => w.AllProperties);
                    clientContext.ExecuteQuery();
                }
                //Verify whether publishing feature is activated
                if (web.AllProperties.FieldValues.ContainsKey(propName))
                {
                    bool propVal;
                    Boolean.TryParse((string)web.AllProperties[propName], out propVal);
                    _IsPublished = propVal;
                    return propVal;
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[DeleteMissingWebparts: IsPublishingWeb]. Exception Message: "
                    + ex.Message + ", Exception Comments: Exception occured while finding publishing page", true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, web.Url, "Webpart", ex.Message,
                    ex.ToString(), "IsPublishingWeb", ex.GetType().ToString(), "Exception occured while finding publishing page");
            }
            finally
            {
                clientContext.Dispose();
                web = null;
            }
            return _IsPublished;
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:39,代码来源:DeleteMissingWebparts.cs

示例8: IsPublishingWeb

        public static bool IsPublishingWeb(ClientContext clientContext, Web web)
        {
            Logger.LogInfoMessage("Checking if the current web is a publishing web");

            Logger.LogInfoMessage("Checking for PublishingFeatureActivated ...");

            var _IsPublished = false;
            var propName = "__PublishingFeatureActivated";

            try
            {

                //Ensure web properties are loaded
                if (!web.IsObjectPropertyInstantiated("AllProperties"))
                {
                    clientContext.Load(web, w => w.AllProperties);
                    clientContext.ExecuteQuery();
                    Logger.LogInfoMessage("Ensure web properties are loaded...");

                }
                //Verify whether publishing feature is activated
                if (web.AllProperties.FieldValues.ContainsKey(propName))
                {
                    bool propVal;
                    Boolean.TryParse((string)web.AllProperties[propName], out propVal);

                    Logger.LogInfoMessage("Verify whether publishing feature is activated...");

                    _IsPublished = propVal;
                    return propVal;
                }
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("[IsPublishingWeb] Exception Message: " + ex.Message);
                System.Console.ResetColor();
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, web.Url, "IsPublishingWeb", ex.Message, ex.ToString(), "IsPublishingWeb()", ex.GetType().ToString());
            }
            return _IsPublished;
        }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:41,代码来源:AddWebPart.cs


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