/// <summary> /// Creates a model deployment package file for a specified model. /// </summary> /// <param name="packageFile">File name for the output package.</param> /// <param name="modelName">Name of the model to export to package.</param> /// <param name="versionName">Name of the version of master data to include in the package.</param> private static void CreatePackage(string packageFile, string modelName, string versionName) { Console.WriteLine("Creating a package for model {0}", modelName); ModelReader reader = new ModelReader(); // Set the model ID on the reader to the passed-in model name. Identifier modelId = new Identifier(); modelId.Name = modelName; reader.ModelId = modelId; // Set the version ID on the reader to the passed-in version name. Identifier versionId = new Identifier(); versionId.Name = versionName; reader.VersionId = versionId; // Create a package that contains metadata, business rules, and master data. List <Package> packages = reader.CreatePackage(true).ToList(); // Save the package Console.WriteLine("Saving package to file {0}", packageFile); using (var stream = new FileStream(packageFile, FileMode.CreateNew)) { var firstPackage = packages.FirstOrDefault(); if (firstPackage != null) { firstPackage.Serialize(stream); } } }
/// <summary> /// Creates a model deployment package file for a specified model. /// </summary> /// <param name="packageFile">File name for the output package.</param> /// <param name="modelName">Name of the model to export to package.</param> /// <param name="versionName">Name of the version of master data to include in the package.</param> private static void CreatePackage(string packageFile, string modelName, string versionName) { Console.WriteLine("Creating a package for model {0}", modelName); ModelReader reader = new ModelReader(); // Set the model ID on the reader to the passed-in model name. Identifier modelId = new Identifier(); modelId.Name = modelName; reader.ModelId = modelId; // Set the version ID on the reader to the passed-in version name. Identifier versionId = new Identifier(); versionId.Name = versionName; reader.VersionId = versionId; // Create a package that contains metadata, business rules, and master data. List<Package> packages = reader.CreatePackage(true).ToList(); // Save the package Console.WriteLine("Saving package to file {0}", packageFile); using (var stream = new FileStream(packageFile, FileMode.CreateNew)) { var firstPackage = packages.FirstOrDefault(); if (firstPackage != null) firstPackage.Serialize(stream); } }