本文整理汇总了C#中System.Collections.IList类的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IList类的具体用法?C# System.Collections.IList怎么用?C# System.Collections.IList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Collections.IList类属于命名空间,在下文中一共展示了System.Collections.IList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListToString
/// <summary>
/// Returns a string representation of this IList.
/// </summary>
/// <remarks>
/// The string representation is a list of the collection's elements in the order
/// they are returned by its IEnumerator, enclosed in square brackets ("[]").
/// The separator is a comma followed by a space i.e. ", ".
/// </remarks>
/// <param name="coll">Collection whose string representation will be returned</param>
/// <returns>A string representation of the specified collection or "null"</returns>
public static string ListToString(IList coll)
{
StringBuilder sb = new StringBuilder();
if (coll != null)
{
sb.Append("[");
for (int i = 0; i < coll.Count; i++)
{
if (i > 0)
sb.Append(", ");
object element = coll[i];
if (element == null)
sb.Append("null");
else if (element is IDictionary)
sb.Append(DictionaryToString((IDictionary)element));
else if (element is IList)
sb.Append(ListToString((IList)element));
else
sb.Append(element.ToString());
}
sb.Append("]");
}
else
sb.Insert(0, "null");
return sb.ToString();
}
示例2: BitSet
/// <summary>Construction from a list of integers </summary>
public BitSet(IList items)
: this(BITS)
{
for (int i = 0; i < items.Count; i++)
{
int v = (int)items[i];
Add(v);
}
}
示例3: DisjunctionSumScorer
/// <summary>Construct a <code>DisjunctionScorer</code>.</summary>
/// <param name="subScorers">A collection of at least two subscorers.
/// </param>
/// <param name="minimumNrMatchers">The positive minimum number of subscorers that should
/// match to match this query.
/// <br>When <code>minimumNrMatchers</code> is bigger than
/// the number of <code>subScorers</code>,
/// no matches will be produced.
/// <br>When minimumNrMatchers equals the number of subScorers,
/// it more efficient to use <code>ConjunctionScorer</code>.
/// </param>
public DisjunctionSumScorer(System.Collections.IList subScorers, int minimumNrMatchers) : base(null)
{
nrScorers = subScorers.Count;
if (minimumNrMatchers <= 0)
{
throw new System.ArgumentException("Minimum nr of matchers must be positive");
}
if (nrScorers <= 1)
{
throw new System.ArgumentException("There must be at least 2 subScorers");
}
this.minimumNrMatchers = minimumNrMatchers;
this.subScorers = subScorers;
}
示例4: GetUserPreferenceChangedList
static private void GetUserPreferenceChangedList()
{
Type oSystemEventsType = typeof(SystemEvents);
//Using reflection, get the FieldInfo object for the internal collection of handlers
// we will use this collection to find the handler we want to unhook and remove it.
// as you can guess by the naming convention it is a private member.
System.Reflection.FieldInfo oFieldInfo = oSystemEventsType.GetField("_handlers",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.GetField |
System.Reflection.BindingFlags.FlattenHierarchy |
System.Reflection.BindingFlags.NonPublic);
//now, get a reference to the value of this field so that you can manipulate it.
//pass null to GetValue() because we are working with a static member.
object oFieldInfoValue = oFieldInfo.GetValue(null);
//the returned object is of type Dictionary<object, List<SystemEventInvokeInfo>>
//each of the Lists<> in the Dictionary<> is used to maintain a different event implementation.
//It may be more efficient to figure out how the UserPreferenceChanged event is keyed here but a quick-and-dirty
// method is to just scan them all the first time and then cache the List<> object once it's found.
System.Collections.IDictionary dictFieldInfoValue = oFieldInfoValue as System.Collections.IDictionary;
foreach (object oEvent in dictFieldInfoValue)
{
System.Collections.DictionaryEntry deEvent = (System.Collections.DictionaryEntry)oEvent;
System.Collections.IList listEventListeners = deEvent.Value as System.Collections.IList;
//unfortunately, SystemEventInvokeInfo is a private class so we can't declare a reference of that type.
//we will use object and then use reflection to get what we need...
List<Delegate> listDelegatesToRemove = new List<Delegate>();
//we need to take the first item in the list, get it's delegate and check the type...
if (listEventListeners.Count > 0 && listEventListeners[0] != null)
{
Delegate oDelegate = GetDelegateFromSystemEventInvokeInfo(listEventListeners[0]);
if (oDelegate is UserPreferenceChangedEventHandler)
{ _UserPreferenceChangedList = listEventListeners; }
}
//if we've found the list, no need to continue searching
if (_UserPreferenceChangedList != null) break;
}
}
示例5: AddChildren
/// <summary>
/// Add all elements of kids list as children of this node
/// </summary>
/// <param name="kids"></param>
public void AddChildren(IList kids)
{
for (int i = 0; i < kids.Count; i++)
{
ITree t = (ITree) kids[i];
AddChild(t);
}
}
示例6: FindTreeWizardContextVisitor
public FindTreeWizardContextVisitor( TreeWizard outer, TreePattern tpattern, IList subtrees )
{
_outer = outer;
_tpattern = tpattern;
_subtrees = subtrees;
}
示例7: ToArray
protected int[] ToArray(IList a)
{
int[] x = new int[a.Count];
a.CopyTo(x, 0);
return x;
}
示例8: AddOffCorrectMap
protected internal virtual void AddOffCorrectMap(int off, int cumulativeDiff)
{
if (pcmList == null)
{
pcmList = new System.Collections.ArrayList();
}
pcmList.Add(new OffCorrectMap(off, cumulativeDiff));
}
示例9: AddParameter
public virtual NeoDatis.Odb.Core.IError AddParameter(object o)
{
if (parameters == null)
{
parameters = new System.Collections.ArrayList();
}
parameters.Add(o != null ? o.ToString() : "null");
return this;
}
示例10: AddProfile
public virtual void AddProfile(NeoDatis.Odb.Test.Update.Nullobject.Profile profile
)
{
if (listProfile == null)
{
listProfile = new System.Collections.ArrayList();
}
listProfile.Add(profile);
}
示例11: Student
public Student(int age, NeoDatis.Odb.Test.VO.School.Course course, System.DateTime
date, string id, string name)
{
this.age = age;
this.course = course;
firstDate = date;
this.id = id;
this.name = name;
listHistory = new System.Collections.ArrayList();
}
示例12: find
public void find(out PasswordInfo mainAsmPassword, out PasswordInfo embedPassword)
{
var asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("asm"), AssemblyBuilderAccess.Run);
var moduleBuilder = asmBuilder.DefineDynamicModule("mod");
var serializedTypes = new SerializedTypes(moduleBuilder);
var allTypes = serializedTypes.deserialize(serializedData);
asmTypes = toList(readField(allTypes, "Types"));
mainAsmPassword = findMainAssemblyPassword();
embedPassword = findEmbedPassword();
}
示例13: Next
public override Token Next()
{
if (cache == null)
{
// fill cache lazily
cache = new System.Collections.ArrayList();
FillCache();
iterator = cache.GetEnumerator();
}
if (!iterator.MoveNext())
{
// the cache is exhausted, return null
return null;
}
return (Token) iterator.Current;
}
示例14: IncrementToken
public override bool IncrementToken()
{
if (cache == null)
{
// fill cache lazily
cache = new System.Collections.ArrayList();
FillCache();
iterator = cache.GetEnumerator();
}
if (!iterator.MoveNext())
{
// the cache is exhausted, return false
return false;
}
// Since the TokenFilter can be reset, the tokens need to be preserved as immutable.
RestoreState((AttributeSource.State) iterator.Current);
return true;
}
示例15: Next
public override Token Next(/* in */ Token reusableToken)
{
System.Diagnostics.Debug.Assert(reusableToken != null);
if (cache == null)
{
// fill cache lazily
cache = new System.Collections.ArrayList();
FillCache(reusableToken);
iterator = cache.GetEnumerator();
}
if (!iterator.MoveNext())
{
// the cache is exhausted, return null
return null;
}
Token nextToken = (Token) iterator.Current;
return (Token) nextToken.Clone();
}