예제 #1
0
        private static (int Level, bool ConcreteParent) GetNestingDepth(ConceptType conceptType)
        {
            int  level = 0;
            bool parentIsConcreteConceptType = true;

            var processed = new HashSet <ConceptType>();

            while (true)
            {
                var parentProperty = GenericParser.GetParentProperty(conceptType.Members);
                if (parentProperty == null)
                {
                    break;
                }
                level += 1;
                if (parentProperty.ConceptType == null) // For example, IConceptInfo.
                {
                    parentIsConcreteConceptType = false;
                    break;
                }

                processed.Add(conceptType);
                if (processed.Contains(parentProperty.ConceptType))
                {
                    break; // Avoid infinite loop when analyzing recursive concepts.
                }
                conceptType = parentProperty.ConceptType;
            }

            return(level, parentIsConcreteConceptType);
        }
예제 #2
0
 public GenericParser(ConceptType concept)
 {
     _conceptType = concept;
 }
 public ConceptSyntaxNode(ConceptType concept)
 {
     Concept    = concept;
     Parameters = new object[concept.Members.Count];
 }
예제 #4
0
 /// <summary>
 /// Determines whether an instance of a specified concept type can be referenced by a base property of the current concept type.
 /// </summary>
 /// <remarks>
 /// Before calling this method, check if the base property has <see cref="ConceptMemberSyntax.ConceptType"/> set,
 /// to avoid null reference exception.
 /// In case of the null value, consider including the base properties with <see cref="ConceptMemberBase.IsConceptInfoInterface"/> set,
 /// because any derived concept type can also be assigned to the base property of type <see cref="IConceptInfo"/>.
 /// </remarks>
 public bool IsAssignableFrom(ConceptType derivedConceptType)
 {
     return(derivedConceptType == this || derivedConceptType.BaseTypes.Contains(this));
 }