public bool TryLookupSubscriptionFactory(IReactiveMetadata metadata, string key, out SubscriptionFactoryDefinitionEntity entity) { if (metadata.SubscriptionFactories.TryGetValue(new Uri(key), out IReactiveSubscriptionFactoryDefinition subscriptionFactoryDefinition)) { var expression = _metadataRewrites.GetValue( subscriptionFactoryDefinition.Expression, e => _queryEngine.RewriteQuotedReactiveToSubscribable(e)); entity = new SubscriptionFactoryDefinitionEntity(subscriptionFactoryDefinition.Uri, expression, subscriptionFactoryDefinition.State); return(true); } entity = null; return(false); }
private void AddEntityPlaceholder(ReactiveEntityKind kind, string key) { var uri = new Uri(key); #pragma warning disable IDE0079 // Remove unnecessary suppression. #pragma warning disable CA2000 // Dispose objects before losing scope. (Entities are owned by the registry.) var added = kind switch { ReactiveEntityKind.Observable => Registry.Observables.TryAdd(key, ObservableDefinitionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.Observer => Registry.Observers.TryAdd(key, ObserverDefinitionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.Stream => Registry.Subjects.TryAdd(key, SubjectEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.StreamFactory => Registry.SubjectFactories.TryAdd(key, StreamFactoryDefinitionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.SubscriptionFactory => Registry.SubscriptionFactories.TryAdd(key, SubscriptionFactoryDefinitionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.Subscription => Registry.Subscriptions.TryAdd(key, SubscriptionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.ReliableSubscription => Registry.ReliableSubscriptions.TryAdd(key, ReliableSubscriptionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.Other => Registry.Other.TryAdd(key, OtherDefinitionEntity.CreateInvalidInstance(uri)), ReactiveEntityKind.Template => Registry.Templates.TryAdd(key, OtherDefinitionEntity.CreateInvalidInstance(uri)), _ => throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Cannot create an invalid entity '{0}' of type '{1}'.", key, kind)), }; #pragma warning restore CA2000 #pragma warning restore IDE0079 if (added) { Parent.TraceSource.Registry_AddEntityPlaceholder(Parent.Uri, kind.ToString(), key); } }