private void GrabDirectives() { log.AddEntry("Searching for directives..."); Regex ex = new Regex(REGEXP_DIRECTIVE, (RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)); bool usesSchemaExplorer = false; bool hasDatabaseProperty = false; int currentStartIndex = 0; string tagname, tmp; CstProperty p; while(currentStartIndex >= 0) { Match match = ex.Match(cstText, currentStartIndex); if (match.Success) { log.AddEntry("--> Found match: {0}", match.Value.ToString()); tagname = this.PullCapturedGroup(match, CstParser.TAG_NAME).ToLower(); switch (tagname) { case "codetemplate": //Language, TargetLanguage, Description, Inherits, Src, Debug template.Language = this.PullCapturedAttribute(match, "Language"); template.TargetLanguage = this.PullCapturedAttribute(match, "TargetLanguage"); template.Description = this.PullCapturedAttribute(match, "Description"); template.Inherits = this.PullCapturedAttribute(match, "Inherits"); template.Src = this.PullCapturedAttribute(match, "Src"); tmp = this.PullCapturedAttribute(match, "Debug"); if (tmp != string.Empty) template.Debug = Convert.ToBoolean(tmp); break; case "property": //Name, Type, Default, Category, Description, Optional p = new CstProperty(); p.Name = this.PullCapturedAttribute(match, "Name"); p.Type = this.PullCapturedAttribute(match, "Type"); p.DefaultValue = this.PullCapturedAttribute(match, "Default"); p.Category = this.PullCapturedAttribute(match, "Category"); p.Description = this.PullCapturedAttribute(match, "Description"); tmp = this.PullCapturedAttribute(match, "Optional"); if (tmp != string.Empty) p.Optional = Convert.ToBoolean(tmp); if (p.Type.StartsWith("SchemaExplorer")) usesSchemaExplorer = true; if (p.Type == "SchemaExplorer.DatabaseSchema") hasDatabaseProperty = true; template.Properties.Add(p); break; case "assembly": //Name tmp = this.PullCapturedAttribute(match, "Name"); template.Assemblies.Add(tmp); break; case "import": //NameSpace tmp = this.PullCapturedAttribute(match, "NameSpace"); template.NameSpaces.Add(tmp); break; } cstText = cstText.Remove(match.Index, match.Length); } else { currentStartIndex = -1; } } if (usesSchemaExplorer && !hasDatabaseProperty) { p = new CstProperty(); p.Name = "Database"; p.Type = "SchemaExplorer.DatabaseSchema"; p.Category = "Context"; p.Description = "Select the Database to use for this template."; p.Optional = false; template.Properties.Insert(0, p); } }
protected string BuildInputProperty(CstProperty prop) { return PropertyText.Replace("§NAME§", prop.Name).Replace("§TYPE§", prop.Type); }