int [] a = new int [10];
IList b = a;
object c = b [-1];
Assert.Fail ("IList.this [-1] should throw");
[Category ("TargetJvmNotSupported")] // Arrays lower bounds are not supported for TARGET_JVM
public void TestIList_Add () {
try {
((IList)myArray).Add ("can not");
Assert.Fail ("IList.Add should throw");
}
catch (Exception) {
Assert.Fail ("IList.Add threw wrong exception type");
try {
((IList)myArray).Remove ("can not");
Assert.Fail ("IList.Remove should throw");
}
List list = CreateTestData();
BinaryFormatter f = new BinaryFormatter (sel, new StreamingContext(StreamingContextStates.Other));
f.Serialize (ms, list);
object list = f.Deserialize (ms);
list.name = "my list";
list.values = new SomeValues();
list.values.Init();
ListItem item1 = new ListItem();
ListItem item2 = new ListItem();
ListItem item3 = new ListItem();
list.children = new ListItem[3];
public void Add () {
var cwt = new ConditionalWeakTable <object,object> ();
public void TryGetValue () {
var cwt = new ConditionalWeakTable <object,object> ();
static void FillStuff (ConditionalWeakTable <object,object> cwt,
out List<object> keepAlive, out List<WeakReference> keys) {
keepAlive = new List<object> ();
keys = new List<WeakReference> ();
var cwt = new ConditionalWeakTable <object,object> ();
List<object> keepAlive;
List<WeakReference> keys;
static List<WeakReference> FillWithNetwork (ConditionalWeakTable <object,object> cwt)
List <int> indices = state.First as List <int>;
List <object> states = state.Second as List <object>;
List <object> types = state.Third as List <object>;
IList list = this as IList;
item.LoadViewState (states [i]);
list.Add (item);
if (idx < Count) {
item = list [idx] as IStateManager;
item.LoadViewState (states [i]);
list.Add (item);
void AddListItem <T> (ref List <T> list, T item)
{
List <int> indices = null;
List <object> states = null;
List <object> types = null;
Type elementType = modelType.GetElementType();
Type listType = typeof(List<>).MakeGenericType(elementType);
object collection = CreateModel(controllerContext, bindingContext, listType);
ModelBindingContext arrayBindingContext = new ModelBindingContext() {
ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => collection, listType),
// we can understand some collection interfaces, e.g. IList<>, IDictionary<,>
}
else if (genericTypeDefinition == typeof(IEnumerable<>) || genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IList<>)) {
typeToCreate = typeof(List<>).MakeGenericType(modelType.GetGenericArguments());
// build up a list of items from the request
List<object> modelList = new List<object>();
foreach (string currentIndex in indexes) {
// if we're being asked to create an array, create a list instead, then coerce to an array after the list is created
Type elementType = modelType.GetElementType();
Type listType = typeof(List<>).MakeGenericType(elementType);
object collection = CreateModel(controllerContext, bindingContext, listType);
};
IList list = (IList)UpdateCollection(controllerContext, arrayBindingContext, elementType);
// build up a list of items from the request
List<object> modelList = new List<object>();
foreach (string currentIndex in indexes) {
AddValueRequiredMessageToModelState(controllerContext, bindingContext.ModelState, subIndexKey, elementType, thisElement);
modelList.Add(thisElement);
// if we're being asked to create an array, create a list instead, then coerce to an array after the list is created
// we can understand some collection interfaces, e.g. IList<>, IDictionary<,>
}
else if (genericTypeDefinition == typeof(IEnumerable<>) || genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IList<>)) {
typeToCreate = typeof(List<>).MakeGenericType(modelType.GetGenericArguments());
}
// build up a list of items from the request
List<object> modelList = new List<object>();
for (int currentIndex = 0; ; currentIndex++) {
VerifyValueUsability(controllerContext, bindingContext.ModelState, subIndexKey, elementType, thisElement);
modelList.Add(thisElement);
// if there weren't any elements at all in the request, just return
if (modelList.Count == 0) {
if (obj is IDictionary<string, object>) {
if (targetType == null)
obj = EvaluateDictionary ((IDictionary<string, object>) obj);
return converter.Deserialize (
EvaluateDictionary ((IDictionary<string, object>) obj),
return ConvertToObject ((IDictionary<string, object>) obj, targetType);
}
if (obj is ArrayList)
return ConvertToList ((ArrayList) obj, targetType);
if (value is IDictionary<string, object>)
value = EvaluateDictionary ((IDictionary<string, object>) value, convertListToArray);
else if (value is ArrayList)
List list = CreateTestData();
SoapFormatter f = new SoapFormatter (sel, new StreamingContext(StreamingContextStates.Other));
f.Serialize (ms, list);
ListItem item1 = new ListItem();
ListItem item2 = new ListItem();
ListItem item3 = new ListItem();
list.children = new ListItem[3];
list.children[0] = item1;
list.children[1] = item2;
list.children[2] = item3;
/// </summary>
public abstract class CustomSymbolDictionary : BaseSymbolDictionary, IDictionary, IDictionary<object, object>, IAttributesCollection {
private Dictionary<SymbolId, object> _data;
/// <summary>
/// Gets a list of the extra keys that are cached by the the optimized implementation
/// Try to set the extra value and return true if the specified key was found in the
/// list of extra values.
/// Try to get the extra value and returns true if the specified key was found in the
/// list of extra values. Returns true even if the value is Uninitialized.
_data = new Dictionary<SymbolId, object>();
/// </summary>
private Dictionary<object, object> GetObjectKeysDictionary() {
Dictionary<object, object> objData = GetObjectKeysDictionaryIfExists();
ICollection<object> IDictionary<object, object>.Keys {
// the new context creates the model if one doesn't already exist
Func<object> modelProvider = () => bindingContext.Model ?? CreateModel(bindingContext, bindingContext.ModelType);
// if ICollection<T> where T is a simple type, use simple list binding logic rather than custom list binding logic
// compare the current property against the list of allowed properties for this type
protected ModelBinderResult BindProperty(ModelBindingContext parentContext, Type propertyType, Func<object> propertyValueProvider, string propertyName) {
// case 1: both destination + source type are arrays, so convert each element
IList converted = Array.CreateInstance(destinationElementType, valueAsArray.Length);
object element = ConvertSimpleType(culture, value, destinationElementType);
IList converted = Array.CreateInstance(destinationElementType, 1);
// we can understand some collection interfaces, e.g. IList<>, IDictionary<,>
}
else if (genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IList<>)) {
//
// ListBindingHelperTest.cs: Test cases for ListBindingHelper class.
[TestFixture]
public class ListBindingHelperTest : TestHelper
[Test]
public void GetListTest ()
{
ListSource lsource = new ListSource (true);
Assert.IsTrue (ListBindingHelper.GetList (lsource) is SimpleItem [], "#A1");
Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList"), "#A2");
Assert.AreEqual (null, ListBindingHelper.GetList (null), "#A3");
Assert.AreEqual (stack, ListBindingHelper.GetList (stack), "#A4"); // IEnumerable
Assert.IsTrue (ListBindingHelper.GetList (lsource, String.Empty) is SimpleItem [], "#B1");
Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList", String.Empty), "#B2");
var i = new XamlTypeInvoker (new XamlType ("urn:foo", "FooType", null, sctx));
i.AddToCollection (new List<int> (), 5); // ... passes.
[Test]
public void AddToCollectionList_ObjectTypeMismatch ()
{
var i = new XamlTypeInvoker (new XamlType (typeof (List<int>), sctx));
[Test]
public void AddToCollectionList_ObjectTypeMismatch2 ()
{
var i = new XamlTypeInvoker (new XamlType (typeof (List<int>), sctx));
i.AddToCollection (new List<object> (), 5); // it is allowed.
}
{
var i = new XamlTypeInvoker (new XamlType (typeof (List<object>), sctx));
i.AddToCollection (new List<int> (), 5); // it is allowed too.
[Test]
public void AddToCollectionList ()
{
private readonly IDictionary<object, IDictionary<string, object>> rawDataEntities = new Dictionary<object, IDictionary<string, object>>(new ReferenceEqualityComparer<object>());
private readonly IDictionary<object, IDictionary<string, MemberInfo>> modifiedProperties = new Dictionary<object, IDictionary<string, MemberInfo>>(new ReferenceEqualityComparer<object>());
/// Unregisters an entity.
/// This is useful when it is switched from update to delete list
//Duplicate the list to not modify modifiedEntities
var modifiedEntities = new List<object>(modifiedProperties.Keys);
foreach (var entity in modifiedEntities)
/// <returns></returns>
protected IList<MemberInfo> GetAllColumnProperties(object entity, MetaModel metaModel)
throw new ArgumentNullException("entity");
var properties = new List<MemberInfo>(GetColumnMembers(entity.GetType(), metaModel));
/// <returns></returns>
protected IList<MemberInfo> GetSelfDeclaringModifiedProperties(object entity, MetaModel metaModel)
Assert.AreEqual (Utils.BuildActionName (t, PageAction.Insert), t.GetActionPath (PageAction.Insert), "#A3");
Assert.AreEqual (Utils.BuildActionName (t, PageAction.List), t.GetActionPath (PageAction.List), "#A4");
routes.Clear ();
routes.Add (new DynamicDataRoute ("{table}/ListDetails.aspx") {
Action = PageAction.List,
ViewName = "ListDetails",
Model = m,
routes.Add (new DynamicDataRoute ("{table}/ListDetails.aspx") {
Action = PageAction.Details,
MetaTable t = m.Tables[TestDataContext.TableFooWithDefaults];
Assert.AreEqual (String.Empty, t.GetActionPath (null, (IList<object>) null), "#A1");
Assert.AreEqual (String.Empty, t.GetActionPath (String.Empty, (IList<object>) null), "#A2");
Assert.AreEqual (String.Empty, t.GetActionPath ("BogusValue", (IList<object>) null), "#A3");
}
static List<ConstructorInfo> ok_constructors = new List<ConstructorInfo> ();
static List<string> ok_constructors_statements = new List<string> ();
static List<object []> ok_constructors_args = new List<object []> ();
return "@\"" + obj.ToString ().Replace ("\"", "\"\"") + "\"";
} else if (tp == typeof (List<int>.Enumerator)) {
list1 = (List<int>.Enumerator) v1;
list2 = (List<int>.Enumerator) v2;
int item1, item2;
do {
next1 = list1.MoveNext ();
next2 = list2.MoveNext ();
if (next1 ^ next2) {
}
item1 = list1.Current;
item2 = list2.Current;
//
// MonoTests.System.Collections.Generic.Test.ListTest
[TestFixture]
public class ListTest
{
static byte [] _serializedList = new byte [] {
0x0b };
int [] _list1_contents;
List <int> _list1;
int [] items = {1, 2, 3};
// List <int> newRange = new List <int> (items);
List <int> newRange = new List <int> (3);
foreach (int i in items)
newRange.Add (i);
_list1.InsertRange (1, newRange);
{
private static ArrayList registeredChannels = new ArrayList ();
private static ArrayList delayedClientChannels = new ArrayList ();
{
var list = new List<IChannel> ();
if (ch is CrossAppDomainChannel) continue;
list.Add (ch);
return list.ToArray ();
if (receiver != null && oldStartModeTypes.Contains (chnl.GetType().ToString ()))
receiver.StartListening (null);
if(chnlReceiver != null)
chnlReceiver.StopListening(null);
{
var list = new List<object> ();
[DebuggerTypeProxy (typeof (CollectionDebuggerView<>))]
public class Collection<T> : IList<T>, IList
#if NET_4_5
, IReadOnlyList<T>
{
IList <T> list;
{
List <T> l = new List <T> ();
IList l2 = l as IList;
syncRoot = l2.SyncRoot;
list = l;
public Collection (IList <T> list)
{
if (list == null)
throw new ArgumentNullException ("list");