Пример #1
0
        public override bool CanExecute()
        {
            if (!(PSMComponentGuid != Guid.Empty &&
                  PIMComponentGuid == Guid.Empty || (Project.VerifyComponentType <PSMAttribute>(PSMComponentGuid) && Project.VerifyComponentType <PIMAttribute>(PIMComponentGuid))
                  ))
            {
                ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH;
                return(false);
            }

            if (PIMComponentGuid == Guid.Empty)
            {
                return(true);
            }

            PIMClass pimClass1 = Project.TranslateComponent <PIMAttribute>(PIMComponentGuid).PIMClass;
            PSMClass niClass   = Project.TranslateComponent <PSMAttribute>(PSMComponentGuid).NearestInterpretedClass();

            if (niClass == null)
            {
                ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_NO_INTCLASS;
                return(false);
            }
            PIMClass pimClass2 = niClass.Interpretation as PIMClass;

            if (pimClass1 != pimClass2 && !pimClass2.GetGeneralClasses().Contains(pimClass1))
            {
                ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_CLASSES_DONT_MATCH;
                return(false);
            }
            return(true);
        }
Пример #2
0
 public override bool CanExecute()
 {
     if (generalClassGuid != Guid.Empty &&
         Project.VerifyComponentType <PIMClass>(generalClassGuid) &&
         specificClassGuid != Guid.Empty &&
         Project.VerifyComponentType <PIMClass>(specificClassGuid) &&
         schemaGuid != Guid.Empty &&
         Project.VerifyComponentType <PIMSchema>(schemaGuid))
     {
         PIMClass specific = Project.TranslateComponent <PIMClass>(specificClassGuid);
         PIMClass general  = Project.TranslateComponent <PIMClass>(generalClassGuid);
         if (specific.GeneralizationAsSpecific != null)
         {
             ErrorDescription = CommandErrors.CMDERR_NO_MULTIPLE_INHERITANCE;
             return(false);
         }
         else if (general.Final)
         {
             ErrorDescription = CommandErrors.CMDERR_GENERAL_IS_FINAL;
             return(false);
         }
         else if (specificClassGuid == generalClassGuid)
         {
             ErrorDescription = CommandErrors.CMDERR_NO_SELF_INHERITANCE;
             return(false);
         }
         else if (general.GetGeneralClasses().Contains(specific))
         {
             ErrorDescription = CommandErrors.CMDERR_CYCLIC_INHERITANCE;
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH;
         return(false);
     }
 }