Fix null sessions in HttpContextWrapper.Session
[mono.git] / mcs / class / System.Core / System.Linq.Parallel / RangeList.cs
1 //
2 // RangeList.cs
3 //
4 // Author:
5 //       Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
6 //
7 // Copyright (c) 2010 Jérémie "Garuma" Laval
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 #if NET_4_0
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31
32 namespace System.Linq.Parallel
33 {
34         internal class RangeList : IList<int>
35         {
36                 readonly int start;
37                 readonly int count;
38
39                 public RangeList (int start, int count)
40                 {
41                         this.start = start;
42                         this.count = count;
43                 }
44
45                 public int IndexOf (int item)
46                 {
47                         if (!Contains(item))
48                                 return -1;
49
50                         return item - start;
51                 }
52
53                 public void Insert (int index, int item)
54                 {
55                         throw new NotImplementedException();
56                 }
57
58                 public void RemoveAt (int index)
59                 {
60                         throw new NotImplementedException();
61                 }
62
63                 public int this[int index] {
64                         get {
65                                 if (start + index <= count)
66                                         return start + index;
67                                 else
68                                         return -1;
69                         }
70                         set {
71                                 throw new NotImplementedException();
72                         }
73                 }
74
75                 public void Add (int item)
76                 {
77                         throw new NotImplementedException();
78                 }
79
80                 public void Clear ()
81                 {
82                         throw new NotImplementedException();
83                 }
84
85                 public bool Contains (int item)
86                 {
87                         return start <= item && item <= start + count - 1;
88                 }
89
90                 public void CopyTo (int[] array, int arrayIndex)
91                 {
92                         int counter = start;
93                         for (int i = arrayIndex; i < array.Length && i < (i - arrayIndex) + count; i++)
94                                 array[i] = counter++;
95                 }
96
97                 public bool Remove (int item)
98                 {
99                         throw new NotImplementedException();
100                 }
101
102                 public int Count {
103                         get {
104                                 return count;
105                         }
106                 }
107
108                 public bool IsReadOnly {
109                         get {
110                                 return true;
111                         }
112                 }
113
114                 IEnumerator<int> IEnumerable<int>.GetEnumerator ()
115                 {
116                         return null;
117                 }
118
119                 IEnumerator IEnumerable.GetEnumerator ()
120                 {
121                         return null;
122                 }
123         }
124 }
125 #endif