| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | internal interface ISearchInfo : ISearchable, ISortable<ISearchInfo> |
| | 5 | | { |
| | 6 | | string id { get; } |
| | 7 | | string name { get; } |
| | 8 | | int size { get; } |
| | 9 | | bool isOwner { get; } |
| | 10 | | bool isOperator { get; } |
| | 11 | | bool isContributor { get; } |
| | 12 | | void SetId(string id); |
| | 13 | | void SetName(string name); |
| | 14 | | void SetSize(int size); |
| | 15 | | void SetCoords(string coords); |
| | 16 | | void SetRole(bool isOwner); |
| | 17 | | } |
| | 18 | |
|
| | 19 | | internal class SearchInfo : ISearchInfo |
| | 20 | | { |
| 16 | 21 | | string ISearchInfo.id => id; |
| 1 | 22 | | string ISearchInfo.name => name; |
| 9 | 23 | | int ISearchInfo.size => size; |
| 0 | 24 | | bool ISearchInfo.isOwner => isOwner; |
| 0 | 25 | | bool ISearchInfo.isOperator => isOperator; |
| 0 | 26 | | bool ISearchInfo.isContributor => isContributor; |
| 0 | 27 | | string[] ISearchable.keywords => keywords; |
| | 28 | |
|
| | 29 | | private bool isOwner; |
| | 30 | | private bool isOperator; |
| | 31 | | private bool isContributor; |
| | 32 | | internal string id; |
| | 33 | | private string name; |
| | 34 | | private int size; |
| | 35 | | private string[] keywords; |
| | 36 | |
|
| 0 | 37 | | public SearchInfo() { keywords = new string[2]; } |
| | 38 | |
|
| 74 | 39 | | void ISearchInfo.SetId(string id) { this.id = id; } |
| | 40 | |
|
| | 41 | | void ISearchInfo.SetName(string name) |
| | 42 | | { |
| 38 | 43 | | this.name = name; |
| 38 | 44 | | keywords[0] = name; |
| 38 | 45 | | } |
| | 46 | |
|
| 78 | 47 | | void ISearchInfo.SetSize(int size) { this.size = size; } |
| | 48 | |
|
| 60 | 49 | | void ISearchInfo.SetCoords(string coords) { keywords[1] = coords; } |
| | 50 | |
|
| | 51 | | void ISearchInfo.SetRole(bool isOwner) |
| | 52 | | { |
| 32 | 53 | | this.isOwner = isOwner; |
| 32 | 54 | | this.isOperator = !isOwner; |
| 32 | 55 | | this.isContributor = false; |
| 32 | 56 | | } |
| | 57 | |
|
| | 58 | | int ISortable<ISearchInfo>.Compare(string sortType, bool isDescendingOrder, ISearchInfo other) |
| | 59 | | { |
| | 60 | | switch (sortType) |
| | 61 | | { |
| | 62 | | case SectionSearchHandler.NAME_SORT_TYPE_ASC: |
| 1 | 63 | | return String.CompareOrdinal(name, other.name); |
| | 64 | | case SectionSearchHandler.NAME_SORT_TYPE_DESC: |
| 0 | 65 | | return String.CompareOrdinal(other.name, name); |
| | 66 | | case SectionSearchHandler.SIZE_SORT_TYPE_DESC: |
| 0 | 67 | | return other.size - size; |
| | 68 | | case SectionSearchHandler.SIZE_SORT_TYPE_ASC: |
| 9 | 69 | | return size - other.size; |
| | 70 | | default: |
| 0 | 71 | | return 0; |
| | 72 | | } |
| | 73 | | } |
| | 74 | | } |