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


C# Guid.HasGuidValue方法代码示例

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


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

示例1: FindTermStore

        internal static TermStore FindTermStore(SPSite site,
            string termStorename, Guid? termStoreId, bool? useDefaultSiteCollectionTermStore)
        {
            var session = new TaxonomySession(site);
            TermStore termStore = null;

            if (useDefaultSiteCollectionTermStore.HasValue && useDefaultSiteCollectionTermStore.Value == true)
            {
                TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Resolving Term Store as useDefaultSiteCollectionTermStore");
                termStore = session.DefaultSiteCollectionTermStore;
            }
            else if (termStoreId.HasGuidValue())
            {
                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving Term Store by ID: [{0}]", termStoreId.Value);
                termStore = session.TermStores[termStoreId.Value];
            }
            else if (!string.IsNullOrEmpty(termStorename))
            {
                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving Term Store by Name: [{0}]", termStorename);
                termStore = session.TermStores[termStorename];
            }


            return termStore;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:25,代码来源:TaxonomyTermStoreModelHandler.cs

示例2: GetTargetWeb

        public SPWeb GetTargetWeb(SPSite site, string webUrl, Guid? webId)
        {
            if (webId.HasGuidValue())
            {
                return site.OpenWeb(webId.Value);
            }
            else if (!string.IsNullOrEmpty(webUrl))
            {
                var targetWebUrl = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                {
                    Value = webUrl,
                    Context = site
                }).Value;

                // server relative URl, always
                targetWebUrl = UrlUtility.RemoveStartingSlash(targetWebUrl);
                targetWebUrl = "/" + targetWebUrl;

                var targetWeb = site.OpenWeb(targetWebUrl);

                return targetWeb;
            }

            // root web by default
            return site.RootWeb;
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:26,代码来源:LookupFieldModelHandler.cs

示例3: GetTargetWeb

        public Web GetTargetWeb(Site site, string webUrl, Guid? webId)
        {
            var context = site.Context;

            if (webId.HasGuidValue())
            {
                var targetWeb = site.OpenWebById(webId.Value);

                context.Load(targetWeb);
                context.ExecuteQueryWithTrace();

                return targetWeb;
            }
            else if (!string.IsNullOrEmpty(webUrl))
            {
                var oldValue = CSOMTokenReplacementService.AllowClientContextAsTokenReplacementContext;

                try
                {
                    CSOMTokenReplacementService.AllowClientContextAsTokenReplacementContext = true;

                    var targetWebUrl = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                    {
                        Value = webUrl,
                        Context = context
                    }).Value;

                    // server relative url, ensure / in the beginning
                    targetWebUrl = UrlUtility.RemoveStartingSlash(targetWebUrl);
                    targetWebUrl = "/" + targetWebUrl;

                    var targetWeb = site.OpenWeb(targetWebUrl);

                    context.Load(targetWeb);
                    context.ExecuteQueryWithTrace();

                    return targetWeb;
                }
                finally
                {
                    CSOMTokenReplacementService.AllowClientContextAsTokenReplacementContext = oldValue;
                }
            }

            // root web by default
            return site.RootWeb;
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:47,代码来源:LookupFieldModelHandler.cs

示例4: LookupList

        public static List LookupList(Web web,
            string listUrl, string listTitle, Guid? listId)
        {
            List list = null;

            if (!string.IsNullOrEmpty(listUrl))
            {
                list = web.QueryAndGetListByUrl(listUrl);
            }
            else if (!string.IsNullOrEmpty(listTitle))
            {
                list = web.Lists.GetByTitle(listTitle);
            }
            else if (listId.HasGuidValue())
            {
                list = web.Lists.GetById(listId.Value);
            }
            else
            {
                throw new SPMeta2Exception("ListUrl, ListTitle or ListId should be defined.");
            }

            return list;
        }
开发者ID:avishnyakov,项目名称:spmeta2,代码行数:24,代码来源:XsltListViewWebPartModelHandler.cs

示例5: LookupTermSet

        public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
            Site site,
            string termGroupName, Guid? termGroupId, bool? isSiteCollectionGroup,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            var storeContext = context;

            TermGroup currenGroup = null;

            if (!string.IsNullOrEmpty(termGroupName))
            {
                currenGroup = termStore.Groups.GetByName(termGroupName);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }
            else if (termGroupId != null && termGroupId.HasGuidValue())
            {
                currenGroup = termStore.Groups.GetById(termGroupId.Value);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }
            else if (isSiteCollectionGroup == true)
            {
                currenGroup = termStore.GetSiteCollectionGroup(site, false);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }

            if (!string.IsNullOrEmpty(termSetName))
            {
                if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
                {
                    TermSet termSet = null;

                    var scope = new ExceptionHandlingScope(storeContext);
                    using (scope.StartScope())
                    {
                        using (scope.StartTry())
                        {
                            termSet = currenGroup.TermSets.GetByName(termSetName);
                            storeContext.Load(termSet);
                        }

                        using (scope.StartCatch())
                        {

                        }
                    }

                    storeContext.ExecuteQueryWithTrace();

                    if (termSet != null && termSet.ServerObjectIsNull == false)
                    {
                        storeContext.Load(termSet, g => g.Id);
                        storeContext.ExecuteQueryWithTrace();

                        return termSet;
                    }
                }
                else
                {
                    var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);

                    storeContext.Load(termSets);
                    storeContext.ExecuteQueryWithTrace();

                    return termSets.FirstOrDefault();
                }
            }

            if (termSetId.HasGuidValue())
            {
                if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
                {
                    TermSet termSet = null;

                    var scope = new ExceptionHandlingScope(storeContext);
                    using (scope.StartScope())
                    {
                        using (scope.StartTry())
                        {
                            termSet = currenGroup.TermSets.GetById(termSetId.Value);
                            storeContext.Load(termSet);
                        }

                        using (scope.StartCatch())
                        {

                        }
                    }

                    storeContext.ExecuteQueryWithTrace();

                    if (termSet != null && termSet.ServerObjectIsNull == false)
                    {
                        storeContext.Load(termSet, g => g.Id);
                        storeContext.ExecuteQueryWithTrace();
//.........这里部分代码省略.........
开发者ID:karayakar,项目名称:spmeta2,代码行数:101,代码来源:TaxonomyFieldModelHandler.cs

示例6: LookupTermSet

        public static TermSet LookupTermSet(
            TermStore tesmStore,
            string termGroupName, Guid? groupId, bool? isSiteCollectionGroup, SPSite site,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            Group currentGroup = null;

            if (!string.IsNullOrEmpty(termGroupName))
            {
                currentGroup = tesmStore.Groups.FirstOrDefault(g => g.Name.ToUpper() == termGroupName.ToUpper());
            }
            else if (groupId != null && groupId.HasGuidValue())
            {
                currentGroup = tesmStore.GetGroup(groupId.Value);
            }
            else if (isSiteCollectionGroup.HasValue && isSiteCollectionGroup.Value)
            {
                currentGroup = tesmStore.GetSiteCollectionGroup(site);
            }

            if (termSetId.HasGuidValue())
            {
                if (currentGroup != null)
                    return currentGroup.TermSets.FirstOrDefault(t => t.Id == termSetId.Value);

                return tesmStore.GetTermSet(termSetId.Value);
            }

            if (!string.IsNullOrEmpty(termSetName))
            {
                if (currentGroup != null)
                    return currentGroup.TermSets.FirstOrDefault(t => t.Name.ToUpper() == termSetName.ToUpper());

                return tesmStore.GetTermSets(termSetName, termSetLCID).FirstOrDefault();
            }

            return null;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:38,代码来源:TaxonomyFieldModelHandler.cs

示例7: LookupBindContext

        internal static ListBindContext LookupBindContext(ListItemModelHost listItemModelHost,
           string webUrl, Guid? webId,
           string listUrl, string listTitle, Guid? listId,
           string viewTitle, Guid? viewId,
            string webPartTitleUrl
            )
        {
            var result = new ListBindContext
            {

            };

            var web = listItemModelHost.HostWeb;
            var context = listItemModelHost.HostWeb.Context;

            var targetWeb = listItemModelHost.HostWeb;

            if (webId.HasGuidValue() || !string.IsNullOrEmpty(webUrl))
            {
                targetWeb = new LookupFieldModelHandler()
                                .GetTargetWeb(listItemModelHost.HostClientContext.Site,
                                        webUrl, webId);
            }

            var list = LookupList(targetWeb, listUrl, listTitle, listId);

            View view = null;

            if (viewId.HasValue && viewId != default(Guid))
                view = list.Views.GetById(viewId.Value);
            else if (!string.IsNullOrEmpty(viewTitle))
                view = list.Views.GetByTitle(viewTitle);

            context.Load(list, l => l.Id);
            context.Load(list, l => l.DefaultViewUrl);
            context.Load(list, l => l.Title);

            // TODO, https://github.com/SubPointSolutions/spmeta2/issues/765
            // list.DefaultView is not available, so a full fetch for list view is a must for SP2010.

            #if !NET35
            context.Load(list, l => l.DefaultView);
            #endif

            if (view != null)
            {
                context.Load(view);
                context.ExecuteQueryWithTrace();

            #if !NET35
                result.OriginalView = list.DefaultView;
                result.OriginalViewId = list.DefaultView.Id;
            #endif

                result.TargetView = view;
                result.TargetViewId = view.Id;

                result.TitleUrl = view.ServerRelativeUrl;
            }
            else
            {
                context.ExecuteQueryWithTrace();
            }

            result.ListId = list.Id;
            result.List = list;

            if (webPartTitleUrl == null)
            {
                if (string.IsNullOrEmpty(result.TitleUrl))
                    result.TitleUrl = list.DefaultViewUrl;
            }

            #if !NET35
            result.DefaultViewId = list.DefaultView.Id;
            #endif

            return result;
        }
开发者ID:avishnyakov,项目名称:spmeta2,代码行数:79,代码来源:XsltListViewWebPartModelHandler.cs

示例8: HandleWikiPageProvision

        private void HandleWikiPageProvision(ListItem listItem,
            WebPartDefinitionBase webpartModel, Guid? currentWebPartStoreKey, Guid? oldWebParStoreKey)
        {
            if (!webpartModel.AddToPageContent)
                return;

            TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "AddToPageContent = true. Handling wiki/publishig page provision case.");

            var context = listItem.Context;

            var targetFieldName = string.Empty;

            if (listItem.FieldValues.ContainsKey(BuiltInInternalFieldNames.WikiField))
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "WikiField field is detected. Switching to wiki page web part provision.");

                targetFieldName = BuiltInInternalFieldNames.WikiField;
            }
            else if (listItem.FieldValues.ContainsKey(BuiltInInternalFieldNames.PublishingPageLayout))
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "PublishingPageLayout field is detected. Switching to publishin page web part provision.");

                targetFieldName = BuiltInInternalFieldNames.PublishingPageContent;
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "Not PublishingPageLayout field, nor WikiField is detected. Skipping.");
                return;
            }

            // any on the page?
            var existingWebPartId = string.Empty;

            // current from the new provision
            var upcomingWebPartId = string.Empty;

            // weird, by some web part ignor ID from the XML
            // so webpartStoreKey from the previous CSOM adding web part to the page must be used

            // M2 covers that fact with the regression testing, so we know what are they
            // and we have NOD idea why it happens
            if (ShouldUseWebPartStoreKeyForWikiPage)
            {
                upcomingWebPartId = currentWebPartStoreKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-"); ;
            }
            else
            {
                // get from the model
                upcomingWebPartId = webpartModel.Id.ToString()
                                       .Replace("g_", string.Empty)
                                       .Replace("_", "-"); ;
            }

            if (!oldWebParStoreKey.HasGuidValue())
            {
                // first provision
                existingWebPartId = currentWebPartStoreKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-");
            }
            else
            {
                // second provision,
                // we had web part on the page and can reuse that ID to relink on wiki content
                existingWebPartId = oldWebParStoreKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-");
            }

            var content = listItem[targetFieldName] == null
                ? string.Empty
                : listItem[targetFieldName].ToString();

            var wikiTemplate = new StringBuilder();

            // actual ID will be replaced later
            wikiTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
            wikiTemplate.Append("     <div class='ms-rtestate-read {0}' id='div_{0}'>");
            wikiTemplate.AppendFormat("     </div>");
            wikiTemplate.AppendFormat("</div>");

            var wikiTemplateOutput = wikiTemplate.ToString();

            if (string.IsNullOrEmpty(content))
            {
                // page is empty, pre-generating HTML
                // pushing web part as the current WebPart Key
                TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall,
                    "Page content is empty Generating new one.");

                content = string.Format(wikiTemplateOutput, upcomingWebPartId);

                listItem[targetFieldName] = content;
                listItem.Update();

                context.ExecuteQueryWithTrace();
            }
            else
//.........这里部分代码省略.........
开发者ID:avishnyakov,项目名称:spmeta2,代码行数:101,代码来源:WebPartModelHandler.cs

示例9: LookupTermSet

        public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            var storeContext = context;

            if (!string.IsNullOrEmpty(termSetName))
            {
                var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);

                storeContext.Load(termSets);
                storeContext.ExecuteQueryWithTrace();

                return termSets.FirstOrDefault();
            }

            if (termSetId.HasGuidValue())
            {
                TermSet termSet = null;

                var scope = new ExceptionHandlingScope(storeContext);
                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        termSet = termStore.GetTermSet(termSetId.Value);
                        storeContext.Load(termSet);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }

                storeContext.ExecuteQueryWithTrace();

                if (termSet != null && termSet.ServerObjectIsNull == false)
                {
                    storeContext.Load(termSet, g => g.Id);
                    storeContext.ExecuteQueryWithTrace();

                    return termSet;
                }
            }

            return null;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:47,代码来源:TaxonomyFieldModelHandler.cs

示例10: HandleWikiPageProvision

        private void HandleWikiPageProvision(ListItem listItem,
            WebPartDefinitionBase webpartModel, Guid? webPartStoreKey, Guid? oldWebParKey)
        {
            if (!webpartModel.AddToPageContent)
                return;

            TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "AddToPageContent = true. Handling wiki/publishig page provision case.");

            var context = listItem.Context;

            var targetFieldName = string.Empty;

            if (listItem.FieldValues.ContainsKey(BuiltInInternalFieldNames.WikiField))
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "WikiField field is detected. Switching to wiki page web part provision.");

                targetFieldName = BuiltInInternalFieldNames.WikiField;
            }
            else if (listItem.FieldValues.ContainsKey(BuiltInInternalFieldNames.PublishingPageLayout))
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "PublishingPageLayout field is detected. Switching to publishin page web part provision.");

                targetFieldName = BuiltInInternalFieldNames.PublishingPageContent;
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionCoreCall, "Not PublishingPageLayout field, nor WikiField is detected. Skipping.");
                return;
            }

            var wikiTemplate = new StringBuilder();

            var existingWebPartId = string.Empty;

            var definitionWebPartId = webpartModel.Id.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-"); ;

            var upcomingWebPartId = definitionWebPartId;

            // aa....
            // extremely unfortunate
            if (webpartModel is XsltListViewWebPartDefinition)
            {
                upcomingWebPartId = webPartStoreKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-"); ;
            }

            if (!oldWebParKey.HasGuidValue())
            {
                // first provision
                existingWebPartId = webPartStoreKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-");
            }
            else
            {
                // second, so that we had web part and use that ID
                existingWebPartId = oldWebParKey.ToString()
                                      .Replace("g_", string.Empty)
                                      .Replace("_", "-");
            }

            var content = listItem[targetFieldName] == null
                ? string.Empty
                : listItem[targetFieldName].ToString();

            // actual ID will be replaced later
            wikiTemplate.AppendFormat("​​​​​​​​​​​​​​​​​​​​​​<div class='ms-rtestate-read ms-rte-wpbox' contentEditable='false'>");
            wikiTemplate.Append("     <div class='ms-rtestate-read {0}' id='div_{0}'>");
            wikiTemplate.AppendFormat("     </div>");
            wikiTemplate.AppendFormat("</div>");

            var wikiTemplateOutput = wikiTemplate.ToString();

            if (string.IsNullOrEmpty(content))
            {
                // page is empty, pre-generating HTML
                // pushing web part as the current WebPart Key
                TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall,
                    "Page content is empty Generating new one.");

                content = string.Format(wikiTemplateOutput, upcomingWebPartId);

                listItem[targetFieldName] = content;
                listItem.Update();

                context.ExecuteQueryWithTrace();
            }
            else
            {
                // we had web part on the page
                // so we need to change the ID
                if (oldWebParKey.HasGuidValue())
                {
                    // was old on the page?
                    if (content.ToUpper().IndexOf(existingWebPartId.ToUpper()) != -1)
                    {
                        // yes, replacing ID
//.........这里部分代码省略.........
开发者ID:jashwanth2269,项目名称:spmeta2,代码行数:101,代码来源:WebPartModelHandler.cs

示例11: LookupBindContext

        internal static ListBindContext LookupBindContext(ListItemModelHost listItemModelHost,
           string webUrl, Guid? webId,
           string listUrl, string listTitle, Guid? listId,
           string viewTitle, Guid? viewId,
            string webPartTitleUrl
            )
        {
            var result = new ListBindContext
            {

            };

            var web = listItemModelHost.HostWeb;
            var context = listItemModelHost.HostWeb.Context;

            var targetWeb = listItemModelHost.HostWeb;

            if (webId.HasGuidValue() || !string.IsNullOrEmpty(webUrl))
            {
                targetWeb = new LookupFieldModelHandler()
                                .GetTargetWeb(listItemModelHost.HostClientContext.Site,
                                        webUrl, webId);
            }

            var list = LookupList(targetWeb, listUrl, listTitle, listId);

            View view = null;

            if (viewId.HasValue && viewId != default(Guid))
                view = list.Views.GetById(viewId.Value);
            else if (!string.IsNullOrEmpty(viewTitle))
                view = list.Views.GetByTitle(viewTitle);

            context.Load(list, l => l.Id);
            context.Load(list, l => l.DefaultViewUrl);
            context.Load(list, l => l.Title);
            context.Load(list, l => l.DefaultView);

            if (view != null)
            {
                context.Load(view);
                context.ExecuteQueryWithTrace();

                result.OriginalView = list.DefaultView;
                result.OriginalViewId = list.DefaultView.Id;

                result.TargetView = view;
                result.TargetViewId = view.Id;

                result.TitleUrl = view.ServerRelativeUrl;
            }
            else
            {
                context.ExecuteQueryWithTrace();
            }

            result.ListId = list.Id;
            result.List = list;

            if (webPartTitleUrl == null)
            {
                if (string.IsNullOrEmpty(result.TitleUrl))
                    result.TitleUrl = list.DefaultViewUrl;
            }

            result.DefaultViewId = list.DefaultView.Id;

            return result;
        }
开发者ID:sweepheart,项目名称:spmeta2,代码行数:69,代码来源:XsltListViewWebPartModelHandler.cs

示例12: LookupTermSet

        public static TermSet LookupTermSet(TermStore tesmStore, string termSetName, Guid? termSetId, int termSetLCID)
        {
            if (termSetId.HasGuidValue())
                return tesmStore.GetTermSet(termSetId.Value);

            if (!string.IsNullOrEmpty(termSetName))
                return tesmStore.GetTermSets(termSetName, termSetLCID).FirstOrDefault();

            return null;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:10,代码来源:TaxonomyFieldModelHandler.cs


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