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


C# FieldCollection.GetById方法代码示例

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


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

示例1: FindField

        private Field FindField(FieldCollection fields, ContentTypeFieldLinkDefinition listFieldLinkModel)
        {
            var context = fields.Context;

            var scope = new ExceptionHandlingScope(context);

            Field field = null;

            if (listFieldLinkModel.FieldId.HasGuidValue())
            {
                var id = listFieldLinkModel.FieldId.Value;

                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        fields.GetById(id);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }
            }
            else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
            {
                var fieldInternalName = listFieldLinkModel.FieldInternalName;

                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        fields.GetByInternalNameOrTitle(fieldInternalName);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }
            }

            context.ExecuteQueryWithTrace();

            if (!scope.HasException)
            {
                if (listFieldLinkModel.FieldId.HasGuidValue())
                {
                    field = fields.GetById(listFieldLinkModel.FieldId.Value);
                }
                else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
                {
                    field = fields.GetByInternalNameOrTitle(listFieldLinkModel.FieldInternalName);
                }

                context.Load(field);
                context.Load(field, f => f.SchemaXml);

                context.ExecuteQueryWithTrace();
            }

            return field;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:64,代码来源:ContentTypeFieldLinkModelHandler.cs

示例2: GetPrimaryLookupField

        protected virtual FieldLookup GetPrimaryLookupField(FieldCollection fields, DependentLookupFieldDefinition definition)
        {
            var context = fields.Context;

            Field result = null;

            if (definition.PrimaryLookupFieldId.HasGuidValue())
                result = fields.GetById(definition.PrimaryLookupFieldId.Value);

            if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldInternalName))
                result = fields.GetByInternalNameOrTitle(definition.PrimaryLookupFieldInternalName);

            if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldTitle))
                result = fields.GetByTitle(definition.PrimaryLookupFieldTitle);

            context.Load(result);
            context.ExecuteQuery();

            return context.CastTo<FieldLookup>(result);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:20,代码来源:DependentLookupFieldModelHandler.cs

示例3: Read

        private SPOField Read(FieldCollection fields)
        {
            var ctx = SPOSiteContext.CurrentSiteContext.Context;
            Field field = null;
            if (this.FieldId != Guid.Empty)
            {
                field = fields.GetById(this.FieldId);
            }
            else if (!string.IsNullOrEmpty(this.FieldNameOrTitle))
            {
                field = fields.GetByInternalNameOrTitle(this.FieldNameOrTitle);
            }
            if (field != null)
            {
                _field = field;
                ctx.Load(field);
                ctx.ExecuteQuery();

                if (field.ServerObjectIsNull.Value)
                    return null;

                return new SPOField(_field);
            }
            return null;
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:25,代码来源:SPOFieldPipeBind.cs

示例4: GetField

 internal static SPOField GetField(CmdletContext ctx, FieldCollection fields, XmlDocument schemaXmlDoc)
 {
     Guid fieldId = Guid.Parse(schemaXmlDoc.DocumentElement.GetAttribute("Id"));
     Field field = fields.GetById(fieldId);
     ctx.Load(field);
     ctx.ExecuteQuery();
     if (!field.ServerObjectIsNull.Value)
     {
         return new SPOField(field);
     }
     field = fields.GetByInternalNameOrTitle(schemaXmlDoc.DocumentElement.GetAttribute("Name"));
     ctx.Load(field);
     ctx.ExecuteQuery();
     if (!field.ServerObjectIsNull.Value)
     {
         return new SPOField(field);
     }
     return null;
 }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:19,代码来源:SPOField.cs


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