Skip to content

Commit 52f6cca

Browse files
author
Andrey Ovsiankin
committed
Еще меньше кода в коллекциях.
1 parent f24f375 commit 52f6cca

File tree

12 files changed

+14
-27
lines changed

12 files changed

+14
-27
lines changed

src/OneScript.StandardLibrary/Collections/FixedStructureImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ public CollectionEnumerator GetManagedIterator()
120120
{
121121
return new CollectionEnumerator(_structure.GetManagedIterator());
122122
}
123-
124-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
125123

126124
#endregion
127125

src/OneScript.StandardLibrary/Collections/StructureImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ public CollectionEnumerator GetManagedIterator()
196196
return new CollectionEnumerator(GetEnumerator());
197197
}
198198

199-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
200-
201199
#endregion
202200

203201
#region IEnumerable<IValue> Members

src/OneScript.StandardLibrary/Collections/ValueTable/ValueTableColumnCollection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,5 @@ void IDebugPresentationAcceptor.Accept(IDebugValueVisitor visitor)
281281
{
282282
visitor.ShowProperties(this);
283283
}
284-
285-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
286284
}
287285
}

src/OneScript.StandardLibrary/Collections/ValueTable/ValueTableRow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public int Count()
3131
return Owner().Columns.Count();
3232
}
3333

34-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
35-
3634
/// <summary>
3735
/// Владелец строки
3836
/// </summary>

src/OneScript.StandardLibrary/Collections/ValueTree/ValueTreeColumnCollection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
207207
return GetEnumerator();
208208
}
209209

210-
bool IEmptyValueCheck.IsEmpty => _columns.Count == 0;
211-
212210
public CollectionEnumerator GetManagedIterator()
213211
{
214212
return new CollectionEnumerator(GetEnumerator());

src/OneScript.StandardLibrary/Collections/ValueTree/ValueTreeRow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public int Count()
4343
return _properties.Count + _owner.Columns.Count();
4444
}
4545

46-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
47-
4846
[ContextProperty("Родитель", "Parent")]
4947
public IValue Parent
5048
{

src/OneScript.StandardLibrary/Regex/MatchCollectionImpl.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ public override int Count()
3636
return _matches.Count;
3737
}
3838

39-
public CollectionEnumerator GetManagedIterator()
40-
{
41-
return new CollectionEnumerator(GetEnumerator());
42-
}
43-
4439
#endregion
4540

4641
#region IEnumerable<IRuntimeContextInstance> Members

src/OneScript.StandardLibrary/StandardGlobalContext.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ public bool ValueIsFilled(IValue inValue)
120120
return false;
121121
}
122122

123-
if (value is IEmptyValueCheck emptyHandler)
123+
switch (value)
124124
{
125-
return !emptyHandler.IsEmpty;
125+
case IEmptyValueCheck emptyHandler:
126+
return !emptyHandler.IsEmpty;
127+
case ICollectionContext collection:
128+
return collection.Count() != 0;
129+
default:
130+
return true;
126131
}
127-
128-
return true;
129132
}
130133

131134
/// <summary>

src/ScriptEngine/Machine/Contexts/AutoCollectionContext.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ protected AutoCollectionContext(TypeDescriptor type) : base(type)
2424
{
2525
}
2626

27-
bool IEmptyValueCheck.IsEmpty => Count() == 0;
28-
2927
public abstract int Count();
3028

3129
public abstract IEnumerator<TItem> GetEnumerator();

src/ScriptEngine/Machine/Contexts/COMWrapperContext.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ This Source Code Form is subject to the terms of the
1414
namespace ScriptEngine.Machine.Contexts
1515
{
1616
[ContextClass("COMОбъект", "COMObject", TypeUUID = "5E4FA60E-9724-494A-A5C8-5BB0A4F914E0")]
17-
public abstract class COMWrapperContext : PropertyNameIndexAccessor, ICollectionContext, IDisposable, IObjectWrapper, IEnumerable<IValue>
17+
public abstract class COMWrapperContext : PropertyNameIndexAccessor,
18+
ICollectionContext,
19+
IEmptyValueCheck,
20+
IDisposable,
21+
IObjectWrapper,
22+
IEnumerable<IValue>
1823
{
1924
private static readonly DateTime MIN_OLE_DATE = new DateTime(100,1,1);
2025
protected static readonly TypeDescriptor ComObjectType = typeof(COMWrapperContext).GetTypeFromClassMarkup();

0 commit comments

Comments
 (0)