コード例 #1
0
        internal ConceptInstance GetParentConcept(ConceptInstance instance)
        {
            foreach (var property in _propertyValues)
            {
                if (property.Value == instance)
                {
                    return(property.Key.Item1 as ConceptInstance);
                }
            }

            return(null);
        }
コード例 #2
0
        internal IEnumerable <Concept2> GetAvailableParameters(ConceptInstance instance)
        {
            var result = new List <Concept2>();

            foreach (var property in GetProperties(instance))
            {
                if (!IsParameter(property))
                {
                    continue;
                }

                if (HasParameterSubstitution(instance, property))
                {
                    continue;
                }

                result.Add(property);
            }

            return(result);
        }
コード例 #3
0
        internal bool MeetsPattern(PointableInstance instance, ConceptInstance pattern)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            var o = instance as ConceptInstance;

            if (o == null)
            {
                return(false);
            }

            //TODO something semantic and other conditionals should be refactored somewhere
            var isRootLevelMatch = o.Concept == pattern.Concept || pattern.Concept == Concept2.Something;

            if (!isRootLevelMatch)
            {
                return(false);
            }

            foreach (var property in GetProperties(pattern))
            {
                if (property == Concept2.Something)
                {
                    //placeholdered properties has to be treaded in a more complex way
                    throw new NotImplementedException();
                }

                if (!MeetsPattern(GetPropertyValue(instance, property), GetPropertyValue(pattern, property) as ConceptInstance))
                {
                    return(false);
                }
            }

            return(true);
        }