Ejemplo n.º 1
0
        public object GetDynamicParameters()
        {
            if (!string.IsNullOrEmpty(GalleryTemplateIdentity) &&
                !GalleryTemplateIdentity.Equals(galleryTemplateName, StringComparison.OrdinalIgnoreCase))
            {
                galleryTemplateName = GalleryTemplateIdentity;
                dynamicParameters   = GalleryTemplatesClient.GetTemplateParametersFromGallery(
                    GalleryTemplateIdentity,
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }
            else if (!string.IsNullOrEmpty(TemplateFile) &&
                     !TemplateFile.Equals(templateFile, StringComparison.OrdinalIgnoreCase))
            {
                templateFile      = TemplateFile;
                dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                    this.TryResolvePath(TemplateFile),
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }
            else if (!string.IsNullOrEmpty(TemplateUri) &&
                     !TemplateUri.Equals(templateUri, StringComparison.OrdinalIgnoreCase))
            {
                templateUri       = TemplateUri;
                dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                    TemplateUri,
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }

            return(dynamicParameters);
        }
        public object GetDynamicParameters()
        {
            if (!string.IsNullOrEmpty(GalleryTemplateIdentity) &&
                !GalleryTemplateIdentity.Equals(galleryTemplateName, StringComparison.OrdinalIgnoreCase))
            {
                galleryTemplateName = GalleryTemplateIdentity;
                try
                {
                    dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromGallery(
                        GalleryTemplateIdentity,
                        TemplateParameterObject,
                        this.TryResolvePath(TemplateParameterFile),
                        MyInvocation.MyCommand.Parameters.Keys.ToArray());
                }
                catch (CloudException)
                {
                    throw new ArgumentException(string.Format(Resources.UnableToFindGallery, GalleryTemplateIdentity));
                }
            }
            else if (!string.IsNullOrEmpty(TemplateFile) &&
                     !TemplateFile.Equals(templateFile, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    templateFile      = TemplateFile;
                    dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                        this.TryResolvePath(TemplateFile),
                        TemplateParameterObject,
                        this.TryResolvePath(TemplateParameterFile),
                        MyInvocation.MyCommand.Parameters.Keys.ToArray());
                }
                catch
                {
                    throw new ArgumentException(string.Format(Resources.FailedToParseProperty, "TemplateFile", TemplateFile));
                }
            }
            else if (!string.IsNullOrEmpty(TemplateUri) &&
                     !TemplateUri.Equals(templateUri, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    templateUri       = TemplateUri;
                    dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                        TemplateUri,
                        TemplateParameterObject,
                        this.TryResolvePath(TemplateParameterFile),
                        MyInvocation.MyCommand.Parameters.Keys.ToArray());
                }
                catch
                {
                    throw new ArgumentException(string.Format(Resources.FailedToParseProperty, "TemplateUri", TemplateUri));
                }
            }

            return(dynamicParameters);
        }
Ejemplo n.º 3
0
        public object GetDynamicParameters()
        {
            if (!string.IsNullOrEmpty(GalleryTemplateIdentity))
            {
                List <PSGalleryItem> galleryItems = new List <PSGalleryItem>();
                try
                {
                    galleryItems = GalleryTemplatesClient.FilterGalleryTemplates(new FilterGalleryTemplatesOptions()
                    {
                        Identity = GalleryTemplateIdentity
                    });
                }
                catch (CloudException)
                {
                    // we could not find a template with that identity
                }

                if (galleryItems.Count == 0)
                {
                    galleryItems = GalleryTemplatesClient.FilterGalleryTemplates(new FilterGalleryTemplatesOptions()
                    {
                        ApplicationName = GalleryTemplateIdentity, AllVersions = false
                    });
                    if (galleryItems == null || galleryItems.Count == 0)
                    {
                        throw new ArgumentException(string.Format(Properties.Resources.InvalidTemplateIdentity, GalleryTemplateIdentity));
                    }

                    GalleryTemplateIdentity = galleryItems[0].Identity;
                }
            }

            if (!string.IsNullOrEmpty(GalleryTemplateIdentity) &&
                !GalleryTemplateIdentity.Equals(galleryTemplateName, StringComparison.OrdinalIgnoreCase))
            {
                galleryTemplateName = GalleryTemplateIdentity;
                dynamicParameters   = GalleryTemplatesClient.GetTemplateParametersFromGallery(
                    GalleryTemplateIdentity,
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }
            else if (!string.IsNullOrEmpty(TemplateFile) &&
                     !TemplateFile.Equals(templateFile, StringComparison.OrdinalIgnoreCase))
            {
                templateFile      = TemplateFile;
                dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                    this.TryResolvePath(TemplateFile),
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }
            else if (!string.IsNullOrEmpty(TemplateUri) &&
                     !TemplateUri.Equals(templateUri, StringComparison.OrdinalIgnoreCase))
            {
                templateUri       = TemplateUri;
                dynamicParameters = GalleryTemplatesClient.GetTemplateParametersFromFile(
                    TemplateUri,
                    TemplateParameterObject,
                    this.TryResolvePath(TemplateParameterFile),
                    MyInvocation.MyCommand.Parameters.Keys.ToArray());
            }

            return(dynamicParameters);
        }