[3437] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14186] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3437] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Reflection;
|
---|
| 24 |
|
---|
| 25 | namespace HeuristicLab.MainForm {
|
---|
| 26 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
---|
| 27 | public sealed class ViewAttribute : Attribute {
|
---|
| 28 | public ViewAttribute(string name) {
|
---|
| 29 | this.name = name;
|
---|
[9977] | 30 | this.helpResourcePath = string.Empty;
|
---|
[3437] | 31 | }
|
---|
| 32 |
|
---|
[9977] | 33 | public ViewAttribute(string name, string helpResourcePath) {
|
---|
| 34 | this.name = name;
|
---|
| 35 | this.helpResourcePath = helpResourcePath;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[3437] | 38 | private string name;
|
---|
| 39 | public string Name {
|
---|
| 40 | get { return this.name; }
|
---|
| 41 | set { this.name = value; }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[9977] | 44 | private string helpResourcePath;
|
---|
| 45 | public string HelpResourcePath {
|
---|
| 46 | get { return this.helpResourcePath; }
|
---|
| 47 | set { this.helpResourcePath = value; }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[3437] | 50 | public static bool HasViewAttribute(MemberInfo viewType) {
|
---|
| 51 | ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
|
---|
| 52 | return attributes.Length != 0;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public static string GetViewName(MemberInfo viewType) {
|
---|
| 56 | ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
|
---|
| 57 | if (attributes.Length == 1)
|
---|
| 58 | return attributes[0].Name;
|
---|
| 59 | return viewType.Name;
|
---|
| 60 | }
|
---|
[9977] | 61 |
|
---|
| 62 | public static string GetHelpResourcePath(MemberInfo viewType) {
|
---|
| 63 | ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
|
---|
| 64 | if (attributes.Length == 1)
|
---|
| 65 | return attributes[0].helpResourcePath;
|
---|
| 66 | return string.Empty;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | public static bool HasHelpResourcePath(MemberInfo viewType) {
|
---|
| 70 | ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
|
---|
| 71 | if (attributes.Length == 1)
|
---|
| 72 | return attributes[0].helpResourcePath != string.Empty;
|
---|
| 73 | return false;
|
---|
| 74 | }
|
---|
[3437] | 75 | }
|
---|
| 76 | } |
---|