Esempio n. 1
0
 /// <summary>
 /// Constructor which requires a <see cref="TransformationInfo"/> as an argument.
 /// </summary>
 /// <param name="transformationInfo"></param>
 public GeneratedArtifact(TransformationInfo transformationInfo)
 {
     if (transformationInfo == null) throw new ArgumentNullException("transformationInfo");
     _transformationInfo = transformationInfo;
     AutogeneratedInfoLines = new List<string>();
     ImportLines = new List<string>();
     ArtifactDataItems = new List<ArtifactDataItem>();
 }
 public DomainModelLibraryProduction(DomainModelInfo domainModelInfo)
 {
     ProjectName = "{project}";
     ProjectNamespace = "{project}";
     ProjectOutputPath = @"{baseuri}\{solution}\{project}";
     TargetLanguage = Tree2Soft.Factory.Contracts.NameTable.TargetLanguage.CSharp;
     TargetDataProvider = Tree2Soft.Factory.Contracts.NameTable.TargetDataProvider.SqlServer;
     TransformationInfo t1 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.ModelLibrary,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Model\{domainmodelname}Model.g.cs",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = "{ProjectNamespace}.Model"
     };
     TransformationInfo t2 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.ModelSchemaXsd,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Model\{domainmodelname}Schema.g.xsd",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = null
     };
     TransformationInfo t3 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.ModelSchemaLoader,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Model\{domainmodelname}Schema.g.cs",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = "{ProjectNamespace}.Model"
     };
     TransformationInfo t4 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.ModelProvider,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Model\{domainmodelname}Provider.g.cs",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = "{ProjectNamespace}.Model"
     };
     TransformationInfo t5 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.FactoryAssets,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Contracts\{domainmodelname}Assets.g.cs",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = "{ProjectNamespace}.Contracts"
     };
     Transformations.Add(t1);
     Transformations.Add(t2);
     Transformations.Add(t3);
     Transformations.Add(t4);
     Transformations.Add(t5);
 }
 public DataModelLibraryProduction(DomainModelInfo domainModelInfo)
 {
     ProjectName = "{projectname}";
     ProjectNamespace = "{project}";
     ProjectOutputPath = @"{baseuri}\{solution}\{project}";
     TargetLanguage = Tree2Soft.Factory.Contracts.NameTable.TargetLanguage.CSharp;
     TargetDataProvider = Tree2Soft.Factory.Contracts.NameTable.TargetDataProvider.SqlServer;
     TransformationInfo t1 = new TransformationInfo
     {
         TransformerName = c.FactoryAssets.Transformer.DataModelLibrary,
         ModelInfo = domainModelInfo,
         GroupResultPathTemplate = @"{ProjectOutputPath}\Src\Models\{ProjectName}.cs",
         ItemResultPathTemplate = null,
         ResultNamespaceTemplate = "{ProjectName}.Model"
     };
     Transformations.Add(t1);
 }
Esempio n. 4
0
 /// <summary>
 /// Set the value of the <see cref="TransformationInfo"/> from which this transformer has been set up.
 /// </summary>
 public void SetTransformationInfo(TransformationInfo transformationInfo)
 {
     TransformationInfo = transformationInfo;
 }
Esempio n. 5
0
 /// <summary>
 /// Executes a single transformation
 /// </summary>
 /// <param name="transformationInfo"></param>
 /// <returns></returns>
 private TransformationResult ExecuteTransformation(TransformationInfo transformationInfo)
 {
     ITransformer transformer = RetrieveTransformer(transformationInfo);
     if (transformer == null)
     {
         throw new FactoryException("Cannot retrieve transformer " + transformationInfo.TransformerName);
     }
     else
     {
         transformer.SetTransformationInfo(transformationInfo);
     }
     IDomainModel model = RetrieveModel(transformationInfo.ModelInfo);
     if (model == null)
     {
         throw new FactoryException("Cannot retrieve domain Model " + transformationInfo.ModelInfo.ToString());
     }
     else
     {
         // initialize the domain model with type system informations
         // target the production context language and data provider
         TypeSystem.TypeSystem typeSystem = RetrieveTypeSystem(
             transformer.TargetLanguage,
             transformer.TargetDataProvider
             );
         DomainModelContext modelContext = new DomainModelContext(null, typeSystem);
         model.Initialize(modelContext);
     }
     // check if the transformer can transform this model
     if (transformer.CanTransform(model))
         // execute transformation passing domain model and production context to the transformer
         return transformer.Transform(model, _productionContext);
     else
         throw new FactoryException("Transformer " + transformationInfo.TransformerName + " cannot transform model " + transformationInfo.ModelInfo.ToString());
 }
Esempio n. 6
0
 /// <summary>
 /// Retrieve a MEF composed transformer.
 /// </summary>
 /// <param name="transformationInfo"></param>
 /// <returns></returns>
 private ITransformer RetrieveTransformer(TransformationInfo transformationInfo)
 {
     foreach (ITransformer transformer in FactoryHost.Instance.Transformers)
     {
         if (transformer.TransformerName == transformationInfo.TransformerName)
         {
             return transformer;
         }
     }
     return null;
 }
Esempio n. 7
0
 /// <summary>
 /// Returns a <see cref="GeneratedArtifact"/> newly created and added to the
 /// <see cref="GeneratedArtifact"/>s collection.
 /// </summary>
 /// <param name="transformationInfo"></param>
 /// <returns></returns>
 public GeneratedArtifact CreateGeneratedArtifact(TransformationInfo transformationInfo)
 {
     GeneratedArtifact retval = new GeneratedArtifact(transformationInfo);
     GeneratedArtifacts.Add(retval);
     return retval;
 }