Esempio n. 1
0
        public static void AddArray <T>(this List <T> list, T[] itemsToAdd, int itemCount)
        {
            if (list.Capacity < list.Count + itemCount)
            {
                list.Capacity = list.Count + itemCount;
            }

            Array.Copy(itemsToAdd, 0, list.GetInternalArray(), list.Count, itemCount);
            ListInternalAccessor <T> .SetSize(list, list.Count + itemCount);
        }
Esempio n. 2
0
        public static void SetSize <T>(this List <T> list, int newSize)
        {
#if XB1 // XB1_LISTEXTENSIONS_NOEMIT
            var sizeField = list.GetType().GetField("_size",
                                                    System.Reflection.BindingFlags.Instance |
                                                    System.Reflection.BindingFlags.NonPublic);
            sizeField.SetValue(list, newSize);
            var versionField = list.GetType().GetField("_version",
                                                       System.Reflection.BindingFlags.Instance |
                                                       System.Reflection.BindingFlags.NonPublic);
            versionField.SetValue(list, (int)versionField.GetValue(list) + 1);
#else // !XB1
            ListInternalAccessor <T> .SetSize(list, newSize);
#endif // !XB1
        }
Esempio n. 3
0
        public static void AddArray <T>(this List <T> list, T[] itemsToAdd, int itemCount)
        {
            if (list.Capacity < list.Count + itemCount)
            {
                list.Capacity = list.Count + itemCount;
            }

            Array.Copy(itemsToAdd, 0, list.GetInternalArray(), list.Count, itemCount);
#if XB1 // XB1_LISTEXTENSIONS_NOEMIT
            var sizeField = list.GetType().GetField("_size",
                                                    System.Reflection.BindingFlags.Instance |
                                                    System.Reflection.BindingFlags.NonPublic);
            sizeField.SetValue(list, list.Count + itemCount);
            var versionField = list.GetType().GetField("_version",
                                                       System.Reflection.BindingFlags.Instance |
                                                       System.Reflection.BindingFlags.NonPublic);
            versionField.SetValue(list, (int)versionField.GetValue(list) + 1);
#else // !XB1
            ListInternalAccessor <T> .SetSize(list, list.Count + itemCount);
#endif // !XB1
        }
Esempio n. 4
0
 public static T[] GetInternalArray <T>(this List <T> list)
 {
     return(ListInternalAccessor <T> .GetArray(list));
 }
Esempio n. 5
0
 public static void SetSize <T>(this List <T> list, int newSize)
 {
     ListInternalAccessor <T> .SetSize(list, newSize);
 }