public static Relationship BuildHasA(EntityType type, Metadata with) { return new Relationship("has a", type) { With = with }; }
public static void DumpToFile(Metadata data) { var sb = new StringBuilder(); sb.AppendFormat("a '{0}' named '{1}' ", data.EntityType.Name, data.Name); foreach (var rel in data.Relationships) { sb.AppendLine(); sb.AppendFormat(" '{0}' '{1}' '{2}' is a '{3}'", rel.Name, rel.EntityType.Name, rel.With.Name, rel.With.EntityType.Name); foreach (var r in rel.With.Relationships) { sb.AppendLine(); sb.AppendFormat(" '{0}' '{1}' '{2}' '{3}'", r.Name, r.EntityType.Name, r.With.Name, r.With.EntityType.Name); } } File.WriteAllText("{0}.model.txt".FormatWith(data.Name),sb.ToString()); }
public static void DumpToHtml(string template, Metadata model) { var viewFolder = new FileSystemViewFolder("."); var engine = new SparkViewEngine() { DefaultPageBaseType = typeof (MessageView).FullName, ViewFolder = viewFolder }; string templateResult = ProcessViewTemplate(engine, template, model); if (!Directory.Exists("output")) Directory.CreateDirectory("output"); File.WriteAllText(".\\output\\{0}.model.html".FormatWith(model.Name), templateResult); }
static string ProcessViewTemplate(SparkViewEngine engine, string templateName, Metadata model) { var view = (MessageView)engine.CreateInstance( new SparkViewDescriptor() .AddTemplate(templateName)); view.Model = model; var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) { view.RenderView(writer); } return sb.ToString(); }
public static void View(Metadata data) { Console.WriteLine("a '{0}' named '{1}' ", data.EntityType.Name, data.Name); foreach (var rel in data.Relationships) { Console.WriteLine(" '{0}' '{1}' '{2}' is a '{3}'", rel.Name,rel.EntityType.Name, rel.With.Name, rel.With.EntityType.Name); foreach (var r in rel.With.Relationships) { Console.WriteLine(" '{0}' '{1}' '{2}' '{3}'", r.Name, r.EntityType.Name, r.With.Name, r.With.EntityType.Name); } } }
static Metadata() { Root = new Metadata("root", new EntityType("null")); }