Ejemplo n.º 1
0
        public static void RefTextNamingConvention(IModelInspector modelInspector, PropertyPath member, IPropertyMapper map)
        {
            var property = member.LocalMember as PropertyInfo;

            if (property.Name == "RefText")
            {
                var props       = member.GetContainerEntity(modelInspector).GetProperties();
                var refTextProp = props.Where(p => Attribute.IsDefined(p, typeof(RefTextAttribute), true));
                if (refTextProp.Count() == 1)
                {
                    map.Formula(refTextProp.First().Name);
                }
                else
                {
                    string s          = "";
                    var    signatures = props.Where(
                        p => Attribute.IsDefined(p, typeof(DomainSignatureAttribute), true) && p.PropertyType == typeof(String));
                    foreach (var prop in signatures)
                    {
                        s += prop.Name + "+'-'+";
                    }
                    //if (s == "") throw new NetArchException("Must define RefText, or DomainSignature on string props for a DomainObject class:" + member.GetContainerEntity(modelInspector).Name);
                    if (s == "")
                    {
                        map.Formula("'not defined'");
                    }
                    else
                    {
                        map.Formula(s.Remove(s.Length - 5));
                    }
                }
            }
        }