private Name SimplifyProperty(Name property,List<Name> ToMList)
{
if (!property.IsComposed)
return property;
var tmpList = ObjectPool<List<Name>>.GetObject();
var r = ObjectPool<List<BeliefPair>>.GetObject();
try
{
tmpList.AddRange(ToMList);
r.AddRange(internal_AskPossibleProperties(property, tmpList, new[] {new SubstitutionSet()}));
if (r.Count != 1)
{
if (r.Count == 0)
throw new Exception($"{nameof(KB)} could not find property value for {property}");
if (r.Count > 1)
throw new Exception($"{nameof(KB)} found multiple valid values for {property}");
}
return r[0].Item1;
}
finally
{
r.Clear();
ObjectPool<List<BeliefPair>>.Recycle(r);
tmpList.Clear();
ObjectPool<List<Name>>.Recycle(tmpList);
}
}