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); }
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)); }
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)); }
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)); }
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); }
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); }
public Concept2 SetPropertyValue(Concept2 property, PointableInstance value) { _propertyValues[property] = value; return(this); }
internal PropertyContainer SetPropertyValue(PointableInstance target, Concept2 property, Concept2 value) { return(SetPropertyValue(target, property, new ConceptInstance(value))); }
internal bool ContainsSubstitutionFor(PointableInstance container, Concept2 parameter) { var key = Tuple.Create(container, parameter); return(_propertyValues.TryGetValue(key, out var substitutions) && substitutions != null); }