/// <summary> /// Get consequences of an invocation. /// </summary> /// <remarks> /// Will try to use the implementation of an interface. /// </remarks> public static IReadOnlyList <Statement> GetInvocationConsequenceStatements2(this IEnumerable <TypeDescription> types, InvocationDescription invocation) { InvocationDescription implementatedInvocation = null; // If the type is an interface, look for the first implementation of that interface and act as if that one was invoked. if (Program.Types.FirstOrDefault(invocation.ContainingType)?.Type == TypeType.Interface) { var implementation = Program.Types.First(t => t.ImplementsType(invocation.ContainingType)); implementatedInvocation = new InvocationDescription(implementation.FullName, invocation.Name); implementatedInvocation.Arguments.AddRange(invocation.Arguments); } var statements = types.GetInvokedMethod(implementatedInvocation ?? invocation) .SelectMany(m => m.Statements); var consequences = new List <Statement>(); foreach (var statement in statements) { var innerStatements = TraverseStatement(types, statement); if (innerStatements.Count > 0) { consequences.AddRange(innerStatements); } else { consequences.Add(statement); } } return(consequences); }
/// <summary> /// Returns <c>true</c> if the <paramref name="invocation"/> would result in a new message. /// </summary> public static bool IsMessageCreation(InvocationDescription invocation) { return(invocation.Name == "PublishMessageAsync" || invocation.Name == "RaiseEvent"); }