• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SPFieldCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SPFieldCollection类属于命名空间,在下文中一共展示了SPFieldCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: TreeViewControl

        public TreeViewControl(SPFieldCollection fields,
                                   string typeName,
                                   string displayName)
            : base(fields, typeName, displayName)
        {
            try
            {
                _fields = fields;
                _typeName = typeName;
                _displayName = displayName;
                _ContextID = SPContext.Current.GetHashCode().ToString();
            }
            catch (Exception Ex)
            {

                _ContextID = NO_CONTEXT;
            }
            ReadCustomProperties();
        }
开发者ID:mdimino514,项目名称:sharepoint-treeview-column,代码行数:19,代码来源:TreeViewFieldControl.cs


示例3: TryGetField

        public SPField TryGetField(SPFieldCollection siteColumns, Guid fieldID)
        {
            siteColumns.RequireNotNull("siteColumns");
            fieldID.Require(Guid.Empty != fieldID, "fieldID");

            return siteColumns.Contains(fieldID) ? siteColumns[fieldID] : null;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:7,代码来源:FieldOperations.cs


示例4: EnsureField

        /// <summary>
        /// Ensure a field
        /// </summary>
        /// <param name="fieldCollection">The field collection</param>
        /// <param name="fieldInfo">The field info configuration</param>
        /// <returns>The internal name of the field</returns>
        public SPField EnsureField(SPFieldCollection fieldCollection, BaseFieldInfo fieldInfo)
        {
            SPList parentList = null;
            bool isListField = TryGetListFromFieldCollection(fieldCollection, out parentList);
            bool alreadyExistsAsSiteColumn = fieldCollection.Web.Site.RootWeb.Fields.TryGetFieldByStaticName(fieldInfo.InternalName) != null;

            if (fieldInfo.EnforceUniqueValues)
            {
                bool isValidTypeForUniquenessConstraint =
                    fieldInfo is IntegerFieldInfo
                    || fieldInfo is NumberFieldInfo
                    || fieldInfo is CurrencyFieldInfo
                    || fieldInfo is DateTimeFieldInfo
                    || fieldInfo is TextFieldInfo
                    || fieldInfo is UserFieldInfo
                    || fieldInfo is LookupFieldInfo
                    || fieldInfo is TaxonomyFieldInfo;

                if (!isValidTypeForUniquenessConstraint)
                {
                    string msg = "Can't set EnforceUniqueValues=TRUE on your field "
                        + fieldInfo.InternalName + " because only the following field types are support uniqueness constraints: "
                        + " Integer, Number, Currency, DateTime, Text (single line), User (not multi), Lookup (not multi) and Taxonomy (not multi).";
                    throw new NotSupportedException(msg);
                }
            }

            if (isListField && !alreadyExistsAsSiteColumn)
            {
                // By convention, we enfore creation of site column before using that field on a list
                this.InnerEnsureField(fieldCollection.Web.Site.RootWeb.Fields, fieldInfo);
            }

            return this.InnerEnsureField(fieldCollection, fieldInfo);
        }
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:41,代码来源:FieldHelper.cs


示例5: FavoriteColorField

 public FavoriteColorField(
     SPFieldCollection fields, 
     string typename, 
     string name)
     : base(fields, typename, name)
 {
 }
开发者ID:zohaib01khan,项目名称:Sharepoint-training-for-Learning,代码行数:7,代码来源:FavoriteColorFieldType.cs


示例6: AddFieldTo

        public override void AddFieldTo(SPFieldCollection fieldCollection)
        {
            AddFieldTo(fieldCollection, f =>
            {
                TaxonomyField field = (TaxonomyField)f;

                if( TermStoreGuid != System.Guid.Empty && TermSetGuid != System.Guid.Empty )
                {
                    field.SspId = TermStoreGuid;
                    field.TermSetId = TermSetGuid;
                }
                else
                {
                    TaxonomySession session = new TaxonomySession(field.ParentList.ParentWeb.Site);
                    TermStore store = session.DefaultSiteCollectionTermStore != null ? session.DefaultSiteCollectionTermStore : session.TermStores[0];
                    Group group = store.Groups[TermGroup];
                    TermSet set = group.TermSets[TermSet];

                    field.SspId = store.Id;
                    field.TermSetId = set.Id;
                }

                field.AllowMultipleValues = AllowMultipleValues;
            });
        }
开发者ID:TypesInCode,项目名称:J.SharePoint,代码行数:25,代码来源:TaxonomyFieldMetadata.cs


示例7: SetLookupToList

        /// <summary>
        /// Sets the lookup to a list.
        /// </summary>
        /// <param name="fieldCollection">The field collection.</param>
        /// <param name="fieldId">The field identifier of the lookup field.</param>
        /// <param name="lookupList">The lookup list.</param>
        /// <exception cref="System.ArgumentNullException">
        /// fieldCollection
        /// or
        /// fieldId
        /// or
        /// lookupList
        /// </exception>
        /// <exception cref="System.ArgumentException">Unable to find the lookup field.;fieldId</exception>
        public void SetLookupToList(SPFieldCollection fieldCollection, Guid fieldId, SPList lookupList)
        {
            if (fieldCollection == null)
            {
                throw new ArgumentNullException("fieldCollection");
            }

            if (fieldId == null)
            {
                throw new ArgumentNullException("fieldId");
            }

            if (lookupList == null)
            {
                throw new ArgumentNullException("lookupList");
            }

            this.logger.Info("Start method 'SetLookupToList' for field id: '{0}'", fieldId);

            // Get the field.
            SPFieldLookup lookupField = this.fieldLocator.GetFieldById(fieldCollection, fieldId) as SPFieldLookup;
            if (lookupField == null)
            {
                throw new ArgumentException("Unable to find the lookup field.", "fieldId");
            }

            // Configure the lookup field.
            this.SetLookupToList(lookupField, lookupList);

            this.logger.Info("End method 'SetLookupToList'.");
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:45,代码来源:FieldLookupHelper.cs


示例8: DataRowConversionArguments

 /// <summary>
 /// Initializes a new instance of the <see cref="SharePointListItemConversionArguments"/> class.
 /// </summary>
 /// <param name="propertyName">
 /// Name of the property.
 /// </param>
 /// <param name="propertyType">
 /// Type of the property.
 /// </param>
 /// <param name="valueKey">
 /// The value key.
 /// </param>
 /// <param name="dataRow">
 /// The data row.
 /// </param>
 /// <param name="listItemCollection">
 /// The list Item Collection.
 /// </param>
 /// <param name="fieldValues">
 /// The full dictionary of values being converted
 /// </param>
 public DataRowConversionArguments(string propertyName, Type propertyType, string valueKey, DataRow dataRow, SPFieldCollection fieldCollection, SPWeb web, IDictionary<string, object> fieldValues)
     : base(propertyName, propertyType, valueKey)
 {
     this.FieldCollection = fieldCollection;
     this.Web = web;
     this.DataRow = dataRow;
     this.FieldValues = fieldValues;
 }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:29,代码来源:DataRowConversionArguments.cs


示例9: AddFieldTo

 public override void AddFieldTo(SPFieldCollection fieldCollection)
 {
     AddFieldTo(fieldCollection, f =>
     {
         SPFieldMultiChoice field = (SPFieldMultiChoice)f;
         field.Choices.Clear();
         field.Choices.AddRange(Choices);
     });
 }
开发者ID:TypesInCode,项目名称:J.SharePoint,代码行数:9,代码来源:SPFieldMultiChoiceMetadata.cs


示例10: FromEntity

 /// <summary>
 /// Fills the values from the entity properties.
 /// </summary>
 /// <param name="sourceEntity">
 /// The source entity.
 /// </param>
 /// <param name="values">
 /// The values.
 /// </param>
 /// <param name="fieldCollection">
 /// The field Collection.
 /// </param>
 /// <param name="web">
 /// The web.
 /// </param>
 public void FromEntity(object sourceEntity, IDictionary<string, object> values, SPFieldCollection fieldCollection, SPWeb web)
 {
     foreach (var binding in this.BindingDetails.Where(x => x.BindingType == BindingType.Bidirectional || x.BindingType == BindingType.WriteOnly))
     {
         var value = binding.EntityProperty.GetValue(sourceEntity, null);
         value = binding.Converter.ConvertBack(value, this.GetConversionArguments(binding, values, fieldCollection, web));
         values[binding.ValueKey] = value;
     }
 }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:24,代码来源:EntitySchema.cs


示例11: AddFieldTo

 public override void AddFieldTo(SPFieldCollection fieldCollection)
 {
     AddFieldTo(fieldCollection, f =>
     {
         SPFieldMultiLineText field = (SPFieldMultiLineText)f;
         field.AppendOnly = AppendOnly;
         field.RichText = RichText;
         field.RichTextMode = RichTextMode;
     });
 }
开发者ID:TypesInCode,项目名称:J.SharePoint,代码行数:10,代码来源:SPFieldMultiLineMetadata.cs


示例12: GetConversionArguments

 /// <summary>
 /// Creates the conversion arguments.
 /// </summary>
 /// <param name="bindingDetail">
 /// The binding detail.
 /// </param>
 /// <param name="values">
 /// The values.
 /// </param>
 /// <param name="fieldCollection">
 /// The field Collection.
 /// </param>
 /// <param name="web">
 /// The web.
 /// </param>
 /// <returns>
 /// The conversion arguments.
 /// </returns>
 protected internal override ConversionArguments GetConversionArguments(EntityBindingDetail bindingDetail, IDictionary<string, object> values, SPFieldCollection fieldCollection, SPWeb web)
 {
     var listItemValues = values as ISharePointListItemValues;
     if (listItemValues != null)
     {
         return new SharePointListItemConversionArguments(bindingDetail.EntityProperty.Name, bindingDetail.EntityProperty.PropertyType, bindingDetail.ValueKey, listItemValues.ListItem, values);
     }
     else
     {
         return base.GetConversionArguments(bindingDetail, values, fieldCollection, web);
     }
 }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:30,代码来源:SharePointEntitySchema.cs


示例13: ModelConverters

		public ModelConverters(MetaModel model, SPFieldCollection fields)
		{
			Guard.ThrowIfArgumentNull(model, "model");
			Guard.ThrowIfArgumentNull(fields, "fields");

			Model = model;
			Converters = new Dictionary<string, IFieldConverter>();

			foreach (var metaProperty in model.MetaProperties)
			{
				var field = fields.GetField(metaProperty.SpFieldInternalName);
				Converters.Add(metaProperty.MemberName, InstantiateConverter(metaProperty, field));
			}
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:14,代码来源:ModelConverters.cs


示例14: FieldCollectionNode

        public FieldCollectionNode(Object parent, SPFieldCollection collection)
        {
            this.Text = SPMLocalization.GetString("Fields_Text");
            this.ToolTipText = SPMLocalization.GetString("Fields_ToolTip");
            this.Name = "Fields";
            this.Tag = collection;
            this.SPParent = parent;

            int index = Program.Window.Explorer.AddImage(this.ImageUrl());
            this.ImageIndex = index;
            this.SelectedImageIndex = index;

            this.Nodes.Add(new ExplorerNodeBase("Dummy"));
        }
开发者ID:lucaslra,项目名称:SPM,代码行数:14,代码来源:FieldCollectionNode.cs


示例15: ToEntity

        /// <summary>
        /// Fills the entity from the values.
        /// </summary>
        /// <param name="targetEntity">
        /// The target entity.
        /// </param>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="fieldCollection">
        /// The field Collection.
        /// </param>
        /// <param name="web">
        /// The web.
        /// </param>
        public virtual void ToEntity(object targetEntity, IDictionary<string, object> values, SPFieldCollection fieldCollection, SPWeb web)
        {
            foreach (var binding in this.BindingDetails.Where(x => x.BindingType == BindingType.Bidirectional || x.BindingType == BindingType.ReadOnly))
            {
                object value;
                if (!values.TryGetValue(binding.ValueKey, out value))
                {
                    value = null;
                }

                value = binding.Converter.Convert(value, this.GetConversionArguments(binding, values, fieldCollection, web));
                binding.EntityProperty.SetValue(targetEntity, value, null);
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:29,代码来源:EntitySchema.cs


示例16: AddField

        /// <summary>
        /// Adds a field defined in xml to a collection of fields.
        /// </summary>
        /// <param name="fieldCollection">The SPField collection.</param>
        /// <param name="fieldXml">The field XML schema.</param>
        /// <returns>
        /// A string that contains the internal name of the new field.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// fieldCollection
        /// or
        /// fieldXml
        /// </exception>
        /// <exception cref="System.FormatException">Invalid xml.</exception>
        public string AddField(SPFieldCollection fieldCollection, XElement fieldXml)
        {
            if (fieldCollection == null)
            {
                throw new ArgumentNullException("fieldCollection");
            }

            if (fieldXml == null)
            {
                throw new ArgumentNullException("fieldXml");
            }

            this._logger.Info("Start method 'AddField'");

            Guid id = Guid.Empty;
            string displayName = string.Empty;
            string internalName = string.Empty;

            // Validate the xml of the field and get its
            if (this.IsFieldXmlValid(fieldXml, out id, out displayName, out internalName))
            {
                // Check if the field already exists. Skip the creation if so.
                if (!this.FieldExists(fieldCollection, displayName, id))
                {
                    // If its a lookup we need to fix up the xml.
                    if (this.IsLookup(fieldXml))
                    {
                        fieldXml = this.FixLookupFieldXml(fieldCollection.Web, fieldXml);
                    }

                    string addedInternalName = fieldCollection.AddFieldAsXml(fieldXml.ToString(), false, SPAddFieldOptions.Default);

                    this._logger.Info("End method 'AddField'. Added field with internal name '{0}'", addedInternalName);

                    return addedInternalName;
                }
                else
                {
                    this._logger.Warn("End method 'AddField'. Field with id '{0}' and display name '{1}' was not added because it already exists in the collection.", id, displayName);
                    return string.Empty;
                }
            }
            else
            {
                string msg = string.Format(CultureInfo.InvariantCulture, "Unable to create field. Invalid xml. id: '{0}' DisplayName: '{1}' Name: '{2}'", id, displayName, internalName);
                throw new FormatException(msg);
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:62,代码来源:FieldHelper.cs


示例17: WriteValuesToFieldDefaults

        /// <summary>
        /// Updates the specified SPField definitions with new DefaultValues
        /// </summary>
        /// <param name="parentFieldCollection">The SharePoint field collection containing the fields to update.</param>
        /// <param name="defaultFieldValueInfos">The default values to be applied as the SPFields' new defaults.</param>
        public void WriteValuesToFieldDefaults(SPFieldCollection parentFieldCollection, IList<FieldValueInfo> defaultFieldValueInfos)
        {
            if (parentFieldCollection == null)
            {
                throw new ArgumentNullException("parentFieldCollection");
            }

            if (defaultFieldValueInfos == null)
            {
                throw new ArgumentNullException("defaultFieldValueInfos");
            }

            foreach (var fieldValue in defaultFieldValueInfos)
            {
                this.WriteValueToFieldDefault(parentFieldCollection, fieldValue);
            }
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:22,代码来源:FieldValueWriter.cs


示例18: GetFieldById

        /// <summary>
        /// Gets the field by identifier.
        /// Returns null if the field is not found in the collection.
        /// </summary>
        /// <param name="fieldCollection">The field collection.</param>
        /// <param name="fieldId">The field identifier.</param>
        /// <returns>The SPField.</returns>
        public SPField GetFieldById(SPFieldCollection fieldCollection, Guid fieldId)
        {
            if (fieldCollection == null)
            {
                throw new ArgumentNullException("fieldCollection");
            }

            if (fieldId == null)
            {
                throw new ArgumentNullException("fieldId");
            }

            SPField field = null;
            if (fieldCollection.Contains(fieldId))
            {
                field = fieldCollection[fieldId] as SPField;
            }

            return field;
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:27,代码来源:FieldLocator.cs


示例19: CreateLookup

 public SPFieldLookup CreateLookup(SPFieldCollection siteColumns, string fieldName, SPList lookupList, SPWeb web, bool required)
 {
     siteColumns.RequireNotNull("siteColumns");
     fieldName.RequireNotNullOrEmpty("fieldName");
     lookupList.RequireNotNull("lookupList");
     string internalFieldName;
     SPField looupField = TryGetField(siteColumns,fieldName);
     if (null == looupField)
     {
         if (null != web)
         {
             internalFieldName = siteColumns.AddLookup(fieldName, lookupList.ID, web.ID, required);
         }
         else
         {
             internalFieldName = siteColumns.AddLookup(fieldName, lookupList.ID, required);
         }
         looupField = siteColumns.GetFieldByInternalName(internalFieldName);
     }
     return looupField as SPFieldLookup;
 }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:21,代码来源:FieldOperations.cs


示例20: DeleteField

        public virtual void DeleteField(SPFieldCollection fieldCollection, Guid fieldId)
        {
            SPField field = fieldCollection[fieldId];

            if (fieldCollection.List == null)
            {
                var ctColl = fieldCollection.Web.ContentTypes;

                for (int i = 0; i < ctColl.Count; i++)
                {
                    var ct = ctColl[i];
                    if (ct.FieldLinks[field.Id] != null)
                    {
                        ct.FieldLinks.Delete(field.Id);

                        ct.Update(true);
                    }
                }
            }

            field.Delete();
        }
开发者ID:powareverb,项目名称:spgenesis,代码行数:22,代码来源:SPGENFieldStorage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SPFieldLookupValue类代码示例发布时间:2022-05-24
下一篇:
C# SPField类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap