-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathValueListItem.cs
More file actions
59 lines (50 loc) · 2.06 KB
/
Copy pathValueListItem.cs
File metadata and controls
59 lines (50 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System;
using OneScript.Contexts;
using OneScript.Localization;
using OneScript.Values;
using ScriptEngine.Machine;
using ScriptEngine.Machine.Contexts;
namespace OneScript.StandardLibrary.Collections.ValueList
{
/// <summary>
/// Используется для доступа к свойствам и методам элемента списка значений
/// </summary>
[ContextClass("ЭлементСпискаЗначений", "ValueListItem")]
public class ValueListItem : AutoContext<ValueListItem>
{
static readonly BilingualString EMPTY_VALUE_STRING = new("<Пустое значение>", "<Empty value>");
private string _presentationHolder;
private IValue _pictureHolder;
internal ValueListItem()
{
_pictureHolder = ValueFactory.Create();
_presentationHolder = String.Empty;
}
[ContextProperty("Значение", "Value")]
public IValue Value { get; set; }
[ContextProperty("Представление", "Presentation")]
public string Presentation
{
get => _presentationHolder;
set => _presentationHolder = value ?? String.Empty;
}
[ContextProperty("Пометка", "Check")]
public bool Check { get; set; }
[ContextProperty("Картинка", "Picture")]
public IValue Picture
{
get => _pictureHolder;
set => _pictureHolder = value ?? ValueFactory.Create();
}
public override string ToString()
=> !String.IsNullOrEmpty(_presentationHolder) ? _presentationHolder
: Value is BslUndefinedValue or BslNullValue? EMPTY_VALUE_STRING
: Value.ToString();
}
}