SharpLibEar/Action.cs
changeset 266 b11d7ebbdc7f
parent 265 82e87f4956ea
     1.1 --- a/SharpLibEar/Action.cs	Wed Aug 31 20:20:32 2016 +0200
     1.2 +++ b/SharpLibEar/Action.cs	Wed Aug 31 23:59:00 2016 +0200
     1.3 @@ -12,7 +12,7 @@
     1.4  namespace SharpLib.Ear
     1.5  {
     1.6      [DataContract]
     1.7 -    [AttributeObject(Id = "Action", Name = "Action", Description = "An empty action.")]
     1.8 +    [AttributeObject(Id = "Action", Name = "Action Group", Description = "Use it to group other actions together.")]
     1.9      public class Action: Object
    1.10      {
    1.11          [DataMember]
    1.12 @@ -36,6 +36,20 @@
    1.13              get { return Iterations > 0; }
    1.14          }
    1.15  
    1.16 +
    1.17 +        public override bool IsValid()
    1.18 +        {            
    1.19 +            // We don't want to override this behaviour for derived classes
    1.20 +            if (GetType() == typeof(Action))
    1.21 +            {
    1.22 +                // Avoid having empty actions with no name
    1.23 +                return !string.IsNullOrEmpty(Name);
    1.24 +            }
    1.25 +
    1.26 +            return base.IsValid();
    1.27 +        }
    1.28 +
    1.29 +
    1.30          /// <summary>
    1.31          /// Basic action just does nothing
    1.32          /// </summary>
    1.33 @@ -93,7 +107,7 @@
    1.34          /// <returns></returns>
    1.35          public virtual string BriefBase()
    1.36          {
    1.37 -            return Name;
    1.38 +            return string.IsNullOrEmpty(Name)? AttributeName : Name;
    1.39          }
    1.40  
    1.41          /// <summary>