/// <summary> /// Recursively build a path of properties from a base node to the final property. /// </summary> /// <param name="type">The current object type.</param> /// <param name="path">The remaining path to parse.</param> /// <param name="propertyPath">Accumulated properties in the path so far.</param> public static void BuildPropertyPath(Type type, string path, IList <PropertyInfo> propertyPath) { if (path.Length == 0) { return; } int Index = path.IndexOf(InferenceEngine.Dot); int ThisPathIndex = (Index >= 0) ? Index : path.Length; string PropertyName = path.Substring(0, ThisPathIndex); int NextPathIndex = (Index >= 0) ? Index + 1 : path.Length; string NextPath = path.Substring(NextPathIndex); if (type.GetInterface(nameof(IOnceReference)) != null) { Type[] GenericArguments = type.GetGenericArguments(); Debug.Assert(GenericArguments.Length == 1); type = GenericArguments[0]; } PropertyInfo Property = NodeTreeHelper.GetPropertyOf(type, PropertyName); Debug.Assert(Property != null); propertyPath.Add(Property); Type NestedType = ToCompilerType(Property.PropertyType); BuildPropertyPath(NestedType, NextPath, propertyPath); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= !string.IsNullOrEmpty(PropertyName) && NodeTreeHelper.GetPropertyOf(nodeType, PropertyName) != null; Debug.Assert(IsValid); return(IsValid); }