本文整理汇总了C#中SPField.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SPField.GetType方法的具体用法?C# SPField.GetType怎么用?C# SPField.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPField
的用法示例。
在下文中一共展示了SPField.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateFieldVisibility
private void UpdateFieldVisibility(SPField field, BaseFieldInfo fieldInfo)
{
field.ShowInListSettings = !fieldInfo.IsHiddenInListSettings;
field.ShowInDisplayForm = !fieldInfo.IsHiddenInDisplayForm;
field.ShowInEditForm = !fieldInfo.IsHiddenInEditForm;
field.ShowInNewForm = !fieldInfo.IsHiddenInNewForm;
// Apply Hidden here again (even through it's already set through the schema XML),
// because otherwise updates to Hidden will not work.
if (!field.CanToggleHidden)
{
bool before = field.Hidden;
// Use reflection to get around the CanToggleHidden constraint. Keep in mind that
// there may be some unintended consequenced from hiding/showing and previously
// shown/hidden field (hence the logged warning).
Type type = field.GetType();
MethodInfo mi = type.GetMethod("SetFieldBoolValue", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(field, new object[] { "CanToggleHidden", true });
field.Hidden = fieldInfo.IsHidden;
mi.Invoke(field, new object[] { "CanToggleHidden", false });
this.log.Warn(
string.Format(
CultureInfo.InvariantCulture,
"FieldHelper.EnsureField - Forced field (id={0}, name={1}) from Hidden={2} to Hidden={3} even though it should've been impossible because CanToggleHidden=false.",
field.Id,
field.InternalName,
before,
fieldInfo.IsHidden));
}
else
{
// No need to use reflection before being able to set the Hidden property
field.Hidden = fieldInfo.IsHidden;
}
}