public static ActivityDelegateMetadata GetMetadata(Type type) { ActivityDelegateMetadata metadata = new ActivityDelegateMetadata(); PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { if (property.PropertyType.IsGenericType) { ActivityDelegateArgumentMetadata argument = null; if (property.PropertyType.GetGenericTypeDefinition() == typeof(DelegateInArgument <>)) { argument = new ActivityDelegateArgumentMetadata(); argument.Direction = ActivityDelegateArgumentDirection.In; } else if (property.PropertyType.GetGenericTypeDefinition() == typeof(DelegateOutArgument <>)) { argument = new ActivityDelegateArgumentMetadata(); argument.Direction = ActivityDelegateArgumentDirection.Out; } if (argument != null) { argument.Name = property.Name; argument.Type = property.PropertyType.GetGenericArguments()[0]; metadata.Add(argument); } } } return(metadata); }
private static DelegateArgument CreateDelegateArgument(ActivityDelegateArgumentMetadata argument) { DelegateArgument delegateArgument = null; if (argument.Direction == ActivityDelegateArgumentDirection.In) { delegateArgument = Activator.CreateInstance(typeof(DelegateInArgument <>).MakeGenericType(argument.Type)) as DelegateArgument; } else { delegateArgument = Activator.CreateInstance(typeof(DelegateOutArgument <>).MakeGenericType(argument.Type)) as DelegateArgument; } delegateArgument.Name = argument.Name; return(delegateArgument); }