本文整理汇总了C#中System.Collections.IList类的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IList类的具体用法?C# System.Collections.IList怎么用?C# System.Collections.IList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Collections.IList类属于命名空间,在下文中一共展示了System.Collections.IList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:Fedorm,项目名称:core-master,代码行数:40,代码来源:CollectionUtils.cs
示例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);
}
}
开发者ID:Fedorm,项目名称:core-master,代码行数:10,代码来源:BitSet.cs
示例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;
}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:28,代码来源:DisjunctionSumScorer.cs
示例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;
}
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:43,代码来源:LeakHelper.cs
示例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);
}
}
开发者ID:sebasjm,项目名称:antlr,代码行数:12,代码来源:BaseTree.cs
示例6: FindTreeWizardContextVisitor
public FindTreeWizardContextVisitor( TreeWizard outer, TreePattern tpattern, IList subtrees )
{
_outer = outer;
_tpattern = tpattern;
_subtrees = subtrees;
}
开发者ID:ksmyth,项目名称:antlr,代码行数:6,代码来源:TreeWizard.cs
示例7: ToArray
protected int[] ToArray(IList a)
{
int[] x = new int[a.Count];
a.CopyTo(x, 0);
return x;
}
开发者ID:nikola-v,项目名称:jaustoolset,代码行数:6,代码来源:Profiler.cs
示例8: GetErrors
/// <summary>
/// Returns a page of errors from the databse in descending order
/// of logged time.
/// </summary>
public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
{
if (pageIndex < 0)
throw new ArgumentOutOfRangeException("pageIndex", pageIndex, null);
if (pageSize < 0)
throw new ArgumentOutOfRangeException("pageSize", pageSize, null);
using (OleDbConnection connection = new OleDbConnection(this.ConnectionString))
using (OleDbCommand command = connection.CreateCommand())
{
command.CommandType = CommandType.Text;
command.CommandText = "SELECT COUNT(*) FROM ELMAH_Error";
connection.Open();
int totalCount = (int)command.ExecuteScalar();
if (errorEntryList != null && pageIndex * pageSize < totalCount)
{
int maxRecords = pageSize * (pageIndex + 1);
if (maxRecords > totalCount)
{
maxRecords = totalCount;
pageSize = totalCount - pageSize * (totalCount / pageSize);
}
StringBuilder sql = new StringBuilder(1000);
sql.Append("SELECT e.* FROM (");
sql.Append("SELECT TOP ");
sql.Append(pageSize.ToString(CultureInfo.InvariantCulture));
sql.Append(" TimeUtc, ErrorId FROM (");
sql.Append("SELECT TOP ");
sql.Append(maxRecords.ToString(CultureInfo.InvariantCulture));
sql.Append(" TimeUtc, ErrorId FROM ELMAH_Error ");
sql.Append("ORDER BY TimeUtc DESC, ErrorId DESC) ");
sql.Append("ORDER BY TimeUtc ASC, ErrorId ASC) AS i ");
sql.Append("INNER JOIN Elmah_Error AS e ON i.ErrorId = e.ErrorId ");
sql.Append("ORDER BY e.TimeUtc DESC, e.ErrorId DESC");
command.CommandText = sql.ToString();
using (OleDbDataReader reader = command.ExecuteReader())
{
Debug.Assert(reader != null);
while (reader.Read())
{
string id = Convert.ToString(reader["ErrorId"], CultureInfo.InvariantCulture);
Error error = new Error();
error.ApplicationName = reader["Application"].ToString();
error.HostName = reader["Host"].ToString();
error.Type = reader["Type"].ToString();
error.Source = reader["Source"].ToString();
error.Message = reader["Message"].ToString();
error.User = reader["UserName"].ToString();
error.StatusCode = Convert.ToInt32(reader["StatusCode"]);
error.Time = Convert.ToDateTime(reader["TimeUtc"]).ToLocalTime();
errorEntryList.Add(new ErrorLogEntry(this, id, error));
}
reader.Close();
}
}
return totalCount;
}
}
开发者ID:buddydvd,项目名称:elmah-mirror,代码行数:74,代码来源:AccessErrorLog.cs
示例9: StringTemplateToken
public StringTemplateToken(int type, string text, IList args)
: base(type, text)
{
this.args = args;
}
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:5,代码来源:StringTemplateToken.cs
示例10: SetListHistory
public virtual void SetListHistory(System.Collections.IList listHistory)
{
this.listHistory = listHistory;
}
开发者ID:ekicyou,项目名称:pasta,代码行数:4,代码来源:Student.cs
示例11: FindTreeWizardVisitor
public FindTreeWizardVisitor( IList nodes )
{
_nodes = nodes;
}
开发者ID:ksmyth,项目名称:antlr,代码行数:4,代码来源:TreeWizard.cs
示例12: AddOffCorrectMap
protected internal virtual void AddOffCorrectMap(int off, int cumulativeDiff)
{
if (pcmList == null)
{
pcmList = new System.Collections.ArrayList();
}
pcmList.Add(new OffCorrectMap(off, cumulativeDiff));
}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:8,代码来源:BaseCharFilter.cs
示例13: 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;
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:9,代码来源:BTreeError.cs
示例14: AddProfile
public virtual void AddProfile(NeoDatis.Odb.Test.Update.Nullobject.Profile profile
)
{
if (listProfile == null)
{
listProfile = new System.Collections.ArrayList();
}
listProfile.Add(profile);
}
开发者ID:ekicyou,项目名称:pasta,代码行数:9,代码来源:Functions.cs
示例15: 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();
}
开发者ID:ekicyou,项目名称:pasta,代码行数:10,代码来源:Student.cs
示例16: 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();
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:11,代码来源:PasswordFinder.cs
示例17: 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;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:18,代码来源:CachingTokenFilter.cs
示例18: 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;
}
开发者ID:carrie901,项目名称:mono,代码行数:19,代码来源:CachingTokenFilter.cs
示例19: 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();
}
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:20,代码来源:CachingTokenFilter.cs
示例20: AddChild
/// <summary>
/// Add t as child of this node.
/// </summary>
/// <remarks>
/// Warning: if t has no children, but child does and child isNil then
/// this routine moves children to t via t.children = child.children;
/// i.e., without copying the array.
/// </remarks>
/// <param name="t"></param>
public virtual void AddChild(ITree t)
{
if (t == null)
{
return;
}
BaseTree childTree = (BaseTree)t;
if (childTree.IsNil) // t is an empty node possibly with children
{
if ((children != null) && (children == childTree.children))
{
throw new InvalidOperationException("attempt to add child list to itself");
}
// just add all of childTree's children to this
if (childTree.children != null)
{
if (children != null) // must copy, this has children already
{
int n = childTree.children.Count;
for (int i = 0; i < n; i++)
{
ITree c = (ITree)childTree.Children[i];
children.Add(c);
// handle double-link stuff for each child of nil root
c.Parent = this;
c.ChildIndex = children.Count - 1;
}
}
else
{
// no children for this but t has children; just set pointer
// call general freshener routine
children = childTree.children;
FreshenParentAndChildIndexes();
}
}
}
else
{
// child is not nil (don't care about children)
if (children == null)
{
children = CreateChildrenList(); // create children list on demand
}
children.Add(t);
childTree.Parent = this;
childTree.ChildIndex = children.Count - 1;
}
}
开发者ID:sebasjm,项目名称:antlr,代码行数:59,代码来源:BaseTree.cs
注:本文中的System.Collections.IList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论