public override bool CanExecute() { if (PSMAttribute.RepresentedAttribute != null) { if (Name != PSMAttribute.RepresentedAttribute.Name || Type != PSMAttribute.RepresentedAttribute.Type) { ErrorDescription = CommandError.CMDERR_REPRESENTING_ATTRIBUTES_CAN_NOT_BE_UPDATED; } } string name = DecideName(); if (name == null) { ErrorDescription = CommandError.CMDERR_PIMLESS_NAME; } if (!NameSuggestor <PSMAttribute> .IsNameUnique(PSMAttribute.Class.PSMAttributes, name, attribute => attribute.AliasOrName, PSMAttribute)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, name); return(false); } if (customMultiplicity && !MultiplicityElementController.IsMultiplicityValid(Lower, Upper)) { ErrorDescription = string.Format(CommandError.CMDERR_MULTIPLICITY_BAD_BOUNDS, name); return(false); } return(true); }
public override bool CanExecute() { if (RepresentedAttribute != null) { if (!PSMClass.RepresentedClass.MeAndAncestors.Contains(RepresentedAttribute.Class)) { ErrorDescription = CommandError.CMDERR_INCLUDED_ATTRIBUTES_INCONSISTENCE; return(false); } if (Name != RepresentedAttribute.Name || Type != null) { ErrorDescription = CommandError.CMDERR_REPRESENTING_ATTRIBUTES_CAN_NOT_BE_UPDATED; } } string name = DecideName(); if (name == null) { ErrorDescription = CommandError.CMDERR_PIMLESS_NAME; } IEnumerable <string> nameCollection; if (UsedAliasesOrNames != null) { nameCollection = UsedAliasesOrNames; } else { nameCollection = from PSMAttribute att in PSMClass.PSMAttributes select att.AliasOrName; } if (!NameSuggestor <string> .IsNameUnique(nameCollection, name, n => n)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, name); return(false); } if (!MultiplicityElementController.IsMultiplicityValid(Lower, Upper)) { ErrorDescription = string.Format(CommandError.CMDERR_MULTIPLICITY_BAD_BOUNDS, name); return(false); } return(true); }