Skip to content

Commit 2705218

Browse files
Add new methods for collections.
1 parent d9882e0 commit 2705218

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,54 @@ public GXBaseList()
4545
base.Insert(idx, TObject);
4646
IsAssigned = true;
4747
}
48+
public bool AddRange(GXBaseList<T> value, int? index)
49+
{
50+
if (!index.HasValue)
51+
{
52+
base.AddRange(value);
53+
return true;
54+
}
55+
else if (index == 0)
56+
{
57+
base.InsertRange(index.Value, value);
58+
return true;
59+
}
60+
else if (index > 0 && index <= Count+1)
61+
{
62+
base.InsertRange(index.Value - 1, value);
63+
return true;
64+
}
65+
return false;
66+
}
67+
public bool RemoveRange(int index, int? countItemsToRemove)
68+
{
69+
if (index > 0 && index <= Count)
70+
{
71+
if (countItemsToRemove == null)
72+
{
73+
int countToRemove = Count - (index-1);
74+
base.RemoveRange(index - 1, countToRemove);
75+
return true;
76+
}
77+
else if (countItemsToRemove.Value < Count - index)
78+
{
79+
base.RemoveRange(index - 1, countItemsToRemove.Value);
80+
return true;
81+
}
82+
}
83+
return false;
84+
}
85+
86+
public bool Set(int index, T value)
87+
{
88+
if (index > 0 && index < Count)
89+
{
90+
this[index - 1] = value;
91+
return true;
92+
}
93+
return false;
94+
}
95+
4896
}
4997

5098
[Serializable]

0 commit comments

Comments
 (0)