private void TestBuildCode(string classFileName, string xmlFileName, string contentTypeName) { ContentType contentType; var expectedOutput = ""; using (var inputReader = File.OpenText(@"..\..\TestFiles\" + xmlFileName + ".xml")) { contentType = new ContentTypeSerializer().Deserialize(inputReader); } using (var goldReader = File.OpenText(@"..\..\TestFiles\" + classFileName + ".cs")) { expectedOutput = goldReader.ReadToEnd(); } var configuration = new CodeGeneratorConfiguration(); configuration.TypeMappings.Add(new TypeMapping("1413afcb-d19a-4173-8e9a-68288d2a73b8", "Int32")); var typeConfig = configuration.Get(contentTypeName); typeConfig.BaseClass = "Umbraco.Core.Models.TypedModelBase"; typeConfig.Namespace = "Umbraco.CodeGen.Models"; var sb = new StringBuilder(); var writer = new StringWriter(sb); var dataTypeProvider = new TestDataTypeProvider(); var generator = new CodeGenerator(typeConfig, dataTypeProvider, new AnnotatedCodeGeneratorFactory()); generator.Generate(contentType, writer); writer.Flush(); Console.WriteLine(sb.ToString()); Assert.AreEqual(expectedOutput, sb.ToString()); }
protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName) { var config = configuration.Get(contentTypeName); config.BaseClass = "global::Umbraco.Core.Models.PublishedContent.PublishedContentModel"; }
protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName) { var config = configuration.Get(contentTypeName); config.BaseClass = "IPublishedContent"; }
protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName) { var typeConfig = configuration.Get(contentTypeName); typeConfig.BaseClass = "BaseClassWithSupport"; }