public IObservableGroup GetObservableGroup(IGroup group, string collectionName = null) { var requiredComponents = ComponentTypeLookup.GetComponentTypes(group.RequiredComponents); var excludedComponents = ComponentTypeLookup.GetComponentTypes(group.ExcludedComponents); var lookupGroup = new LookupGroup(requiredComponents, excludedComponents); var observableGroupToken = new ObservableGroupToken(lookupGroup, collectionName); if (_observableGroups.ContainsKey(observableGroupToken)) { return(_observableGroups[observableGroupToken]); } var entityMatches = GetEntitiesFor(lookupGroup, collectionName); var configuration = new ObservableGroupConfiguration { ObservableGroupToken = observableGroupToken, InitialEntities = entityMatches }; if (collectionName != null) { configuration.NotifyingCollection = _collections[collectionName]; } else { configuration.NotifyingCollection = this; } var observableGroup = ObservableGroupFactory.Create(configuration); _observableGroups.Add(observableGroupToken, observableGroup); return(_observableGroups[observableGroupToken]); }
public IObservableGroup GetObservableGroup(IGroup group, params int[] collectionIds) { var requiredComponents = ComponentTypeLookup.GetComponentTypes(group.RequiredComponents); var excludedComponents = ComponentTypeLookup.GetComponentTypes(group.ExcludedComponents); var lookupGroup = new LookupGroup(requiredComponents, excludedComponents); var observableGroupToken = new ObservableGroupToken(lookupGroup, collectionIds); if (_observableGroups.Contains(observableGroupToken)) { return(_observableGroups[observableGroupToken]); } var entityMatches = GetEntitiesFor(lookupGroup, collectionIds); var configuration = new ObservableGroupConfiguration { ObservableGroupToken = observableGroupToken, InitialEntities = entityMatches }; if (collectionIds != null && collectionIds.Length > 0) { configuration.NotifyingCollections = _collections.Where(x => collectionIds.Contains(x.Id)); } else { configuration.NotifyingCollections = new [] { this }; } var observableGroup = ObservableGroupFactory.Create(configuration); _observableGroups.Add(observableGroup); return(_observableGroups[observableGroupToken]); }
public IObservableGroup Create(ObservableGroupConfiguration arg) { return(new ObservableGroup(arg.ObservableGroupToken, arg.InitialEntities, arg.NotifyingCollection)); }