本文整理汇总了C#中SPFieldCollection.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# SPFieldCollection.GetField方法的具体用法?C# SPFieldCollection.GetField怎么用?C# SPFieldCollection.GetField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPFieldCollection
的用法示例。
在下文中一共展示了SPFieldCollection.GetField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
}
示例2: FieldExists
private bool FieldExists(SPFieldCollection fieldCollection, string displayName, Guid fieldId)
{
if (fieldCollection.Contains(fieldId))
{
// If Id is found in the collection.
this._logger.Warn("Field with id '{0}' is already in the collection.", fieldId);
return true;
}
SPField field;
try
{
// Throws argument exception if not in collection.
field = fieldCollection.GetField(displayName);
}
catch (ArgumentException)
{
return false;
}
if (field == null)
{
// Still can't find the field in the collection
return false;
}
else
{
// We found it!
this._logger.Warn("Field with display name '{0}' is already in the collection.", displayName);
return true;
}
}
示例3: TryGetField
public static SPField TryGetField(SPFieldCollection siteColumns, string fieldName)
{
siteColumns.RequireNotNull("siteColumns");
fieldName.RequireNotNullOrEmpty("fieldName");
return siteColumns.ContainsField(fieldName) ? siteColumns.GetField(fieldName) : null;
}
示例4: GetPrimaryLookupField
protected virtual SPFieldLookup GetPrimaryLookupField(SPFieldCollection fields, DependentLookupFieldDefinition definition)
{
if (definition.PrimaryLookupFieldId.HasGuidValue())
return fields[definition.PrimaryLookupFieldId.Value] as SPFieldLookup;
if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldInternalName))
return fields.GetFieldByInternalName(definition.PrimaryLookupFieldInternalName) as SPFieldLookup; ;
if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldTitle))
return fields.GetField(definition.PrimaryLookupFieldTitle) as SPFieldLookup; ;
throw new SPMeta2Exception("PrimaryLookupFieldTitle / PrimaryLookupFieldInternalName / PrimaryLookupFieldId need to be defined");
}
示例5: AddFieldTo
public void AddFieldTo(SPContentType contentType, SPFieldCollection sourceFields, SPWeb parentWeb = null)
{
if (contentType != null && !contentType.Fields.ContainsField(this))
{
SPFieldLink link = null;
if (sourceFields.ContainsField(this))
link = new SPFieldLink(sourceFields.GetField(this));
else if (parentWeb.AvailableFields.ContainsField(this))
link = new SPFieldLink(parentWeb.AvailableFields.GetField(this));
if (link != null)
{
contentType.FieldLinks.Add(link);
contentType.Update();
}
}
}