static CorrelationProperty BuildConstraintProperty(PropertyDefinition member) { var propertyType = member.PropertyType; return(new CorrelationProperty ( name: member.Name, type: CorrelationPropertyTypeReader.GetCorrelationPropertyType(propertyType) )); }
public static SagaDefinition GetSagaDefinition(Type sagaType, BuildSqlDialect sqlDialect) { if (SagaTypeHasIntermediateBaseClass(sagaType)) { throw new Exception("Saga implementations must inherit from either Saga<T> or SqlSaga<T> directly. Deep class hierarchies are not supported."); } var saga = (Saga)FormatterServices.GetUninitializedObject(sagaType); var mapper = new ConfigureHowToFindSagaWithMessage(); methodInfo.Invoke(saga, new object[] { mapper }); CorrelationProperty correlationProperty = null; if (mapper.CorrelationType != null) { correlationProperty = new CorrelationProperty( name: mapper.CorrelationProperty, type: CorrelationPropertyTypeReader.GetCorrelationPropertyType(mapper.CorrelationType)); } var transitionalCorrelationPropertyName = GetSagaMetadataProperty(sagaType, saga, "TransitionalCorrelationPropertyName", att => att.TransitionalCorrelationProperty); CorrelationProperty transitional = null; if (transitionalCorrelationPropertyName != null) { var sagaDataType = sagaType.BaseType.GetGenericArguments()[0]; var transitionalProperty = sagaDataType.GetProperty(transitionalCorrelationPropertyName, AnyInstanceMember); transitional = new CorrelationProperty(transitionalCorrelationPropertyName, CorrelationPropertyTypeReader.GetCorrelationPropertyType(transitionalProperty.PropertyType)); } var tableSuffixOverride = GetSagaMetadataProperty(sagaType, saga, "TableSuffix", att => att.TableSuffix); var tableSuffix = tableSuffixOverride ?? sagaType.Name; if (sqlDialect == BuildSqlDialect.Oracle) { tableSuffix = tableSuffix.Substring(0, Math.Min(27, tableSuffix.Length)); } return(new SagaDefinition( tableSuffix: tableSuffix, name: sagaType.FullName, correlationProperty: correlationProperty, transitionalCorrelationProperty: transitional)); }
public static SagaDefinition GetSagaDefinition(Type sagaType, BuildSqlDialect sqlDialect) { var saga = (Saga)FormatterServices.GetUninitializedObject(sagaType); var mapper = new ConfigureHowToFindSagaWithMessage(); methodInfo.Invoke(saga, new object[] { mapper }); CorrelationProperty correlationProperty = null; if (mapper.CorrelationType != null) { correlationProperty = new CorrelationProperty( name: mapper.CorrelationProperty, type: CorrelationPropertyTypeReader.GetCorrelationPropertyType(mapper.CorrelationType)); } var transitionalCorrelationPropertyName = (string)sagaType .GetProperty("TransitionalCorrelationPropertyName", AnyInstanceMember) .GetValue(saga); CorrelationProperty transitional = null; if (transitionalCorrelationPropertyName != null) { var sagaDataType = sagaType.BaseType.GetGenericArguments()[0]; var transitionalProperty = sagaDataType.GetProperty(transitionalCorrelationPropertyName, AnyInstanceMember); transitional = new CorrelationProperty(transitionalCorrelationPropertyName, CorrelationPropertyTypeReader.GetCorrelationPropertyType(transitionalProperty.PropertyType)); } var tableSuffixOverride = (string)sagaType.GetProperty("TableSuffix", AnyInstanceMember).GetValue(saga); var tableSuffix = tableSuffixOverride ?? sagaType.Name; if (sqlDialect == BuildSqlDialect.Oracle) { tableSuffix = tableSuffix.Substring(0, Math.Min(27, tableSuffix.Length)); } return(new SagaDefinition( tableSuffix: tableSuffix, name: sagaType.FullName, correlationProperty: correlationProperty, transitionalCorrelationProperty: transitional)); }