コード例 #1
0
 public PropertyInfoGenerator(
     ContentTypeConfiguration config,
     IList<DataTypeDefinition> dataTypes,
     params CodeGeneratorBase[] memberGenerators
     ) : base(config, dataTypes, memberGenerators)
 {
 }
コード例 #2
0
 public CompositeCodeGenerator(
     ContentTypeConfiguration config,
     params CodeGeneratorBase[] generators
 ) : base(config)
 {
     this.generators = generators;
 }
コード例 #3
0
 public PropertiesParser(
     ContentTypeConfiguration configuration,
     ContentTypeCodeParserBase propertyParser
     ) : base(configuration)
 {
     this.propertyParser = propertyParser;
 }
コード例 #4
0
 public NamespaceGenerator(
     ContentTypeConfiguration config,
     params CodeGeneratorBase[] memberGenerators
     ) : base(config)
 {
     this.memberGenerators = memberGenerators;
 }
コード例 #5
0
		private void WriteDocuments(
			ContentTypeConfiguration contentTypeConfiguration,
			IEnumerable<XDocument> documents, 
			string path, 
			string baseClass
			)
		{
			var contentTypeName = contentTypeConfiguration.ContentTypeName;
			var docsAtLevel = documents.Where(doc => doc.Element(contentTypeName).Element("Info").Element("Master").Value == baseClass);
			foreach (var doc in docsAtLevel)
			{
				var alias = doc.Element(contentTypeName).Element("Info").Element("Alias").Value;
				var directoryPath = Path.Combine(path, alias);
				if (!Directory.Exists(directoryPath))
					Directory.CreateDirectory(directoryPath);
				var defPath = Path.Combine(directoryPath, "def.config");

				if (configuration.OverwriteReadOnly && File.Exists(defPath))
					File.SetAttributes(defPath, File.GetAttributes(defPath) & ~FileAttributes.ReadOnly);

				doc.Save(defPath);

				WriteDocuments(contentTypeConfiguration, documents, directoryPath, alias);
			}
		}
コード例 #6
0
 public ClassGenerator(
     ContentTypeConfiguration config, 
     params CodeGeneratorBase[] memberGenerators
     )
     : base(config, memberGenerators)
 {
 }
コード例 #7
0
 public PropertyInfoGenerator(
     ContentTypeConfiguration config,
     IList<DataTypeDefinition> dataTypes
     ) : base(config)
 {
     this.dataTypes = dataTypes;
 }
コード例 #8
0
 public PropertiesGenerator(
     ContentTypeConfiguration config,
     params CodeGeneratorBase[] propertyGenerators
     ) : base(config)
 {
     this.propertyGenerators = propertyGenerators;
 }
コード例 #9
0
 protected ContentTypeCodeParser(
     ContentTypeConfiguration configuration,
     params ContentTypeCodeParserBase[] memberParsers
     ) 
     : base(configuration)
 {
     this.memberParsers = memberParsers;
 }
コード例 #10
0
 public void Create_DelegatesConfiguration()
 {
     var factory = new DefaultParserFactory();
     var configuration = new ContentTypeConfiguration(CodeGeneratorConfiguration.Create(), "DocumentType");
     var dataTypeDefinitions = new List<DataTypeDefinition>();
     var parser = factory.Create(configuration, dataTypeDefinitions);
     Assert.IsInstanceOf<DocumentTypeCodeParser>(parser);
 }
コード例 #11
0
 public CodeGeneratorBase CreateDocTypeGenerator(ContentTypeConfiguration configuration, IEnumerable<DataTypeDefinition> dataTypes)
 {
     return CreateGenerators(
         configuration,
         dataTypes,
         "DocumentType",
         new DocumentTypeInfoGenerator(configuration)
         );
 }
コード例 #12
0
 public AttributeCodeGenerator(
     string attributeName,
     ContentTypeConfiguration config,
     params CodeGeneratorBase[] memberGenerators
     ) : base(config)
 {
     this.attributeName = attributeName;
     this.memberGenerators = memberGenerators;
 }
コード例 #13
0
 public CodeGeneratorBase CreateMediaTypeGenerator(ContentTypeConfiguration configuration, IEnumerable<DataTypeDefinition> dataTypes)
 {
     return CreateGenerators(
         configuration,
         dataTypes,
         "MediaType",
         new CommonInfoGenerator(configuration)
         );
 }
コード例 #14
0
 protected PropertyDeclarationGenerator(
     ContentTypeConfiguration config,
     IList<DataTypeDefinition> dataTypes,
     params CodeGeneratorBase[] memberGenerators
     ) : base(config)
 {
     this.DataTypes = dataTypes;
     this.MemberGenerators = memberGenerators;
 }
コード例 #15
0
 public DocumentTypeCodeParser(
     ContentTypeConfiguration configuration, 
     params ContentTypeCodeParserBase[] memberParsers 
     ) : base(
         configuration,
         memberParsers
     )
 {
 }
コード例 #16
0
 private void SetConfig(ContentTypeConfiguration value, string contentTypeName)
 {
     value.config = this;
     value.ContentTypeName = contentTypeName;
     if (!Configs.ContainsKey(contentTypeName))
         Configs.Add(contentTypeName, value);
     else
         Configs[contentTypeName] = value;
 }
コード例 #17
0
 public ClassGenerator(
     ContentTypeConfiguration config, 
     CodeGeneratorBase entityDescriptionGenerator,
     params CodeGeneratorBase[] memberGenerators
     )
     : base(config)
 {
     this.entityDescriptionGenerator = entityDescriptionGenerator;
     this.memberGenerators = memberGenerators;
 }
コード例 #18
0
 public ContentTypeCodeParser Create(
     ContentTypeConfiguration configuration,
     IEnumerable<DataTypeDefinition> dataTypes 
     )
 {
     Configuration = configuration;
     DataTypes = dataTypes as List<DataTypeDefinition> ?? dataTypes.ToList();
     var typedParser = configuration.ContentTypeName == "DocumentType" 
                           ? CreateDocumentTypeParser() 
                           : CreateMediaTypeParser();
     return typedParser;
 }
コード例 #19
0
 private void SetConfig(ContentTypeConfiguration value, string contentTypeName)
 {
     value.config          = this;
     value.ContentTypeName = contentTypeName;
     if (!Configs.ContainsKey(contentTypeName))
     {
         Configs.Add(contentTypeName, value);
     }
     else
     {
         Configs[contentTypeName] = value;
     }
 }
コード例 #20
0
 private CodeGeneratorBase CreateGenerators(ContentTypeConfiguration c, CodeGeneratorBase infoGenerator, IEnumerable<DataTypeDefinition> dataTypes)
 {
     return new NamespaceGenerator(c,
         new ImportsGenerator(c),
         new ClassGenerator(c,
             new EntityDescriptionGenerator(c),
             infoGenerator,
             new StructureGenerator(c),
             new PropertiesGenerator(c,
                 new PropertyDeclarationGenerator(c, dataTypes.ToList(), new EntityDescriptionGenerator(c)),
                 new PropertyBodyGenerator(c)
                 )
             )
         );
 }
コード例 #21
0
 public CodeGeneratorBase CreateInterfaceGenerator(ContentTypeConfiguration configuration, IEnumerable<DataTypeDefinition> dataTypes)
 {
     return new NamespaceGenerator(
         configuration,
         new ImportsGenerator(configuration),
         new InterfaceGenerator(configuration,
             new CompositeCodeGenerator(
                 configuration,
                 new InterfaceNameGenerator(configuration)
                 ),
             new PropertiesGenerator(
                 configuration,
                 new InterfacePropertyDeclarationGenerator(
                     configuration,
                     dataTypes.ToList(),
                     new EntityNameGenerator(configuration),
                     new InterfacePropertyBodyGenerator(configuration)
                     )
                 )
             )
         );
 }
コード例 #22
0
 private static CodeGeneratorBase CreateGenerators(
     ContentTypeConfiguration configuration,
     IEnumerable<DataTypeDefinition> dataTypes,
     string attributeName,
     CodeGeneratorBase infoGenerator)
 {
     return new NamespaceGenerator(
         configuration,
         new ImportsGenerator(configuration),
         new ClassGenerator(configuration,
             new CompositeCodeGenerator(
                 configuration,
                 new EntityNameGenerator(configuration),
                 new AttributeCodeGenerator(
                     attributeName,
                     configuration,
                     infoGenerator,
                     new StructureGenerator(configuration)
                     )
                 ),
             new CtorGenerator(configuration),
             new PropertiesGenerator(
                 configuration,
                 new PublicPropertyDeclarationGenerator(
                     configuration,
                     dataTypes.ToList(),
                     new EntityNameGenerator(configuration),
                     new AttributeCodeGenerator(
                         "GenericProperty",
                         configuration,
                         new PropertyInfoGenerator(configuration, dataTypes.ToList())
                         ),
                     new PropertyBodyGenerator(configuration)
                     )
                 )
             )
         );
 }
コード例 #23
0
		private void GenerateXml(ContentTypeConfiguration contentTypeConfiguration)
		{
			var parser = new CodeParser(contentTypeConfiguration, dataTypes, new DefaultParserFactory());
		    var modelPath = HttpContext.Current.Server.MapPath(contentTypeConfiguration.ModelPath);
			if (!Directory.Exists(modelPath))
				Directory.CreateDirectory(modelPath);
			var files = Directory.GetFiles(modelPath, "*.cs");
			var documents = new List<XDocument>();
			foreach(var file in files)
			{
				using (var reader = File.OpenText(file))
				{
				    var contentType = parser.Parse(reader).FirstOrDefault();
                    if (contentType != null)
					    documents.Add(XDocument.Parse(serializer.Serialize(contentType)));
				}
			}

			var documentTypeRoot = Path.Combine(uSyncConfiguration.USyncFolder, contentTypeConfiguration.ContentTypeName);
			if (!Directory.Exists(documentTypeRoot))
				Directory.CreateDirectory(documentTypeRoot);
			WriteDocuments(contentTypeConfiguration, documents, documentTypeRoot, "");
		}
コード例 #24
0
 public EntityDescriptionGenerator(ContentTypeConfiguration config) : base(config)
 {
 }
コード例 #25
0
 public StructureParser(ContentTypeConfiguration configuration) : base(configuration)
 {
 }
コード例 #26
0
 public DocumentTypeInfoParser(ContentTypeConfiguration configuration) : base(configuration)
 {
 }
コード例 #27
0
 public InterfacePropertyBodyGenerator(ContentTypeConfiguration config) : base(config)
 {
 }
コード例 #28
0
 public ImportsGenerator(ContentTypeConfiguration config) : base(config)
 {
 }
コード例 #29
0
 public PropertyParser(ContentTypeConfiguration configuration, IEnumerable<DataTypeDefinition> dataTypes)
     : base(configuration)
 {
     this.DataTypes = dataTypes;
     DefaultDataType = FindDataTypeDefinition(configuration.TypeMappings.DefaultDefinitionId);
 }
コード例 #30
0
 private string EnsureModelPath(ContentTypeConfiguration typeConfig)
 {
     var modelPath = paths[typeConfig.ContentTypeName];
     if (!Directory.Exists(modelPath))
         Directory.CreateDirectory(modelPath);
     return modelPath;
 }
コード例 #31
0
 public CommonInfoGenerator(ContentTypeConfiguration config) : base(config)
 {
 }