Skip to content

Commit 67edf3a

Browse files
committed
Изменено представление аннотаций в образе.
1 parent c514629 commit 67edf3a

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/OneScript.Core/Commons/Utils.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,20 @@ public static void ForEach<T>(this IEnumerable<T> input, Action<T> action)
3535
action(data);
3636
}
3737
}
38-
38+
public static string NameAndValuePresentation(string name, object value)
39+
{
40+
var list = new List<string>();
41+
if (!string.IsNullOrEmpty(name))
42+
{
43+
list.Add(name);
44+
}
45+
if (value != null)
46+
{
47+
list.Add(value.ToString());
48+
}
49+
return string.Join("=", list);
50+
}
51+
3952
public static bool IsMonoRuntime => Type.GetType("Mono.Runtime") != null;
4053

4154
}

src/OneScript.Core/Contexts/BslAnnotationAttribute.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8+
using OneScript.Commons;
9+
using OneScript.Values;
810
using System;
911
using System.Collections.Generic;
10-
using OneScript.Values;
1112

1213
namespace OneScript.Contexts
1314
{
@@ -47,5 +48,10 @@ public BslAnnotationParameter(string name, BslPrimitiveValue value = null)
4748

4849
public BslPrimitiveValue Value { get; }
4950

51+
public override string ToString()
52+
{
53+
return Utils.NameAndValuePresentation(Name, Value);
54+
}
55+
5056
}
5157
}

src/ScriptEngine/Machine/AnnotationDefinition.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ This Source Code Form is subject to the terms of the
88

99
namespace ScriptEngine.Machine
1010
{
11-
[Serializable]
1211
public struct AnnotationDefinition
1312
{
1413
public string Name;

src/ScriptEngine/Machine/AnnotationParameter.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,20 @@ This Source Code Form is subject to the terms of the
44
was not distributed with this file, You can obtain one
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
7-
using System;
8-
using System.Collections.Generic;
7+
using OneScript.Commons;
98

109
namespace ScriptEngine.Machine
1110
{
12-
[Serializable]
1311
public struct AnnotationParameter
1412
{
1513
public string Name;
1614

17-
[NonSerialized]
1815
public IValue RuntimeValue;
1916

2017
public override readonly string ToString()
2118
{
22-
var list = new List<string>();
23-
if (!string.IsNullOrEmpty(Name))
24-
{
25-
list.Add(Name);
26-
}
27-
if (RuntimeValue != null)
28-
{
29-
list.Add(RuntimeValue.ToString());
30-
}
31-
return string.Join("=", list);
19+
return Utils.NameAndValuePresentation(Name, RuntimeValue);
3220
}
21+
3322
}
3423
}

0 commit comments

Comments
 (0)