Ejemplo n.º 1
0
        private void AddCollection(CollectionEntry entry, ObjectMode mode, Source source)
        {
            // Client created a new collection - send create payload to server
            if (source == Source.Client)
            {
                if (this.client.IsConnected)
                {
                    Payload eventData = new CollectionOpenedPayload(entry.Name, entry.Id, entry.Type.AssemblyQualifiedName, mode, entry.CollectionType, this.client.ClientId);
                    this.client.SendPublishEvent(eventData);
                    Debug.Assert(entry.Items.Count == 0);
                }
                else
                {
                    // Client is not connected throw exception
                    throw new InvalidOperationException("Cannot Add Collection before Client is connected");
                }
            }

            // Add to internal dictionary tracking all the known collections
            this.pendingCollections[entry.Name] = entry;
        }
Ejemplo n.º 2
0
        private void OnCollectionOpened(CollectionOpenedPayload payload)
        {
            CollectionEntry entry;

            // Collection already exists locally
            if (this.pendingCollections.TryGetValue(payload.Name, out entry))
            {
                // This will occur when a client has called OpenCollection for a collection
                // We must verify that the collection the user
                // is registering for is of the same type on the server as on the client
                if (payload.Type != entry.Type.AssemblyQualifiedName)
                {
                    throw new Exception("The type of the registered collection on the client does not match with the server");
                }

                this.pendingCollections.Remove(payload.Name);
                entry.Id = payload.Id;
                this.Add(entry);
            }
            else
            {
                Debug.Assert(false, "CollectionOpened received for collection we are not aware of");
            }
        }
Ejemplo n.º 3
0
 public CollectionEntry(SharedObjectsClient client, CollectionOpenedPayload payload)
     : this(client, payload.Name, Type.GetType(payload.Type))
 {
     this.Id = payload.Id;
 }
Ejemplo n.º 4
0
 public OrderedCollectionEntry(SharedObjectsClient client, CollectionOpenedPayload payload)
     : base(client, payload)
 {
     Init();
 }