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


C# SPFieldCollection类代码示例

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


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


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