public IQueryable <SimpleEntity> Query(Parameter4 parameter) { if (parameter != null) { throw new Exception("Parameter null is expected."); } return(new SimpleEntityList { "q4" }.AsQueryable()); }
///-------------------------------------------------------------------------------- /// <summary>Interpret this node to produce code, output, or model data..</summary> /// /// <param name="interpreterType">The type of interpretation to perform.</param> /// <param name="solutionContext">The associated solution.</param> /// <param name="templateContext">The associated template.</param> /// <param name="modelContext">The associated model context.</param> ///-------------------------------------------------------------------------------- public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext) { try { string path = Parameter1.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); if (!String.IsNullOrEmpty(path)) { if (solutionContext.IsSampleMode == true) { // don't perform removal of output file data, just indicate it would be output templateContext.MessageBuilder.Append("\r\n+ "); templateContext.MessageBuilder.Append(path); templateContext.MessageBuilder.Append(": \""); templateContext.MessageBuilder.Append(Parameter2.GetStringValue(solutionContext, templateContext, modelContext, interpreterType)); templateContext.MessageBuilder.Append("\", \""); templateContext.MessageBuilder.Append(Parameter3.GetStringValue(solutionContext, templateContext, modelContext, interpreterType)); if (Parameter4 != null) { templateContext.MessageBuilder.Append("\", \""); templateContext.MessageBuilder.Append(Parameter4.GetStringValue(solutionContext, templateContext, modelContext, interpreterType)); templateContext.MessageBuilder.Append("\", \""); templateContext.MessageBuilder.Append(Parameter5.GetStringValue(solutionContext, templateContext, modelContext, interpreterType)); } templateContext.MessageBuilder.Append("\""); } else if (solutionContext.LoggedErrors.Count == 0) { if (File.Exists(path) == true) { string text = FileHelper.GetText(path); if (Parameter4 != null) { // remove text bounded by begin and end tags string beginTag = Parameter2.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); string endTag = Parameter3.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); string matchingText = Parameter4.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); string insertText = Parameter5.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); int beginIndex = text.IndexOf(beginTag); int previousIndex = -1; while (beginIndex >= 0 && beginIndex != previousIndex) { previousIndex = beginIndex; int endIndex = text.IndexOf(endTag, beginIndex + 1); if (endIndex < 0) { break; } int matchingIndex = text.IndexOf(matchingText, beginIndex); if (matchingIndex < endIndex && matchingIndex + matchingText.Length <= endIndex) { text = text.Substring(0, beginIndex) + insertText + text.Substring(beginIndex); FileHelper.ReplaceFile(path, text); break; } beginIndex = text.IndexOf(beginTag, beginIndex + 1); } } else { // remove text matching input match text string matchingText = Parameter2.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); string insertText = Parameter3.GetStringValue(solutionContext, templateContext, modelContext, interpreterType); int index = text.IndexOf(matchingText); if (index >= 0) { text = text.Substring(0, index) + insertText + text.Substring(index); FileHelper.ReplaceFile(path, text); } } } } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { LogException(solutionContext, templateContext, modelContext, ex, interpreterType); } }