public T RegisterFactor <T>(string identifier) where T : Factor { // if the factor already exists, then return it var factorKey = new FactorKey(identifier, typeof(T)); SimulationNode node; ModelKey modelKey; if (!_modelLookup.TryGetValue(factorKey, out modelKey)) { // otherwise create. Note that creating the factor always creates the corresponding model var factor = _factory.CreateFactor(typeof(T), identifier, this) as T; var model = factor.Model; modelKey = new ModelKey(identifier, model.GetType()); node = AddModelToGraph(modelKey, model); node.Factor = factor; _modelLookup[factorKey] = modelKey; } else { node = _nodes[modelKey]; } _nodeStack.Peek().AddRequisite(node); return((T)node.Factor); }
public bool Matches(FactorKey model) { return model.GetType() == this.Type; }
public bool Matches(FactorKey model) { return(model.GetType() == this.Type); }