public ICommandExecution Create(ICombineToMakeCommand cmd, object targetModel, InsertOption insertOption = InsertOption.Default) { lock (oLockCachedAnswers) { CachedDropTarget proposition = new CachedDropTarget(targetModel, insertOption); //typically user might start a drag and then drag it all over the place so cache answers to avoid hammering database/loading donuts if (_cachedAnswers.ContainsKey(cmd)) { //if we already have a cached execution for the command and the target if (_cachedAnswers[cmd].ContainsKey(proposition)) { return(_cachedAnswers[cmd][proposition]);//return from cache } } else { _cachedAnswers.Add(cmd, new Dictionary <CachedDropTarget, ICommandExecution>()); //novel command } var result = CreateNoCache(cmd, targetModel, insertOption); _cachedAnswers[cmd].Add(new CachedDropTarget(targetModel, insertOption), result); return(result); } }
protected bool Equals(CachedDropTarget other) { return(Equals(Target, other.Target) && RelativeLocation == other.RelativeLocation); }