Exemplo n.º 1
0
 internal PointableInstance GetPropertyValue(PointableInstance instance, Concept2 property)
 {
     if (!_propertyValues.TryGetValue(Tuple.Create(instance, property), out var result))
     {
         var conceptInstance = instance as ConceptInstance;
         result = conceptInstance?.Concept.GetPropertyValue(property);
     }
     return(result);
 }
Exemplo n.º 2
0
        internal PropertyContainer SetPropertyValue(PointableInstance target, Concept2 property, PointableInstance value)
        {
            var key = Tuple.Create(target, property);
            var newPropertyValues = new Dictionary <Tuple <PointableInstance, Concept2>, PointableInstance>(_propertyValues);

            newPropertyValues[key] = value;

            return(new PropertyContainer(newPropertyValues));
        }
Exemplo n.º 3
0
        internal bool HasParameterSubstitution(PointableInstance instance, Concept2 parameter)
        {
            var conceptInstance = instance as ConceptInstance;

            if (conceptInstance is null)
            {
                throw new NotImplementedException();
            }

            var currentValue = GetPropertyValue(instance, parameter);

            return(currentValue != conceptInstance.Concept.GetPropertyValue(parameter));
        }
Exemplo n.º 4
0
        internal PropertyContainer Import(PointableInstance instance, PropertyContainer container)
        {
            var newValues = new Dictionary <Tuple <PointableInstance, Concept2>, PointableInstance>(_propertyValues);

            foreach (var key in container._propertyValues.Keys)
            {
                //TODO recursive import !!
                if (key.Item1 == instance)
                {
                    newValues[key] = container._propertyValues[key];
                }
            }

            return(new PropertyContainer(newValues));
        }
Exemplo n.º 5
0
        internal IEnumerable <Concept2> GetProperties(PointableInstance instance)
        {
            var result = new HashSet <Concept2>();

            foreach (var key in _propertyValues.Keys)
            {
                if (key.Item1 == instance)
                {
                    result.Add(key.Item2);
                }
            }

            var conceptInstance = instance as ConceptInstance;

            if (conceptInstance != null)
            {
                result.UnionWith(conceptInstance.Concept.Properties);
            }

            return(result);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public Concept2 SetPropertyValue(Concept2 property, PointableInstance value)
 {
     _propertyValues[property] = value;
     return(this);
 }
Exemplo n.º 8
0
 internal PropertyContainer SetPropertyValue(PointableInstance target, Concept2 property, Concept2 value)
 {
     return(SetPropertyValue(target, property, new ConceptInstance(value)));
 }
Exemplo n.º 9
0
        internal bool ContainsSubstitutionFor(PointableInstance container, Concept2 parameter)
        {
            var key = Tuple.Create(container, parameter);

            return(_propertyValues.TryGetValue(key, out var substitutions) && substitutions != null);
        }