Ejemplo n.º 1
0
        public ValidationError IsValid()
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(new ValidationError("Shortcut Name Cannot be Empty.", this));
            }

            foreach (Action action in Actions)
            {
                switch (action.Type)
                {
                case "command":
                    CommandAction   a1    = action as CommandAction;
                    ValidationError a1Err = a1.IsValid();
                    if (a1Err != null)
                    {
                        a1Err.Shortcut = this;
                        return(a1Err);
                    }

                    break;

                case "file":
                    FileAction      a2    = action as FileAction;
                    ValidationError a2Err = a2.IsValid();
                    if (a2Err != null)
                    {
                        a2Err.Shortcut = this;
                        return(a2Err);
                    }

                    break;

                case "folder":
                    FolderAction    a3    = action as FolderAction;
                    ValidationError a3Err = a3.IsValid();
                    if (a3Err != null)
                    {
                        a3Err.Shortcut = this;
                        return(a3Err);
                    }

                    break;

                case "software":
                    SoftwareAction  a4    = action as SoftwareAction;
                    ValidationError a4Err = a4.IsValid();
                    if (a4Err != null)
                    {
                        a4Err.Shortcut = this;
                        return(a4Err);
                    }

                    break;

                case "website":
                    WebsiteAction   a5    = action as WebsiteAction;
                    ValidationError a5Err = a5.IsValid();
                    if (a5Err != null)
                    {
                        a5Err.Shortcut = this;
                        return(a5Err);
                    }

                    break;
                }
            }

            return(null);
        }