Esempio n. 1
0
        private void StartChannelSubscriptionInfo(ChannelSubscriptionInfo info, MockIndex startIndex, bool sendChanges)
        {
            info.IsStarted = true;
            info.Query     = new ChannelDataQuery
            {
                Channel               = info.Channel as IMockGrowingObject,
                ChannelId             = info.ChannelId,
                IsStartIndexInclusive = true,
                EndIndex              = null,
            };
            info.SendChanges = sendChanges;

            info.Query.StartIndex = startIndex == null
                ? info.Query.Channel.EndIndex
                : info.Query.Channel.GetIndex(startIndex);
        }
Esempio n. 2
0
        private void RefreshChannelSubscription(ChannelSubscription subscription)
        {
            var allObjects = new Dictionary <Guid, MockObject>();

            subscription.ChannelScopeUuidByChannelUuid.Clear();
            subscription.ValidChannelIds.Clear();
            foreach (var subscriptionInfo in subscription.ChannelScopesByChannelScopeUuid.Values)
            {
                foreach (var @object in GetObjects(subscription.Version, subscriptionInfo.Context))
                {
                    allObjects[@object.Uuid] = @object;
                    if (!subscription.ChannelScopeUuidByChannelUuid.ContainsKey(@object.Uuid))
                    {
                        subscription.ChannelScopeUuidByChannelUuid[@object.Uuid] = subscriptionInfo.RequestUuid;
                        ChannelSubscriptionInfo info;
                        if (!subscription.ChannelSubscriptionsByChannelUuid.TryGetValue(@object.Uuid, out info))
                        {
                            info = new ChannelSubscriptionInfo
                            {
                                Channel          = @object,
                                ChannelId        = subscription.NextChannelId++,
                                ChannelScopeUuid = subscriptionInfo.RequestUuid,
                                IsStarted        = false,
                                SendChanges      = false,
                            };
                            if (subscription.AutoStart)
                            {
                                StartChannelSubscriptionInfo(info, null, false);
                            }
                            subscription.ChannelSubscriptionsByChannelUuid[@object.Uuid] = info;
                        }
                        subscription.ValidChannelIds[info.ChannelId] = info;
                    }
                }
            }

            RefreshSubscriptionObjects(subscription, allObjects.Values);
        }