/// <summary>Determines whether this instance can execute the specified context.</summary> /// <param name="context">The context.</param> /// <param name="parameters">The parameters.</param> /// <returns><c>true</c> if this instance can execute the specified context; otherwise, <c>false</c>.</returns> public override bool CanExecute(DataContext context, Dictionary<string, string> parameters) { var statement = context.GetPreviousStatement(); if (statement == null) { return false; } return context.GetIterator(parameters, statement); }
/// <summary>Gets the model.</summary> /// <param name="context">The context.</param> /// <returns>Returns the model.</returns> private Model GetModel(DataContext context) { var treeNode = context.TreeNode; if (treeNode == null) { return null; } var statement = context.GetPreviousStatement() as IDeclarationStatement; if (statement == null) { return null; } foreach (var variableDeclaration in statement.VariableDeclarations) { if (!this.IsEnumerable(variableDeclaration.Type)) { continue; } var typeName = variableDeclaration.Type.GetLongPresentableName(CSharpLanguage.Instance); if (typeName == "string" || typeName == "System.String") { continue; } return new Model { VariableName = variableDeclaration.DeclaredName, TypeName = typeName }; } return null; }