本文整理汇总了C#中System.Collections.ArrayList.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.MoveNext方法的具体用法?C# ArrayList.MoveNext怎么用?C# ArrayList.MoveNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.MoveNext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAll
/// <summary>
/// Adds all of the elements of the "c" collection to the "target" collection.
/// </summary>
/// <param name="target">Collection where the new elements will be added.</param>
/// <param name="c">Collection whose elements will be added.</param>
/// <returns>Returns true if at least one element was added, false otherwise.</returns>
public static bool AddAll(System.Collections.ICollection target, System.Collections.ICollection c)
{
System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator();
bool added = false;
//Reflection. Invoke "addAll" method for proprietary classes
System.Reflection.MethodInfo method;
try
{
method = target.GetType().GetMethod("addAll");
if (method != null)
added = (bool) method.Invoke(target, new System.Object[] {c});
else
{
method = target.GetType().GetMethod("Add");
while (e.MoveNext() == true)
{
bool tempBAdded = (int) method.Invoke(target, new System.Object[] {e.Current}) >= 0;
added = added ? added : tempBAdded;
}
}
}
catch (System.Exception ex)
{
throw ex;
}
return added;
}
示例2: AddAll
/// <summary>
/// Adds all the elements of the specified collection that are not present to the list.
/// </summary>
/// <param name="c">Collection where the new elements will be added</param>
/// <returns>Returns true if at least one element was added, false otherwise.</returns>
public bool AddAll(System.Collections.ICollection c)
{
System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator();
bool added = false;
while (e.MoveNext() == true)
{
if (this.Add(e.Current) == true)
added = true;
}
return added;
}
示例3: AddAll
public bool AddAll(ICollection c)
{
IEnumerator enumerator = new ArrayList(c).GetEnumerator();
bool flag = false;
while (enumerator.MoveNext())
{
if (this.Add(enumerator.Current))
{
flag = true;
}
}
return flag;
}
示例4: AddAll
public bool AddAll(ICollection c)
{
IEnumerator e = new ArrayList(c).GetEnumerator();
bool added = false;
while (e.MoveNext())
{
if (AddWithoutSorting(e.Current))
{
added = true;
}
}
Sort(comparator);
return added;
}
示例5: AddAll
/// <summary>
/// Adds all the elements of the specified collection that are not present to the list.
/// </summary>
/// <param name="c">Collection where the new elements will be added</param>
/// <returns>Returns true if at least one element was added, false otherwise.</returns>
public bool AddAll(ICollection c)
{
IEnumerator e = new ArrayList(c).GetEnumerator();
bool added = false;
while (e.MoveNext() == true)
{
if (Add(e.Current) == true)
{
added = true;
}
}
return added;
}
示例6: AddAll
/// <summary>
/// Adds all the elements contained into the specified collection, starting at the specified position.
/// </summary>
/// <param name="index">Position at which to add the first element from the specified collection.</param>
/// <param name="list">The list used to extract the elements that will be added.</param>
/// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
public static bool AddAll(IList list, int index, ICollection c)
{
bool result = false;
if (c != null)
{
IEnumerator tempEnumerator = new ArrayList(c).GetEnumerator();
int tempIndex = index;
while (tempEnumerator.MoveNext())
{
list.Insert(tempIndex++, tempEnumerator.Current);
result = true;
}
}
return result;
}
示例7: AddAll
public static bool AddAll(ICollection target, ICollection c)
{
IEnumerator enumerator = new ArrayList(c).GetEnumerator();
bool flag = false;
try
{
MethodInfo method = target.GetType().GetMethod("addAll");
if (method != null)
{
return (bool) method.Invoke(target, new object[] { c });
}
method = target.GetType().GetMethod("Add");
while (enumerator.MoveNext())
{
bool flag2 = ((int) method.Invoke(target, new object[] { enumerator.Current })) >= 0;
flag = flag ? flag : flag2;
}
}
catch (Exception exception)
{
throw exception;
}
return flag;
}
示例8: RetainAll
/// <summary>
/// Retains the Elements in the target collection that are contained in the specified collection
/// </summary>
/// <param name="target">Collection where the Elements will be removed.</param>
/// <param name="c">Elements to be retained in the target collection.</param>
/// <returns>true</returns>
public static bool RetainAll(ICollection target, ICollection c)
{
IEnumerator e = new ArrayList(target).GetEnumerator();
var al = new ArrayList(c);
//Reflection. Invoke "retainAll" method for proprietary classes or "Remove" for each Element in the collection
System.Reflection.MethodInfo method;
try
{
method = c.GetType().GetMethod("retainAll");
if (method != null)
method.Invoke(target, new Object[] {c});
else
{
method = c.GetType().GetMethod("Remove");
while (e.MoveNext())
{
if (al.Contains(e.Current) == false)
method.Invoke(target, new[] {e.Current});
}
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
示例9: RemoveAll
/// <summary>
/// Removes all the elements contained into the specified collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be removed.</param>
/// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
public virtual bool RemoveAll(System.Collections.ICollection collection)
{
bool result = false;
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
{
if (this.Contains(tempEnumerator.Current))
result = this.Remove(tempEnumerator.Current);
}
return result;
}
示例10: ContainsAll
/// <summary>
/// Verifies if all the elements of the specified collection are contained into the current collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be verified.</param>
/// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
public virtual bool ContainsAll(System.Collections.ICollection collection)
{
bool result = false;
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
if (!(result = this.Contains(tempEnumerator.Current)))
break;
return result;
}
示例11: AddAll
/// <summary>
/// Adds all the elements contained in the specified collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be added.</param>
/// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
public virtual bool AddAll(System.Collections.ICollection collection)
{
bool result = false;
if (collection!=null)
{
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
{
if (tempEnumerator.Current != null)
result = this.Add(tempEnumerator.Current);
}
}
return result;
}
示例12: RemoveAll
/// <summary>
/// Removes all the elements contained into the specified collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be removed.</param>
/// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
public virtual bool RemoveAll(ICollection collection)
{
bool result = false;
IEnumerator tempEnumerator = new ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
{
result = true;
if (base.Contains(tempEnumerator.Current))
base.Remove(tempEnumerator.Current);
}
return result;
}
示例13: RetainAll
public static bool RetainAll(ICollection target, ICollection c)
{
IEnumerator enumerator = new ArrayList(target).GetEnumerator();
ArrayList list = new ArrayList(c);
try
{
MethodInfo method = c.GetType().GetMethod("retainAll");
if (method != null)
{
method.Invoke(target, new object[] { c });
}
else
{
method = c.GetType().GetMethod("Remove");
while (enumerator.MoveNext())
{
if (!list.Contains(enumerator.Current))
{
method.Invoke(target, new object[] { enumerator.Current });
}
}
}
}
catch (Exception exception)
{
throw exception;
}
return true;
}
示例14: ChangeSessionIdentifier
/// <summary> Invalidate the old session after copying all of its contents to a newly created session with a new session id.
/// Note that this is different from logging out and creating a new session identifier that does not contain the
/// existing session contents. Care should be taken to use this only when the existing session does not contain
/// hazardous contents.
///
/// </summary>
/// <returns> The invaldiated session.
/// </returns>
/// <seealso cref="Owasp.Esapi.Interfaces.IHttpUtilities.ChangeSessionIdentifier()">
/// </seealso>
public IHttpSession ChangeSessionIdentifier()
{
IHttpRequest request = ((Authenticator) Esapi.Authenticator()).CurrentRequest;
IHttpResponse response = ((Authenticator) Esapi.Authenticator()).CurrentResponse;
IHttpSession session = ((Authenticator)Esapi.Authenticator()).CurrentSession;
IDictionary temp = new Hashtable();
// make a copy of the session content
IEnumerator e = session.GetEnumerator();
while (e != null && e.MoveNext())
{
string name = (string) e.Current;
object val = session[name];
temp[name] = val;
}
// invalidate the old session and create a new one
// This hack comes from here: http://support.microsoft.com/?kbid=899918
session.Abandon();
response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
// copy back the session content
IEnumerator i = new ArrayList(temp).GetEnumerator();
while (i.MoveNext())
{
DictionaryEntry entry = (DictionaryEntry) i.Current;
session.Add((string) entry.Key, entry.Value);
}
return session;
}