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


C# SPFieldCollection.OfType方法代码示例

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


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

示例1: FindField

        private SPField FindField(SPFieldCollection fields, ListFieldLinkDefinition listFieldLinkModel)
        {
            if (listFieldLinkModel.FieldId.HasGuidValue())
            {

                return fields
                    .OfType<SPField>()
                    .FirstOrDefault(f => f.Id == listFieldLinkModel.FieldId.Value);
            }

            if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
            {
                return fields
                   .OfType<SPField>()
                   .FirstOrDefault(f => f.InternalName.ToUpper() == listFieldLinkModel.FieldInternalName.ToUpper());
            }

            throw new ArgumentException("FieldId or FieldInternalName should be defined");
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:19,代码来源:ListFieldLinkModelHandler.cs

示例2: HandleIncorectlyDeletedTaxonomyField

        private void HandleIncorectlyDeletedTaxonomyField(FieldDefinition fieldModel,
            SPFieldCollection fields)
        {
            var isTaxField =
                fieldModel.FieldType.ToUpper() == BuiltInFieldTypes.TaxonomyFieldType.ToUpper()
                || fieldModel.FieldType.ToUpper() == BuiltInFieldTypes.TaxonomyFieldTypeMulti.ToUpper();

            if (!isTaxField)
                return;

            var existingIndexedFieldName = fieldModel.Title.ToUpper() + "_";
            var existingIndexedField = fields.OfType<SPField>()
                .FirstOrDefault(f => f.Title.ToUpper().StartsWith(existingIndexedFieldName));

            if (existingIndexedField != null && existingIndexedField.Type == SPFieldType.Note)
                existingIndexedField.Delete();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:17,代码来源:FieldModelHandler.cs

示例3: EnsureFieldInFieldsCollection

        private SPField EnsureFieldInFieldsCollection(
            object modelHost,
            SPFieldCollection fields, FieldDefinition fieldModel)
        {
            var currentField = fields.OfType<SPField>()
                                        .FirstOrDefault(f => f.Id == fieldModel.Id);

            if (currentField == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new field");

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });

                var fieldDef = GetTargetSPFieldXmlDefinition(fieldModel);

                // special handle for taxonomy field
                // incorectly removed tax field leaves its indexed field
                // https://github.com/SubPointSolutions/spmeta2/issues/521

                HandleIncorectlyDeletedTaxonomyField(fieldModel, fields);

                var addFieldOptions = (SPAddFieldOptions)(int)fieldModel.AddFieldOptions;
                fields.AddFieldAsXml(fieldDef, fieldModel.AddToDefaultView, addFieldOptions);

                currentField = fields[fieldModel.Id];
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing field");

                currentField = fields[fieldModel.Id];

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });
            }

            return currentField;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:55,代码来源:FieldModelHandler.cs

示例4: EnsureFieldInFieldsCollection

        private SPField EnsureFieldInFieldsCollection(
            object modelHost,
            SPFieldCollection fields, FieldDefinition fieldModel)
        {
            var currentField = fields.OfType<SPField>()
                                        .FirstOrDefault(f => f.Id == fieldModel.Id);

            if (currentField == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new field");

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });

                var fieldDef = GetTargetSPFieldXmlDefinition(fieldModel);
                var addFieldOptions = (SPAddFieldOptions)(int)fieldModel.AddFieldOptions;

                fields.AddFieldAsXml(fieldDef, fieldModel.AddToDefaultView, addFieldOptions);

                currentField = fields[fieldModel.Id];
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing field");

                currentField = fields[fieldModel.Id];

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });
            }

            return currentField;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:49,代码来源:FieldModelHandler.cs

示例5: GetDependentLookupField

        protected virtual SPFieldLookup GetDependentLookupField(SPFieldCollection fields, DependentLookupFieldDefinition definition)
        {
            var targetName = definition.InternalName.ToUpper();

            return fields
                     .OfType<SPField>()
                     .FirstOrDefault(f => f.InternalName.ToUpper() == targetName) as SPFieldLookup;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:8,代码来源:DependentLookupFieldModelHandler.cs

示例6: EnsureFieldInFieldsCollection

        private SPField EnsureFieldInFieldsCollection(
            object modelHost,
            SPFieldCollection fields, FieldDefinition fieldModel)
        {
            // by ID?
            var currentField = fields.OfType<SPField>()
                                        .FirstOrDefault(f => f.Id == fieldModel.Id);

            // by internal name?
            if (currentField == null && !string.IsNullOrEmpty(fieldModel.InternalName))
            {
                TraceService.Information((int)LogEventId.CoreCalls, "Could not find field by ID, fallback on InternalName");

                currentField = fields.OfType<SPField>()
                                           .FirstOrDefault(f => String.Equals(f.InternalName, fieldModel.InternalName,
                                                                StringComparison.OrdinalIgnoreCase));
            }

            if (currentField == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new field");

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });

                var fieldDef = GetTargetSPFieldXmlDefinition(fieldModel);
                var addFieldOptions = (SPAddFieldOptions)(int)fieldModel.AddFieldOptions;

                fields.AddFieldAsXml(fieldDef, fieldModel.AddToDefaultView, addFieldOptions);

                currentField = fields[fieldModel.Id];
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing field");

                currentField = fields.OfType<SPField>()
                                        .FirstOrDefault(f => f.Id == fieldModel.Id);

                if (currentField == null && !string.IsNullOrEmpty(fieldModel.InternalName))
                {
                    TraceService.Information((int)LogEventId.CoreCalls, "Could not find existing field by ID, fallback on InternalName");

                    currentField = fields.OfType<SPField>()
                                               .FirstOrDefault(f => String.Equals(f.InternalName, fieldModel.InternalName,
                                                                    StringComparison.OrdinalIgnoreCase));
                }

                if (currentField == null)
                {
                    throw new SPMeta2Exception(
                        string.Format("Cannot find existing field neither by ID [{0}] or InternalName [{1}]. Definition:[{2}]",
                        fieldModel.Id, fieldModel.InternalName, fieldModel));
                }

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioning,
                    Object = currentField,
                    ObjectType = GetTargetFieldType(fieldModel),
                    ObjectDefinition = fieldModel,
                    ModelHost = modelHost
                });
            }

            return currentField;
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:77,代码来源:FieldModelHandler.cs


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