예제 #1
0
        private Type?GetEventArgumentType()
        {
            if (EventPath == null || !EventPath.IsValid)
            {
                return(null);
            }

            // Cannot rely on EventPath.GetValue() because part of the path might be null
            Type eventType = EventPath.GetPropertyType() !;

            return(eventType.IsGenericType ? eventType.GetGenericArguments()[0] : typeof(DataModelEventArgs));
        }
예제 #2
0
        private void CreateValueChangedEventIfNeeded()
        {
            Type?propertyType = EventPath?.GetPropertyType();

            if (propertyType == null)
            {
                return;
            }

            if (!typeof(IDataModelEvent).IsAssignableFrom(propertyType))
            {
                IDataModelEvent?instance = (IDataModelEvent?)Activator.CreateInstance(typeof(DataModelValueChangedEvent <>).MakeGenericType(propertyType), EventPath);
                _valueChangedEvent = instance ?? throw new ArtemisCoreException("Failed to create a DataModelValueChangedEvent for a property changed data model event");
            }
            else
            {
                _valueChangedEvent = null;
            }
        }