Compartilhar via


Completing the policy helper application

To make The "policy helper" application load and remove policy metadata, complete the following procedure:

  1. Add a method that loads behavior and policy metadata.

    Add a method that controls the loading of behavior and policy metadata. This method should call the LoadBehaviors and LoadPolicies methods that you created earlier

    Warning: You must always add the behavior metadata before you add the policy metadata.

    private void Load()
    

{ LoadBehaviors();

LoadPolicies();

}

  1. Add a method that removes policy and behavior metadata.

    Add a method that controls the removal of policy and behavior metadata. This method calls the RemovePolicies and RemoveBehaviors methods that you created earlier.

    Warning: You must always remove your policy metadata before you remove your behavior metadata.

    private void Remove()
    

{ RemovePolicies();

RemoveBehaviors();

}

  1. Add the Load and Remove methods to the Main method.

    In the Main method of your application, associate the "/load"and "/remove" command line parameters with the Load and Remove methods you created earlier.

    The following code example shows how to use the command line parameters to add or remove policy metadata. The example also shows how to display an error for an invalid command line parameter.

    if (args[0].ToLowerInvariant() == "/load")
    

{ managePolicies.Load(); Console.WriteLine("Lead policies have been added to the Dynamics GP Service metadata."); Console.WriteLine(); }

else if (args[0].ToLowerInvariant() == "/remove") { managePolicies.Remove(); Console.WriteLine("Lead policies have been removed from the Dynamics GP Service metadata."); Console.WriteLine(); } else { Console.WriteLine("Error: Unknown paramater encountered."); Console.WriteLine("Error: The parameter was {0}", args[0].ToLowerInvariant()); Console.WriteLine("Valid parameters are: /load or /remove"); Console.WriteLine(); }

  1. Save the project.

    From the file menu, choose Save All.