本文整理汇总了C#中EntityInfo.GetPropertyGroup方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInfo.GetPropertyGroup方法的具体用法?C# EntityInfo.GetPropertyGroup怎么用?C# EntityInfo.GetPropertyGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityInfo
的用法示例。
在下文中一共展示了EntityInfo.GetPropertyGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static EntityMemberMask Create(EntityInfo entity, string propertiesOrGroups)
{
var invalidNames = new StringList();
var mask = new EntityMemberMask(propertiesOrGroups, entity);
var props = propertiesOrGroups.SplitNames(',', ';');
foreach (var name in props) {
//first try member
if (string.IsNullOrWhiteSpace(name))
continue;
var grp = entity.GetPropertyGroup(name);
if (grp != null) {
foreach (var m in grp.Members)
mask.Set(m);
continue;
}
var member = entity.GetMember(name);
if (member != null) {
mask.Set(member);
continue;
}
//name is invalid
invalidNames.Add(name);
}
if (invalidNames.Count > 0)
Util.Throw("Properties/subgroups [{0}] not found in entity {1}.", string.Join(",", invalidNames), entity.EntityType);
return mask;
}
示例2: Apply
public override void Apply(AttributeContext context, Attribute attribute, EntityInfo entity)
{
if (string.IsNullOrWhiteSpace(this.GroupName)) {
context.Log.Error("Group name may not be empty. Entity: {0}.", entity.Name);
return;
}
var names = StringHelper.SplitNames(this.MemberNames);
foreach (var name in names) {
var member = entity.GetMember(name);
if (member == null) {
context.Log.Error("PropertyGroup '{0}', entity {1}: member {2} not found.", this.GroupName, entity.Name, name);
continue;
}
var grp = entity.GetPropertyGroup(this.GroupName, create: true);
if (!grp.Members.Contains(member))
grp.Members.Add(member);
}//foreach
}