Skip to content

Commit 0323e5f

Browse files
committed
Merge remote-tracking branch 'origin/latest' into latest
2 parents 87f2e3c + 70e0bf2 commit 0323e5f

File tree

8 files changed

+817
-212
lines changed

8 files changed

+817
-212
lines changed

src/ScriptEngine.HostedScript/Library/ConsoleColorEnum.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,23 @@ public static ConsoleColorEnum CreateInstance()
4848

4949
instance = new ConsoleColorEnum(type, enumValueType);
5050

51-
instance.AddValue("Белый", "White", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.White));
5251
instance.AddValue("Черный", "Black", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Black));
52+
instance.AddValue("ТемноСиний", "DarkBlue", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkBlue));
53+
instance.AddValue("ТемноЗеленый", "DarkGreen", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkGreen));
54+
instance.AddValue("ТемноБирюзовый", "DarkCyan", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkCyan));
55+
instance.AddValue("ТемноКрасный", "DarkRed", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkRed));
56+
instance.AddValue("ТемноМалиновый", "DarkMagenta", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkMagenta));
57+
instance.AddValue("ТемноЖелтый", "DarkYellow", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkYellow));
58+
instance.AddValue("Серый", "Gray", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Gray));
59+
60+
instance.AddValue("ТемноСерый", "DarkGray", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.DarkGray));
5361
instance.AddValue("Синий", "Blue", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Blue));
54-
instance.AddValue("Желтый", "Yellow", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Yellow));
55-
instance.AddValue("Красный", "Red", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Red));
5662
instance.AddValue("Зеленый", "Green", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Green));
5763
instance.AddValue("Бирюза", "Cyan", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Cyan));
64+
instance.AddValue("Красный", "Red", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Red));
5865
instance.AddValue("Малиновый", "Magenta", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Magenta));
59-
instance.AddValue("Серый", "Gray", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Gray));
66+
instance.AddValue("Желтый", "Yellow", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.Yellow));
67+
instance.AddValue("Белый", "White", new CLREnumValueWrapper<ConsoleColor>(instance, ConsoleColor.White));
6068

6169
return instance;
6270
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
8+
using ScriptEngine.HostedScript.Library.Binary;
9+
using ScriptEngine.Machine;
10+
using ScriptEngine.Machine.Values;
11+
12+
namespace ScriptEngine.HostedScript.Library
13+
{
14+
public static class CommonTypes
15+
{
16+
public static readonly TypeDescriptor BinaryData = TypeManager.GetTypeByFrameworkType(typeof(BinaryDataContext));
17+
public static readonly TypeDescriptor Null = TypeManager.GetTypeByFrameworkType(typeof(NullValue));
18+
public static readonly TypeDescriptor Boolean = TypeDescriptor.FromDataType(DataType.Boolean);
19+
public static readonly TypeDescriptor String = TypeDescriptor.FromDataType(DataType.String);
20+
public static readonly TypeDescriptor Date = TypeDescriptor.FromDataType(DataType.Date);
21+
public static readonly TypeDescriptor Number = TypeDescriptor.FromDataType(DataType.Number);
22+
public static readonly TypeDescriptor Type = TypeDescriptor.FromDataType(DataType.Type);
23+
public static readonly TypeDescriptor Undefined = TypeDescriptor.FromDataType(DataType.Undefined);
24+
25+
public static readonly TypeDescriptor[] Primitives = {
26+
CommonTypes.Boolean,
27+
CommonTypes.BinaryData,
28+
CommonTypes.String,
29+
CommonTypes.Date,
30+
CommonTypes.Null,
31+
CommonTypes.Number,
32+
CommonTypes.Type
33+
};
34+
}
35+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
using System.Collections.Generic;
8+
using ScriptEngine.HostedScript.Library.Binary;
9+
using ScriptEngine.Machine;
10+
using ScriptEngine.Machine.Values;
11+
12+
namespace ScriptEngine.HostedScript.Library
13+
{
14+
internal class TypeComparer : IComparer<TypeTypeValue>
15+
{
16+
public int Compare(TypeTypeValue x, TypeTypeValue y)
17+
{
18+
if (x == null)
19+
{
20+
return y == null ? 0 : -1;
21+
}
22+
23+
if (y == null) return 1;
24+
25+
var primitiveX = PrimitiveIndex(x);
26+
var primitiveY = PrimitiveIndex(y);
27+
28+
if (primitiveX != -1)
29+
{
30+
if (primitiveY != -1)
31+
return primitiveX - primitiveY;
32+
33+
return -1;
34+
}
35+
36+
if (primitiveY != -1)
37+
return 1;
38+
39+
return x.Value.ID.CompareTo(y.Value.ID);
40+
}
41+
42+
private static int PrimitiveIndex(TypeTypeValue type)
43+
{
44+
var typeDescriptor = TypeManager.GetTypeDescriptorFor(type);
45+
for (var primitiveIndex = 0; primitiveIndex < CommonTypes.Primitives.Length; primitiveIndex++)
46+
{
47+
if (typeDescriptor.Equals(CommonTypes.Primitives[primitiveIndex]))
48+
{
49+
return primitiveIndex;
50+
}
51+
}
52+
53+
return -1;
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)