Example #1
0
        private void VerifyPath()
        {
            if (_path.Contains("."))
            {
                VerifyPathEx(); return;
            }

            var          tDataRoot = typeof(TDataRoot);
            PropertyInfo propertyInfo;

            try{ propertyInfo = tDataRoot.GetProperty(_path, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); }
            catch (AmbiguousMatchException ex) { this.DoNothing(ex); /*TODO*/ return; }
            catch (Exception ex) { this.DoNothing(ex); throw; }
            if (propertyInfo == null)
            {
                var msg = ("ERROR: Property not found!" +
                           "\n\tPath: " + _path +
                           "\n\tRoot: " + DebugUtil.FormatTypeName(tDataRoot) +
                           //"\n\tModel: "+DebugUtil.FormatTypeName(DebugUtil.Try(()=>((IMetadata)Parent).Parent))+
                           "\n\tModel: " + DebugUtil.Try(() => DebugUtil.FormatTypeName(DebugUtil.FindStackAncestor2(typeof(IObjectVM))))
                           //"\n\tModelPath: "+ DebugUtil.Try(()=>new Json(this).GetValue("Parent.Parent.MemberPath",true))+
                           );
                var frame = DebugUtil.FindStackFrame(typeof(IObjectVM), 1);
                Debug.WriteLine("CLICK TO NAVIGATE>>\n" + frame.GetFileName() + "(" + frame.GetFileLineNumber() + "," + frame.GetFileColumnNumber() + ")");
                DebuggerːBreak(msg);
                throw new MissingMemberException(tDataRoot.FullName, _path);
            }
            if (propertyInfo.GetGetMethod() == null)
            {
                throw new MissingMemberException(tDataRoot.FullName, _path + ";get");
            }

            //check return type
            if (!propertyInfo.PropertyType.IsAssignableFrom(typeof(TData)))
            {
                throw new MemberAccessException(
                          "Incompatible property type!" +
                          "\r\n\tExpected: " + DebugUtil.FormatTypeName(typeof(TData)) +
                          "\r\n\tAvailable: " + DebugUtil.FormatTypeName(propertyInfo.PropertyType) +
                          "\r\n\tPath: " + _path +
                          (ParentVM == null?"":"\r\n\tViewmodel: " + ParentVM.MemberPath + " " + ((ObjectVM)ParentVM).DebugːGetTypeːName) +
                          "\r\n\tUniqueID: {85C102E4-4408-40F9-B198-F2F1CCDB7F55}"
                          );
            }
        }