/// <summary> /// Registers the object creation. /// </summary> /// <param name="newObject">The new object.</param> /// <param name="createDateTime">The create date time.</param> /// <param name="eventId">The event id.</param> internal void RegisterObjectCreation(object newObject, DateTime createDateTime, long eventId) { if (newObject == null) { throw new ArgumentNullException("newObject"); } if (!isMaintenanceObject(newObject) && !Collector.IsNotForProtocol(newObject.GetType())) { var newEvent = new ProtocolEvent { Target = newObject, ProtocolEventType = ProtocolEventType.ObjectCreated, EventDateTime = createDateTime, EventId = eventId }; RegisterProtocolEvent(newEvent); // load initial values for brand new object trackedObjects.Refresh(newObject); } }
/// <summary> /// Registers the protocol event. /// </summary> /// <param name="protocolEvent">The protocol event.</param> public void RegisterProtocolEvent(ProtocolEvent protocolEvent) { // prevent event registration at loading and inside registered method if (Collector.ProtocolService.IsSessionInMethod(Session) || Collector.ProtocolService.LoadService.IsLoading) { return; } if (protocolEvent.Target != null) { if (Collector.IsNotForProtocol(protocolEvent.Target.GetType())) { return; } if (!string.IsNullOrEmpty(protocolEvent.PropertyName) && Collector.IsNotForProtocol(protocolEvent.Target.GetType(), protocolEvent.PropertyName)) { return; } } sessionEvents.ProtocolEvents.Add(protocolEvent); }
/// <summary> /// Determines whether the specified property is maintenance. /// </summary> /// <param name="target">The target.</param> /// <param name="propertyName">Name of the property.</param> /// <returns> /// <c>true</c> if property is maintenance; otherwise, <c>false</c>. /// </returns> private bool isMaintenanceProperty(object target, string propertyName) { var classInfo = Session.GetClassInfo(target); var propInfo = classInfo.FindMember(propertyName); return(propInfo == null || (propInfo is ServiceField) || propInfo.IsReadOnly || propInfo.Owner.ClassType.IsAssignableFrom(typeof(XPBaseObject)) || Collector.IsNotForProtocol(classInfo.ClassType) || Collector.IsNotForProtocol(classInfo.ClassType, propertyName)); }
/// <summary> /// Determines whether the specified object is maintenance. /// </summary> /// <param name="source">The source.</param> /// <returns> /// <c>true</c> if object is maintenance; otherwise, <c>false</c>. /// </returns> private bool isMaintenanceObject(object source) { var classInfo = Session.GetClassInfo(source); var result = classInfo == null; if (!result) { result = !classInfo.IsPersistent || classInfo.BaseClass.ClassType == typeof(XPBaseObject) || Collector.IsNotForProtocol(classInfo.ClassType) || (source is IntermediateObject); } return(result); }