How can I reference the Configuration from CustomDomainCommand Header button?

I'm attempting to use the Header button from

https://developer.m-files.com/Frameworks/Vault-Application-Framework/Configuration/Commands/

But I am unable to reference the variables obtained from the Configuration editors

https://developer.m-files.com/Frameworks/Vault-Application-Framework/Configuration/Editors/

Example below, would expect the MyStringValue from the config to end up in the popup, but the typical this.Configuration.<> doesnt seem to work in this instance.

public class VaultApplication
        : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>

    {


        public readonly CustomDomainCommand cmdHeaderButtonCommand = new CustomDomainCommand
        {
            ID = "cmdHeaderButtonCommand",
            Execute = (c, o) =>
            {
                
                
                string returntest = this.Configuration.MyStringValue;
                o.ShowMessage(""+returntest);


            },
            DisplayName = "Test Contents",
            Locations = new List<ICommandLocation>
            {
            new ButtonBarCommandLocation()
            }
        };

        /// <inheritdoc />
        public override IEnumerable<CustomDomainCommand> GetCommands(IConfigurationRequestContext context)
        {
            return new List<CustomDomainCommand>(base.GetCommands(context))
            {
            this.cmdHeaderButtonCommand,
            };
        }

    }

  • This isn't related to the VAF at all, but how fields instantiated like that can access instance members.  Instead: move the code to the constructor:

    public class VaultApplication
            : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
    
        {
    
    
            public CustomDomainCommand cmdHeaderButtonCommand { get; }
            
            public VaultApplication()
            {
                this.cmdHeaderButtonCommand = new CustomDomainCommand
                {
                    ID = "cmdHeaderButtonCommand",
                    Execute = (c, o) =>
                    {
                        string returntest = this.Configuration.MyStringValue;
                        o.ShowMessage(""+returntest);
                    },
                    DisplayName = "Test Contents",
                    Locations = new List<ICommandLocation>
                    {
                        new ButtonBarCommandLocation()
                    }
                }
            };
    
            /// <inheritdoc />
            public override IEnumerable<CustomDomainCommand> GetCommands(IConfigurationRequestContext context)
            {
                return new List<CustomDomainCommand>(base.GetCommands(context))
                {
                this.cmdHeaderButtonCommand,
                };
            }
    
        }

    An alternative approach is to use the new functionality recently added to the Extensions, which cuts out a lot of that boilerplate:

    public class VaultApplication 
    : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
    {
    
    	[CustomCommand("Test Contents")]
    	[ButtonBarCommandLocation]
    	public void SayHello
    	(
    		IConfigurationRequestContext context, 
    		ClientOperations operations
    	)
    	{
            string returntest = this.Configuration.MyStringValue;
            operations.ShowMessage(""+returntest);
    	}
    }

  • Thank you! and the new functionality is beautifully simple.

  • It doesn't do anything more clever than plumb together everything via those attributes.  The VAF does all the hard work.

    Glad it's working though.

  • I had a secondary issue which drove the original question where I had a second class in the main namespace.  was trying to pull in from the configuration class.  I solved that issue by passing "this.Configuration" through to that class as "Configurat Config" and then i could just Config.<> without problems!