public override void ApplyOnMember(EntityModelBuilder builder) { var namesArr = StringHelper.SplitNames(this.MemberNames); foreach (var name in namesArr) { var targetMember = HostEntity.GetMember(name); if (targetMember == null) { builder.Log.Error("Member {0} referenced in DependsOn attribute on member {1}.{2} not found.", name, HostEntity.Name, HostMember.MemberName); return; } //add this member to DependentMembers array of targetMember if (targetMember.DependentMembers == null) { targetMember.DependentMembers = new EntityMemberInfo[] { HostMember } } ; else { var mList = targetMember.DependentMembers.ToList(); mList.Add(HostMember); targetMember.DependentMembers = mList.ToArray(); } } //foreach name } // method
public override void ApplyOnMember(EntityModelBuilder builder) { if (HostMember.DataType != typeof(int)) { builder.Log.Error("HashFor attribute can be used only on int properties. Entity/property: {0}.{1}.", HostEntity.Name, HostMember.MemberName); return; } _hashedMember = HostEntity.GetMember(this.PropertyName); if (_hashedMember == null) { builder.Log.Error("Property {0} referenced in HashFor attribute on property {1} not found on entity {2}.", this.PropertyName, HostMember.MemberName, HostEntity.Name); return; } if (_hashedMember.DataType != typeof(string)) { builder.Log.Error("HashFor attribute on property {0}.{1}: target property must be of string type.", HostEntity.Name, HostMember.MemberName); return; } _oldSetter = _hashedMember.SetValueRef; _hashedMember.SetValueRef = OnSettingValue; _hashingService = builder.Model.App.GetService <IHashingService>(); }
public override void ApplyOnEntity(EntityModelBuilder builder) { var names = StringHelper.SplitNames(this.MemberNames); foreach (var name in names) { var member = HostEntity.GetMember(name); if (member == null) { builder.Log.Error("PropertyGroup '{0}', entity {1}: member {2} not found.", this.GroupName, HostEntity.Name, name); return; } var grp = HostEntity.GetPropertyGroup(this.GroupName, create: true); if (!grp.Members.Contains(member)) { grp.Members.Add(member); } } //foreach }
public override void ApplyOnEntity(EntityModelBuilder builder) { if (this.MethodClass != null && this.MethodName != null) { _customMethodInfo = this.MethodClass.GetMethod(MethodName); if (_customMethodInfo == null) { builder.Log.Error("Method {0} specified as Display method for entity {1} not found in type {2}", MethodName, HostEntity.EntityType, this.MethodClass); return; } HostEntity.DisplayMethod = InvokeCustomDisplay; return; } //Check if Format provided if (string.IsNullOrEmpty(this.Format)) { builder.Log.Error("Invalid Display attribute on entity {0}. You must provide method reference or non-empty Format value.", HostEntity.EntityType); return; } //Parse Format value, build argIndexes from referenced property names StringHelper.TryParseTemplate(this.Format, out _adjustedFormat, out _propNames); //verify and build arg indexes foreach (var prop in _propNames) { //it might be dotted sequence of props; we check only first property var propSeq = prop.SplitNames('.'); var member = HostEntity.GetMember(propSeq[0]); if (member == null) { builder.Log.Error("Invalid Format expression in Display attribute on entity {0}. Property {1} not found.", HostEntity.EntityType, propSeq[0]); return; } }//foreach HostEntity.DisplayMethod = GetDisplayString; }