本文整理汇总了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");
}
示例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();
}
示例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;
}
示例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);
}
示例5: FavoriteColorField
public FavoriteColorField(
SPFieldCollection fields,
string typename,
string name)
: base(fields, typename, name)
{
}
示例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;
});
}
示例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'.");
}
示例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;
}
示例9: AddFieldTo
public override void AddFieldTo(SPFieldCollection fieldCollection)
{
AddFieldTo(fieldCollection, f =>
{
SPFieldMultiChoice field = (SPFieldMultiChoice)f;
field.Choices.Clear();
field.Choices.AddRange(Choices);
});
}
示例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;
}
}
示例11: AddFieldTo
public override void AddFieldTo(SPFieldCollection fieldCollection)
{
AddFieldTo(fieldCollection, f =>
{
SPFieldMultiLineText field = (SPFieldMultiLineText)f;
field.AppendOnly = AppendOnly;
field.RichText = RichText;
field.RichTextMode = RichTextMode;
});
}
示例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);
}
}
示例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));
}
}
示例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"));
}
示例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);
}
}