private static void TestGeneratedXml(string classFileName, string xmlFileName, string contentTypeName, ParserFactory factory)
        {
            ContentType contentType;
            string expectedOutput;

            using (var goldReader = File.OpenText(@"..\..\TestFiles\" + xmlFileName + ".xml"))
            {
                expectedOutput = goldReader.ReadToEnd();
            }

            var contentTypeConfig = new CodeGeneratorConfiguration().Get(contentTypeName);
            contentTypeConfig.BaseClass = "Umbraco.Core.Models.TypedModelBase";

            using (var inputReader = File.OpenText(@"..\..\TestFiles\" + classFileName + ".cs"))
            {
                var codeParser = new CodeParser(contentTypeConfig, TestDataTypeProvider.All, factory);
                contentType = codeParser.Parse(inputReader).Single();
            }

            var serializer = new ContentTypeSerializer();
            var xml = serializer.Serialize(contentType);

            Console.WriteLine(xml);

            Assert.AreEqual(expectedOutput, xml);
        }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Parser = new CommonInfoParser(Configuration);
     ContentType = new MediaType();
     Info = ContentType.Info;
 }
예제 #3
0
 public static void SaveConfiguration(CodeGeneratorConfiguration newConfiguration)
 {
     var configurationProvider =
         new CodeGeneratorConfigurationFileProvider(HttpContext.Current.Server.MapPath("~/config/CodeGen.config"));
     configurationProvider.SaveConfiguration(newConfiguration);
     LoadConfiguration();
 }
        public void SetUp()
        {
            Configuration = new CodeGeneratorConfiguration().MediaTypes;
            dataTypeConfiguration = TestDataTypeProvider.All;

            Parser = new PropertyParser(Configuration, dataTypeConfiguration);
        }
		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());
		}
 public void SetUp()
 {
     Generator = new StructureGenerator(Configuration);
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate = Type = new CodeTypeDeclaration();
     ContentType = new MediaType();
 }
 public void SetUp()
 {
     Generator = new StructureGenerator(Configuration);
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     attribute = new CodeAttributeDeclaration("MediaType");
     contentType = new MediaType();
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Generator = new CommonInfoGenerator(Configuration);
     ContentType = new MediaType { Info = { Alias = "anEntity" } };
     Candidate = Type = new CodeTypeDeclaration();
     info = ContentType.Info;
 }
	    public void SaveConfiguration(CodeGeneratorConfiguration configuration)
	    {
	        using (var writer = File.CreateText(path))
	        {
                var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { OmitXmlDeclaration = true, Encoding = Encoding.UTF8, Indent = true });
                CodeGeneratorConfigurationProvider.SerializeConfiguration(configuration, xmlWriter);
	        }
	    }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate = Type = new CodeTypeDeclaration();
     generator = new DocumentTypeInfoGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "aClass" } };
     info = (DocumentTypeInfo)documentType.Info;
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Configuration.Namespace = "MyWeb.Models";
     ContentType = new MediaType();
     Generator = new NamespaceGenerator(Configuration);
     compileUnit = new CodeCompileUnit();
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Parser = new DocumentTypeInfoParser(Configuration);
     ContentType = new DocumentType();
     Info = ContentType.Info;
     typedInfo = (DocumentTypeInfo) Info;
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate = Type = new CodeTypeDeclaration();
     Generator = new EntityDescriptionGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "anEntity" } };
     EntityDescription = documentType.Info;
 }
예제 #14
0
        public static void SerializeConfiguration(CodeGeneratorConfiguration newConfiguration, XmlWriter writer)
        {
            var serializer = new XmlSerializer(typeof(CodeGeneratorConfiguration), new XmlRootAttribute("CodeGenerator")
            {
                Namespace = ""
            });

            serializer.Serialize(writer, newConfiguration, new XmlSerializerNamespaces(new[] { new XmlQualifiedName("", "") }));
            writer.Flush();
        }
 public void SaveConfiguration(CodeGeneratorConfiguration configuration)
 {
     using (var writer = File.CreateText(path))
     {
         var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings {
             OmitXmlDeclaration = true, Encoding = Encoding.UTF8, Indent = true
         });
         CodeGeneratorConfigurationProvider.SerializeConfiguration(configuration, xmlWriter);
     }
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     attribute = new CodeAttributeDeclaration("DocumentType");
     generator = new DocumentTypeInfoGenerator(Configuration);
     documentType = new DocumentType
     {
         Info = info = new DocumentTypeInfo {Alias = "aClass"}
     };
 }
 public void SetUp()
 {
     codeGenConfig = CodeGeneratorConfiguration.Create();
     Configuration = codeGenConfig.MediaTypes;
     Generator = new PropertyInfoGenerator(
         Configuration, 
         TestDataTypeProvider.All
     );
     attribute = new CodeAttributeDeclaration();
     property = new GenericProperty{Alias="anEntity"};
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Generator = new ClassGenerator(
         Configuration,
         new EntityDescriptionGenerator(Configuration)
         );
     ContentType = new MediaType { Info = { Alias = "anEntity" } };
     EntityDescription = info = ContentType.Info;
     ns = new CodeNamespace("ANamespace");
 }
 public void SetUp()
 {
     codeGenConfig = CodeGeneratorConfiguration.Create();
     Configuration = codeGenConfig.MediaTypes;
     Generator = new PropertyInfoGenerator(
         Configuration, 
         TestDataTypeProvider.All,
         new EntityDescriptionGenerator(Configuration)
     );
     Candidate = codeProperty = new CodeMemberProperty();
     property = new GenericProperty{Alias="anEntity"};
 }
 public void SetUp()
 {
     codeGenConfig = CodeGeneratorConfiguration.Create();
     Configuration = codeGenConfig.DocumentTypes;
     Generator = new InterfacePropertyDeclarationGenerator(
         Configuration,
         TestDataTypeProvider.All,
         new EntityDescriptionGenerator(Configuration)
     );
     Candidate = codeProperty = new CodeMemberProperty();
     property = new GenericProperty { Alias = "aProperty" };
 }
예제 #21
0
 public ModelGenerator(
     CodeGeneratorConfiguration configuration, 
     CodeGeneratorFactory generatorFactory, 
     CodeGeneratorFactory interfaceGeneratorFactory,
     UmbracoDataTypesProvider dataTypeProvider, 
     IDictionary<string, string> paths)
 {
     this.configuration = configuration;
     this.generatorFactory = generatorFactory;
     this.interfaceGeneratorFactory = interfaceGeneratorFactory;
     this.dataTypeProvider = dataTypeProvider;
     this.paths = paths;
 }
        public static CodeGeneratorConfiguration Create()
        {
            var configuration = new CodeGeneratorConfiguration
            {
                TypeMappings = new TypeMappings()
            };

            configuration.configs = new Dictionary <string, ContentTypeConfiguration>
            {
                { Keys.DocumentType, new ContentTypeConfiguration(configuration, Keys.DocumentType) },
                { Keys.MediaType, new ContentTypeConfiguration(configuration, Keys.MediaType) },
            };
            return(configuration);
        }
예제 #23
0
		public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
		{
			var uSyncConfigurationProvider = new USyncConfigurationProvider(HttpContext.Current.Server.MapPath("~/config/uSyncSettings.config"), new HttpContextPathResolver());
			var configurationProvider = new CodeGeneratorConfigurationFileProvider(HttpContext.Current.Server.MapPath("~/config/CodeGen.config"));

			uSyncConfiguration = uSyncConfigurationProvider.GetConfiguration();
			
			dataTypesProvider = new USyncDataTypeProvider(uSyncConfiguration.USyncFolder);
	
			dataTypes = dataTypesProvider.GetDataTypes();
			configuration = configurationProvider.GetConfiguration();

			paths.Add("DocumentType", HttpContext.Current.Server.MapPath(configuration.DocumentTypes.ModelPath));
			paths.Add("MediaType", HttpContext.Current.Server.MapPath(configuration.MediaTypes.ModelPath));

			XmlDoc.Saved += OnDocumentTypeSaved;

			if (configuration.DocumentTypes.GenerateXml)
				GenerateXml(configuration.DocumentTypes);
			if (configuration.MediaTypes.GenerateXml)
				GenerateXml(configuration.MediaTypes);
		}
	    public ContentTypeConfiguration(CodeGeneratorConfiguration config, string contentTypeName)
	    {
	        ContentTypeName = contentTypeName;
	        this.config = config;
	    }
		public CodeGeneratorConfiguration GetConfiguration()
		{
		    return configuration ?? (configuration = LoadConfiguration());
		}
 protected virtual void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName)
 {
     
 }
예제 #27
0
        public void Parse_Definition_WhenMissingOrUnknown_AndDefaultIsMissing_Throws()
        {
            codeGenConfig = new CodeGeneratorConfiguration();
            codeGenConfig.DefaultDefinitionId = "";
            Configuration = codeGenConfig.MediaTypes;
            Parser = new PropertyParser(Configuration, dataTypeConfiguration);

            ParseProperty(PureProperty);
        }
 protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName)
 {
     var typeConfig = configuration.Get(contentTypeName);
     typeConfig.BaseClass = "BaseClassWithSupport";
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().DocumentTypes;
     spy1 = new SpyGenerator();
     spy2 = new SpyGenerator();
 }
 public static void SerializeConfiguration(CodeGeneratorConfiguration newConfiguration, XmlWriter writer)
 {
     var serializer = new XmlSerializer(typeof(CodeGeneratorConfiguration), new XmlRootAttribute("CodeGenerator") {Namespace=""});
     serializer.Serialize(writer, newConfiguration, new XmlSerializerNamespaces(new[] { new XmlQualifiedName("", "") }));
     writer.Flush();
 }
 public CodeGeneratorConfiguration Post(CodeGeneratorConfiguration configuration)
 {
     Integration.Configuration.SaveConfiguration(configuration);
     return Get();
 }
 protected override void OnConfiguring(CodeGeneratorConfiguration configuration, string contentTypeName)
 {
     var config = configuration.Get(contentTypeName);
     config.BaseClass = "global::Umbraco.Core.Models.PublishedContent.PublishedContentModel";
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Parser = new StructureParser(Configuration);
     ContentType = new MediaType();
 }
예제 #34
0
 public ContentTypeConfiguration(CodeGeneratorConfiguration config, string contentTypeName)
 {
     ContentTypeName = contentTypeName;
     this.config     = config;
 }
예제 #35
0
 public CodeGeneratorConfiguration GetConfiguration()
 {
     return(configuration ?? (configuration = LoadConfiguration()));
 }