public static void WriteRelationships(TopicRequest request) { var @ns = Path.GetFileName(request.RootDirectory); var className = request.TopicName + "TopicRegistry"; var writer = new StringWriter(); writer.WriteLine("namespace {0}", @ns); writer.WriteLine("{"); writer.WriteLine(" public class {0} : {1}", className, typeof(TopicRegistry).FullName); writer.WriteLine(" {"); writer.WriteLine(" public {0}()", className); writer.WriteLine(" {"); writeRelationships(writer, request); writer.WriteLine(" }"); writer.WriteLine(" }"); writer.WriteLine("}"); var path = request.RootDirectory.AppendPath(className + ".cs"); Console.WriteLine("Writing the topic registry to " + path); new FileSystem().WriteStringToFile(path, writer.ToString()); }
public void SetUp() { document = new XmlDocument(); document.Load("Topics.xml"); var parser = new TopicParser(); theTop = parser.Parse(theRootDirectory, document); }
public TopicRequest AddTopic(XmlElement element) { var request = new TopicRequest { Title = element.GetAttribute("title"), Namespace = CurrentNamespace, RootDirectory = _directory, TopicName = element.GetAttribute("name") }; if (_topics.Any()) { _topics.Peek().Children.Add(request); } return(request); }
private static void writeRelationships(StringWriter writer, TopicRequest request) { if (!request.Children.Any()) { return; } request.Children.Each(child => { writer.WriteLine(" For<{0}>().Append<{1}>();", request.FullTopicClassName, child.FullTopicClassName); }); writer.WriteLine(); request.Children.Each(child => { writeRelationships(writer, child); }); }
public void PushTopic(TopicRequest request) { _topics.Push(request); }
public TopicRequest AddTopic(XmlElement element) { var request = new TopicRequest { Title = element.GetAttribute("title"), Namespace = CurrentNamespace, RootDirectory = _directory, TopicName = element.GetAttribute("name") }; if (_topics.Any()) { _topics.Peek().Children.Add(request); } return request; }
private void writeRequest(TopicRequest request) { request.WriteFiles(); request.Children.Each(writeRequest); }