コード例 #1
0
		private static void TestBuildCode(string fileName, string contentTypeName)
		{
		    ContentType contentType;
			var expectedOutput = "";
			using (var inputReader = File.OpenText(@"..\..\TestFiles\" + fileName + ".xml"))
			{
                contentType = new ContentTypeSerializer().Deserialize(inputReader);
            }
            using (var goldReader = File.OpenText(@"..\..\TestFiles\" + fileName + ".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 = "DocumentTypeBase";
		    typeConfig.Namespace = "Umbraco.CodeGen.Models";

		    var sb = new StringBuilder();
			var writer = new StringWriter(sb);

		    var factory = new DefaultCodeGeneratorFactory();
		    var dataTypeProvider = new TestDataTypeProvider();
		    var generator = new CodeGenerator(typeConfig, dataTypeProvider, factory);
		    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 typeConfig = configuration.Get(contentTypeName);
     typeConfig.BaseClass = "BaseClassWithSupport";
 }
コード例 #4
0
 protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName)
 {
     var config = configuration.Get(contentTypeName);
     config.BaseClass = "IPublishedContent";
 }