Показать сообщение отдельно
Старый 01.12.2009, 21:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
How to add all descendant classes to a new project
Источник: http://alexvoy.blogspot.com/2009/12/...lasses-to.html
==============

I bumped into the problem of a class compilation with no licence for X++ source code.

Forward compile option is not enough to make my changes working. Thus I need to export-import all descendant classes as well as the class I changed - FormLetter in my case.

I therefore have to add all these classes to my project. Natural laziness saved me again from this manual work.

I hope this short job inspired by system class SysCompilerOutput and miklenew's job from AXForum will help you in similar situations.


X++:
// add to a new project all descendant classes for forward compilation
public static void SISCreateCompileForwardProject(Args _args)
{
   #AOT
   str                     project = 'SIS_CompileForward';
   SysCompilerOutput       sysCompilerOutput;
   Dictionary              dictionary      = new Dictionary();
   DictClass               dictClass       = new DictClass(className2Id("Formletter"));
   int                     numOfClasses    = dictionary.classCnt();
   ProjectNode             sharedProjects;
   ProjectNode             newProject;

   void addToProjectForwardClass(DictClass _dictClass, Dictionary _dictionary, int _numOfClasses)
   {
   ClassNode           classNode;
   DictClass           dictClassLoop;
   DictClass           childClass;
   int                 i;
   ;
       if (_dictClass)
       {
           classNode = infolog.findNode(#ClassesPath + #AOTDelimiter + _dictClass.name());

           if (classNode)
           {
               newProject.addUtilNode(UtilElementType::Class, classNode.name());

               for (i=1; i <= _numOfClasses; i++)
               {
                   dictClassLoop = _dictionary.classObject(_dictionary.classCnt2Id(i));

                   if (dictClassLoop.extend() == _dictClass.id())
                   {
                       childClass = new DictClass(dictClassLoop.id());
                       addToProjectForwardClass(childClass, _dictionary, _numOfClasses);
                   }
               }
           }
       }
   }
   ;

   sharedProjects = infolog.projectRootNode().AOTfindChild('Shared');
   sharedProjects.AOTAdd(project);
   newProject =  sharedProjects.AOTfindChild(project);
   newProject.loadForInspection();
   newProject = newProject.getRunNode();
   addToProjectForwardClass(dictClass, dictionary, numOfClasses);
   newProject.AOTsave();


}
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.