public void ParseTemplateParameterFileContents_DeserializeWithCorrectType() { Dictionary <string, TemplateFileParameterV1> result = galleryTemplatesClient.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json"); Assert.Equal(true, result["isWorker"].Value); Assert.Equal((System.Int64) 1, result["numberOfWorker"].Value); }
protected Hashtable GetTemplateParameterObject(Hashtable templateParameterObject) { // NOTE(jogao): create a new Hashtable so that user can re-use the templateParameterObject. var prameterObject = new Hashtable(); if (templateParameterObject != null) { foreach (var parameterKey in templateParameterObject.Keys) { prameterObject[parameterKey] = new Hashtable { { "value", templateParameterObject[parameterKey] } }; } } // Load parameters from the file string templateParameterFilePath = this.TryResolvePath(TemplateParameterFile); if (templateParameterFilePath != null && FileUtilities.DataStore.FileExists(templateParameterFilePath)) { var parametersFromFile = GalleryTemplatesClient.ParseTemplateParameterFileContents(templateParameterFilePath); parametersFromFile.ForEach(dp => { var parameter = new Hashtable(); if (dp.Value.Value != null) { parameter.Add("value", dp.Value.Value); } if (dp.Value.Reference != null) { parameter.Add("reference", dp.Value.Reference); } prameterObject[dp.Key] = parameter; }); } // Load dynamic parameters IEnumerable <RuntimeDefinedParameter> parameters = PowerShellUtilities.GetUsedDynamicParameters(dynamicParameters, MyInvocation); if (parameters.Any()) { parameters.ForEach(dp => prameterObject[((ParameterAttribute)dp.Attributes[0]).HelpMessage] = new Hashtable { { "value", dp.Value } }); } return(prameterObject); }
protected Hashtable GetTemplateParameterObject(Hashtable templateParameterObject) { templateParameterObject = templateParameterObject ?? new Hashtable(); // Load parameters from the file string templateParameterFilePath = this.TryResolvePath(TemplateParameterFile); if (templateParameterFilePath != null && FileUtilities.DataStore.FileExists(templateParameterFilePath)) { var parametersFromFile = GalleryTemplatesClient.ParseTemplateParameterFileContents(templateParameterFilePath); parametersFromFile.ForEach(dp => templateParameterObject[dp.Key] = dp.Value.Value); } // Load dynamic parameters IEnumerable <RuntimeDefinedParameter> parameters = PowerShellUtilities.GetUsedDynamicParameters(dynamicParameters, MyInvocation); if (parameters.Any()) { parameters.ForEach(dp => templateParameterObject[((ParameterAttribute)dp.Attributes[0]).HelpMessage] = dp.Value); } return(templateParameterObject); }