/// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinDesignerEventArgs e)
        {
            //Microsoft.Dynamics.AX.Metadata.Core.MetaModel.EntryPointType entryPointType;
            try
            {
                var selectedItem = e.SelectedElement as Microsoft.Dynamics.Framework.Tools.MetaModel.Automation.IRootElement;
                if (selectedItem != null)
                {
                    var metadataType = selectedItem.GetMetadataType();

                    LabelFactory labelFactory = LabelFactory.construct(selectedItem);
                    labelFactory.ApplyLabel();
                }
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
示例#2
0
        public static LabelFactory construct(IRootElement selectedElement)
        {
            LabelFactory labelFactory = null;

            if (selectedElement is ITable)
            {
                labelFactory = new LabelFactory_Table();
            }
            else if (selectedElement is ITableExtension)
            {
                labelFactory = new LabelFactory_TableExtension();
            }
            else if (selectedElement is IDataEntity)
            {
                labelFactory = new LabelFactory_DataEntity();
            }
            else if (selectedElement is Microsoft.Dynamics.Framework.Tools.MetaModel.Automation.DataEntityViews.IDataEntityViewExtension)
            {
                labelFactory = new LabelFactory_DataEntityExtension();
            }
            else if (selectedElement is IMenuItem || selectedElement is IMenuItemExtension)
            {
                labelFactory = new LabelFactory_IMenuItem();
            }
            else if (selectedElement is IForm)
            {
                labelFactory = new LabelFactory_Form();
            }
            else if (selectedElement is ISecurityDuty)
            {
                labelFactory = new LabelFactory_ISecurityDuty();
            }
            else if (selectedElement is ISecurityPrivilege)
            {
                labelFactory = new LabelFactory_ISecurityPrivilege();
            }
            else if (selectedElement is ISecurityRole)
            {
                labelFactory = new LabelFactory_ISecurityRole();
            }
            else if (selectedElement is IEdtBase)
            {
                labelFactory = new LabelFactory_IEdtBase();
            }
            else if (selectedElement is IBaseEnum)
            {
                labelFactory = new LabelFactory_IBaseEnum();
            }
            else if (selectedElement is IBaseEnumExtension)
            {
                labelFactory = new LabelFactory_IBaseEnumExtension();
            }
            else if (selectedElement is IConfigurationKey)
            {
                labelFactory = new LabelFactory_IConfigurationKey();
            }
            // add additional elseifs here
            else
            {
                throw new Exception($"Type {selectedElement.GetMetadataType().Name} not implemented yet");
            }

            labelFactory.setElement(selectedElement);

            return(labelFactory);
        }