Example #1
0
        public static bool HasSameNameAutoProperty(this ClrObject clrObject, [NotNull] FieldInfo autoPropFldInfo)
        {
            Assert.ArgumentNotNull(autoPropFldInfo, "fieldInfo");

            var expected = MemoryDiagnostics.StringUtil.ProduceAutoPropertyName(autoPropFldInfo.Name);

            return(clrObject.HasSameNameField(expected));
        }
Example #2
0
        public static string GetStringFldOrAutoProp(this ClrObject clrObject, string fieldName)
        {
            if (clrObject.HasSameNameField(fieldName))
            {
                return(clrObject.GetStringFld(fieldName));
            }

            var autoProp = MemoryDiagnostics.StringUtil.ProduceAutoPropertyName(fieldName);

            return(clrObject.GetStringFld(autoProp));
        }
        protected virtual bool CanInjectField([NotNull] FieldInfo modelField, ClrObject obj, out string violation)
        {
            violation = string.Empty;

            if (obj.Type.IsString)
            {
                return(true);
            }

            if (!obj.HasSameNameField(modelField))
            {
                violation = ViolationFormatter.NoFieldInSource(obj, modelField);
                return(false);
            }

            ClrInstanceField fld = obj.Type.GetFieldByName(modelField.Name);

            if ((fld == null) || (fld.Type == null))
            {
                violation = ViolationFormatter.NoFieldInSource(obj, modelField);
            }

            return(fld?.Type != null);
        }
Example #4
0
 public static bool HasSameNameField(this ClrObject clrObject, [NotNull] FieldInfo fieldInfo)
 {
     Assert.ArgumentNotNull(fieldInfo, "fieldInfo");
     return(clrObject.HasSameNameField(fieldInfo.Name));
 }