Пример #1
0
 public void ReplicationListUpdate(ReplicationListUpdateEvent updateInfo)
 {
     ThreadPool.QueueUserWorkItem((callback) =>
     {
         try
         {
             SendData(SerializeMessagePackToFrame(updateInfo));
         }
         catch (ObjectDisposedException)
         {
         }
         catch
         {
         }
     });
 }
        public static void DispatchGenericReplicationInfo(SPClient client, ReplicationListUpdateEvent genericReplicationInfo)
        {
            var objectName = genericReplicationInfo.ObjectName;

            foreach (var ri in _replicationInfos)
            {
                if (ri.Key.Equals(client))
                {
                    continue;
                }

                if (ri.Value.Contains(objectName))
                {
                    ri.Key.ReplicationListUpdate(genericReplicationInfo);
                }
            }
        }
Пример #3
0
        private void ListUpdateEvent(ReplicationListUpdateEvent ev)
        {
            var prop = _selfHosted.GetType().GetProperties().FirstOrDefault(s =>
                                                                            s.GetCustomAttribute(typeof(SPGenericReplicationAttribute)) != null &&
                                                                            s.GetCustomAttribute <SPGenericReplicationAttribute>().ObjectName == ev.ObjectName).PropertyType;

            if (prop != null && prop.IsGenericType)
            {
                var baseTypeDefinition = prop.GenericTypeArguments[0];

                var newItems = Activator.CreateInstance(typeof(List <>).MakeGenericType(baseTypeDefinition)) as IList;
                var oldItems = Activator.CreateInstance(typeof(List <>).MakeGenericType(baseTypeDefinition)) as IList;

                if (ev.NewItems != null)
                {
                    newItems = ev.NewItems;
                    for (int i = 0; i < ev.NewItems.Count; i++)
                    {
                        newItems[i] = Activator.CreateInstance(baseTypeDefinition).GetType().ConvertProperties((Dictionary <object, object>)newItems[i]);
                    }
                }

                if (ev.OldItems != null)
                {
                    oldItems = ev.OldItems;
                    for (int i = 0; i < ev.OldItems.Count; i++)
                    {
                        oldItems[i] = Activator.CreateInstance(baseTypeDefinition).GetType().ConvertProperties((Dictionary <object, object>)oldItems[i]);
                    }
                }

                if (_activatedReplicationObjects.ContainsKey(ev.ObjectName))
                {
                    _activatedReplicationObjects[ev.ObjectName].GetType().GetMethod("UpdateReceive").Invoke(_activatedReplicationObjects[ev.ObjectName], new object[] { newItems, oldItems });
                }
            }
        }