public override IEnumerable <ITool> Convert(AvailableToolLink input) { if (!InstancesMap.ContainsKey(input)) { var tool = input.Tool; if (!_shiftConverter.NamedInstances.ContainsKey(input.Shift.Name)) { _shiftConverter.Convert(input.Shift); } IShift shift = _shiftConverter.InstancesMap[input.Shift]; var tools = new HashSet <ITool>(); var converted = Factory.Create(tool.Name, shift); tools.Add(converted); var instances = new Dictionary <int, IToolInstance>(); ToolTypes.Add(converted, instances); for (int i = 0; i < input.AvailableQuantity; i++) { var instance = _toolInstanceFactory.Create(converted); instances.Add(instance.ID, instance); } InstancesMap.GetOrAdd(input, tools); // TODO: this should be a toolInstance converter and a toolDefinition converter // TODO: we have skillConverter which is the definition part, and laborConverter which is the instance part NamedInstances.GetOrAdd(tool.Name, tools.First()); } return(InstancesMap[input]); }
public override ISkill Convert(ILabor input) { if (!InstancesMap.ContainsKey(input)) { var converted = Factory.Create(input.Name); InstancesMap.GetOrAdd(input, converted); NamedInstances.GetOrAdd(input.Name, converted); } return(InstancesMap[input]); }
public override IShift Convert(DataSetServices.Data.Modeling.Core.IShift input) { if (!InstancesMap.ContainsKey(input)) { var start = (int)input.StartTime.AsMinutes; var end = (int)input.EndTime.AsMinutes; var converted = Factory.Create(input.Name, start, end); NamedInstances.GetOrAdd(input.Name, converted); return(InstancesMap.GetOrAdd(input, converted)); } return(InstancesMap[input]); }