private void Register(ISessionMapElement item) { TraceFactory.Logger.Debug("Registering {0} : {1}".FormatWith(item.MapElement.ElementType, item.MapElement.Name)); item.MapElement.OnUpdateStatus += new EventHandler(PublishSessionMapElement); // Recursively iterate through all properties marked with the // [SessionMapElementCollection] attribute and register them with the publisher // so that any changes to the status for those items will be sent // out to listening clients. This will only process the first // result, but in the future if there is more than one property // it can be extended. Also wire the parent/child relationship. var property = ( from p in item.GetType().GetProperties() where Attribute.IsDefined(p, typeof(SessionMapElementCollectionAttribute), false) select p ).FirstOrDefault(); if (property != null) { foreach (var entry in (IEnumerable <ISessionMapElement>)property.GetValue(item, null)) { entry.MapElement.ParentId = item.MapElement.Id; entry.MapElement.SessionId = _sessionId; Register(entry); } } }
/// <summary> /// Registers the specified element map with this publisher. /// </summary> /// <param name="root">The root map element.</param> public void RegisterMapElements(ISessionMapElement root) { Register(root); }