public void pack_run(ChocolateyConfiguration config) { string nuspecFilePath = validate_and_return_package_file(config, Constants.ManifestExtension); var nuspecDirectory = _fileSystem.get_full_path(_fileSystem.get_directory_name(nuspecFilePath)); if (string.IsNullOrWhiteSpace(nuspecDirectory)) { nuspecDirectory = _fileSystem.get_current_directory(); } IDictionary <string, string> properties = new Dictionary <string, string>(); // Set the version property if the flag is set if (!string.IsNullOrWhiteSpace(config.Version)) { properties["version"] = config.Version; } // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(properties); var basePath = nuspecDirectory; if (config.Information.PlatformType != PlatformType.Windows) { //bug with nuspec and tools/** folder location on Windows. basePath = "./"; } var builder = new PackageBuilder(nuspecFilePath, basePath, propertyProvider, includeEmptyDirectories: true); if (!string.IsNullOrWhiteSpace(config.Version)) { builder.Version = new SemanticVersion(config.Version); } string outputFile = builder.Id + "." + builder.Version + Constants.PackageExtension; string outputPath = _fileSystem.combine_paths(_fileSystem.get_current_directory(), outputFile); this.Log().Info(() => "Attempting to build package from '{0}'.".format_with(_fileSystem.get_file_name(nuspecFilePath))); //IPackage package = NugetPack.BuildPackage(builder, _fileSystem, outputPath); //todo: v1 analyze package //if (package != null) //{ // AnalyzePackage(package); //} this.Log().Info(ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputFile)); }
private PackageBuilder CreatePackageBuilderFromNuspec(string path) { // Set the version property if the flag is set if (!String.IsNullOrEmpty(Version)) { Properties["version"] = Version; } // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(Properties); if (String.IsNullOrEmpty(BasePath)) { return(new PackageBuilder(path, propertyProvider, !ExcludeEmptyDirectories)); } return(new PackageBuilder(path, BasePath, propertyProvider, !ExcludeEmptyDirectories)); }
public void DictionaryPropertiesConstantWithNullPropValue() { Hashtable hashtable = new Hashtable(); hashtable["EmployeeID"] = -1; hashtable["FirstName"] = "Immo"; hashtable["DOB"] = new DateTime(1981, 10, 19); PropertyBinding[] customProps = DictionaryPropertyProvider.GetProperties(hashtable); hashtable["FirstName"] = null; Expression <object> expr = new Expression <object>(); expr.DataContext.Constants.Add(new ConstantBinding("Constant", hashtable, customProps)); expr.Text = "Constant.FirstName = 'Immo'"; Assert.AreEqual(typeof(bool), expr.Resolve()); Assert.AreEqual(null, expr.Evaluate()); }
private T1 CreateEntityFromExamineData(SearchResult examineNode, ILocalization localization) { if (examineNode == null) { throw new Exception("Trying to load data from null examine SearchResult"); } if (!examineNode.Fields.ContainsKey("id") || string.IsNullOrEmpty(examineNode.Fields["id"])) { throw new Exception("Trying to load data from null examine SearchResult without id field. Actual fields: {" + string.Join(", ", examineNode.Fields.Select(a => a.Key + " = " + a.Value)) + "}"); } var entity = Activator.CreateInstance <T2>(); var fields = new DictionaryPropertyProvider(examineNode); entity.NodeTypeAlias = TypeAlias; entity.LoadFieldsFromExamine(fields); LoadDataFromPropertiesDictionary(entity, fields, localization); return(entity); }
public void DictionaryPropertiesParameterNullValue() { Hashtable hashtable = new Hashtable(); hashtable["EmployeeID"] = -1; hashtable["FirstName"] = "Immo"; hashtable["DOB"] = new DateTime(1981, 10, 19); PropertyBinding[] customProps = DictionaryPropertyProvider.GetProperties(hashtable); Expression <object> expr = new Expression <object>(); expr.Parameters.Add(new ParameterBinding("@Parameter", typeof(IDictionary), customProps)); expr.Parameters["@Parameter"].Value = null; expr.Text = "@Parameter.FirstName = 'Immo'"; Assert.AreEqual(typeof(bool), expr.Resolve()); Assert.AreEqual(null, expr.Evaluate()); }
private PackageBuilder CreatePackageBuilderFromNuspec(string path) { // Set the version property if the flag is set if (!String.IsNullOrEmpty(Version)) { Properties["version"] = Version; } // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(Properties); if (String.IsNullOrEmpty(BasePath)) { return new PackageBuilder(path, propertyProvider, !ExcludeEmptyDirectories); } return new PackageBuilder(path, BasePath, propertyProvider, !ExcludeEmptyDirectories); }
private void runParameterWithCustomPropertiesButton_Click(object sender, EventArgs e) { #region Parameter with Custom Properties Query query = new Query(); Dictionary <string, object> myDictionary = new Dictionary <string, object>(); myDictionary["DateTimeProp"] = DateTime.Now; myDictionary["IntProp"] = 42; myDictionary["StringProp"] = Environment.UserName; query.Parameters.Add("@Param", typeof(Dictionary <string, object>), myDictionary, DictionaryPropertyProvider.GetProperties(myDictionary)); query.Text = "SELECT @Param.IntProp, @Param.StringProp, @Param.DateTimeProp"; dataGridView1.DataSource = query.ExecuteDataTable(); #endregion }
public void pack_run(ChocolateyConfiguration config) { string nuspecFilePath = validate_and_return_package_file(config, Constants.ManifestExtension); var nuspecDirectory = _fileSystem.get_full_path(_fileSystem.get_directory_name(nuspecFilePath)); if (string.IsNullOrWhiteSpace(nuspecDirectory)) nuspecDirectory = _fileSystem.get_current_directory(); IDictionary<string, string> properties = new Dictionary<string, string>(); // Set the version property if the flag is set if (!string.IsNullOrWhiteSpace(config.Version)) { properties["version"] = config.Version; } // Initialize the property provider based on what was passed in using the properties flag var propertyProvider = new DictionaryPropertyProvider(properties); var basePath = nuspecDirectory; if (config.Information.PlatformType != PlatformType.Windows) { //bug with nuspec and tools/** folder location on Windows. basePath = "./"; } var builder = new PackageBuilder(nuspecFilePath, basePath, propertyProvider, includeEmptyDirectories: true); if (!string.IsNullOrWhiteSpace(config.Version)) { builder.Version = new SemanticVersion(config.Version); } string outputFile = builder.Id + "." + builder.Version + Constants.PackageExtension; string outputPath = _fileSystem.combine_paths(_fileSystem.get_current_directory(), outputFile); this.Log().Info(() => "Attempting to build package from '{0}'.".format_with(_fileSystem.get_file_name(nuspecFilePath))); //IPackage package = NugetPack.BuildPackage(builder, _fileSystem, outputPath); //todo: v1 analyze package //if (package != null) //{ // AnalyzePackage(package); //} this.Log().Info(ChocolateyLoggers.Important, () => "Successfully created package '{0}'".format_with(outputFile)); }
public override bool Execute() { if (Nuspecs == null || Nuspecs.Length == 0) { Log.LogError("Nuspecs argument must be specified"); return false; } if (String.IsNullOrEmpty(OutputDirectory)) { Log.LogError("OuputDirectory argument must be specified"); return false; } if (!Directory.Exists(OutputDirectory)) { Directory.CreateDirectory(OutputDirectory); } IPropertyProvider properties = null; if (Properties != null && Properties.Length > 0) { Dictionary<string, string> propertyDictionary = new Dictionary<string, string>(); foreach (string property in Properties) { var propertyPair = property.Split(new[] { '=' }, 2); if (propertyPair.Length < 2) { Log.LogError($"Invalid property pair {property}. Properties should be of the form name=value."); continue; } propertyDictionary[propertyPair[0]] = propertyPair[1]; } properties = new DictionaryPropertyProvider(propertyDictionary); } foreach (var nuspec in Nuspecs) { string nuspecPath = nuspec.GetMetadata("FullPath"); if (!File.Exists(nuspecPath)) { Log.LogError($"Nuspec {nuspecPath} does not exist"); continue; } try { PackageBuilder builder = new PackageBuilder(nuspecPath, properties, !ExcludeEmptyDirectories); string id = builder.Id, version = builder.Version.ToString(); if (String.IsNullOrEmpty(id)) { Log.LogError($"Nuspec {nuspecPath} does not contain a valid Id"); continue; } if (String.IsNullOrEmpty(version)) { Log.LogError($"Nuspec {nuspecPath} does not contain a valid version"); continue; } string nupkgPath = Path.Combine(OutputDirectory, $"{id}.{version}.nupkg"); using (var fileStream = File.Create(nupkgPath)) { builder.Save(fileStream); } Log.LogMessage($"Created '{nupkgPath}'"); } catch (Exception e) { Log.LogError($"Error when creating nuget package from {nuspecPath}. {e}"); } } return !Log.HasLoggedErrors; }
public void DictionaryProperties() { Query query = QueryFactory.CreateQuery(); query.Text = @" SELECT e.EmployeeID, e.FirstName, e.LastName FROM Employees e WHERE e.EmployeeID BETWEEN 1 AND 2 ORDER BY 1 "; Hashtable hashtable = new Hashtable(); hashtable["EmployeeID"] = -1; hashtable["FirstName"] = ""; hashtable["LastName"] = ""; ParameterBinding param = new ParameterBinding("@ROW", typeof(IDictionary), DictionaryPropertyProvider.GetProperties(hashtable)); Expression <object> expr = new Expression <object>(); expr.DataContext = query.DataContext; expr.Parameters.Add(param); DataTable dataTable = query.ExecuteDataTable(); foreach (DataRow row in dataTable.Rows) { Hashtable rowHashtable = new Hashtable(); param.Value = rowHashtable; foreach (DataColumn col in dataTable.Columns) { rowHashtable[col.ColumnName] = row[col]; } foreach (DataColumn col in dataTable.Columns) { expr.Text = "@ROW.[" + col.ColumnName + "]"; Assert.AreEqual(row[col], expr.Evaluate()); } } }