本文整理汇总了C#中IList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Clear方法的具体用法?C# IList.Clear怎么用?C# IList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PurgePath
/// <summary>
/// Removes containing paths and merge overlapping paths.
/// </summary>
/// <param name="scaffoldPaths">Input paths/scaffold.</param>
public void PurgePath(IList<ScaffoldPath> scaffoldPaths)
{
if (scaffoldPaths != null && 0 != scaffoldPaths.Count)
{
this.internalScaffoldPaths = scaffoldPaths.AsParallel().OrderBy(t => t.Count).ToList();
bool isUpdated = true;
bool[] isConsumed = new bool[this.internalScaffoldPaths.Count];
while (isUpdated)
{
isUpdated = false;
for (int index = 0; index < this.internalScaffoldPaths.Count; index++)
{
if (null != this.internalScaffoldPaths[index] &&
0 != this.internalScaffoldPaths[index].Count && !isConsumed[index])
{
isUpdated |=
this.SearchContainingAndOverlappingPaths(this.internalScaffoldPaths[index], isConsumed);
}
else
{
isConsumed[index] = true;
}
}
}
this.UpdatePath(isConsumed);
scaffoldPaths.Clear();
((List<ScaffoldPath>)scaffoldPaths).AddRange(this.internalScaffoldPaths);
}
}
示例2: Apply
public void Apply(IList<IElement> elements, DecompilationContext context)
{
var results = new List<IElement>();
this.ProcessRange(elements, 0, results, new Dictionary<IElement, IElement>());
elements.Clear();
elements.AddRange(results);
}
示例3: Select
public void Select(IList<IIndividual> Individuals, int firstSize, int secondSize)
{
ElitismSelection eliteSelection = new ElitismSelection();
WheelSelection wheelSelection = new WheelSelection();
IList<IIndividual> eliteIndividuals = new List<IIndividual>();
IList<IIndividual> wheelIndividuals = new List<IIndividual>();
(Individuals as List<IIndividual>).ForEach(
i => {
eliteIndividuals.Add(i.Clone());
wheelIndividuals.Add(i.Clone());
}
);
eliteSelection.Select(eliteIndividuals, firstSize);
wheelSelection.Select(wheelIndividuals, secondSize);
Individuals.Clear();
(eliteIndividuals as List<IIndividual>).ForEach(
i => Individuals.Add(i)
);
(wheelIndividuals as List<IIndividual>).ForEach(
i => Individuals.Add(i)
);
}
示例4: Apply
public static void Apply(this FilterScheme filterScheme, IEnumerable rawCollection, IList filteredCollection)
{
Argument.IsNotNull("filterScheme", filterScheme);
Argument.IsNotNull("rawCollection", rawCollection);
Argument.IsNotNull("filteredCollection", filteredCollection);
IDisposable suspendToken = null;
var filteredCollectionType = filteredCollection.GetType();
if (filteredCollectionType.IsGenericTypeEx() && filteredCollectionType.GetGenericTypeDefinitionEx() == typeof(FastObservableCollection<>))
{
suspendToken = (IDisposable)filteredCollectionType.GetMethodEx("SuspendChangeNotifications").Invoke(filteredCollection, null);
}
filteredCollection.Clear();
foreach (object item in rawCollection)
{
if (filterScheme.CalculateResult(item))
{
filteredCollection.Add(item);
}
}
if (suspendToken != null)
{
suspendToken.Dispose();
}
}
示例5: Select
public void Select(IList<IIndividual> Individuals, int firstSize, int secondSize)
{
ElitismSelection eliteSelection = new ElitismSelection();
UniversalSelection universalSelection = new UniversalSelection();
IList<IIndividual> eliteIndividuals = new List<IIndividual>();
IList<IIndividual> universalIndividuals = new List<IIndividual>();
(Individuals as List<IIndividual>).ForEach(
i =>
{
eliteIndividuals.Add(i.Clone());
universalIndividuals.Add(i.Clone());
}
);
eliteSelection.Select(eliteIndividuals, firstSize);
universalSelection.Select(universalIndividuals, secondSize);
Individuals.Clear();
(eliteIndividuals as List<IIndividual>).ForEach(
i => Individuals.Add(i)
);
(universalIndividuals as List<IIndividual>).ForEach(
i => Individuals.Add(i)
);
}
示例6: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (IsHtmlFile && completionSets.Any())
{
var bottomSpan = completionSets.First().ApplicableTo;
if (!JScriptEditorUtil.IsInJScriptLanguageBlock(_lbm, bottomSpan.GetStartPoint(bottomSpan.TextBuffer.CurrentSnapshot)))
{
// This is an HTML statement completion session, so do nothing
return;
}
}
// TODO: Reflect over the ShimCompletionSet to see where the Description value comes from
// as setting the property does not actually change the value.
var newCompletionSets = completionSets
.Select(cs => cs == null ? cs : new ScriptCompletionSet(
cs.Moniker,
cs.DisplayName,
cs.ApplicableTo,
cs.Completions
.Select(c => c == null ? c : new Completion(
c.DisplayText,
c.InsertionText,
DocCommentHelper.ProcessParaTags(c.Description),
c.IconSource,
c.IconAutomationText))
.ToList(),
cs.CompletionBuilders))
.ToList();
completionSets.Clear();
newCompletionSets.ForEach(cs => completionSets.Add(cs));
}
示例7: ProcessFactories
private void ProcessFactories(XmlNode node, IList factories)
{
foreach ( XmlNode child in node.ChildNodes )
{
Type type;
switch ( child.LocalName )
{
case "add":
type = Type.GetType(child.Attributes["type"].Value);
if ( !factories.Contains(type) )
factories.Add(type);
break;
case "remove":
type = Type.GetType(child.Attributes["type"].Value);
if ( factories.Contains(type) )
factories.Remove(type);
break;
case "clear":
factories.Clear();
break;
default:
// gives obsolete warning but needed for .NET 1.1 support
throw new ConfigurationException(string.Format("Unknown element '{0}' in section '{0}'", child.LocalName, node.LocalName));
}
}
}
示例8: RegisterDisplayModes
public static void RegisterDisplayModes(IList<IDisplayMode> displayModes)
{
var modeDesktop = new DefaultDisplayMode("")
{
ContextCondition = (c => c.Request.IsDesktop())
};
var modeSmartphone = new DefaultDisplayMode("smartphone")
{
ContextCondition = (c => c.Request.IsSmartphone())
};
var modeTablet = new DefaultDisplayMode("tablet")
{
ContextCondition = (c => c.Request.IsTablet())
};
var modeLegacy = new DefaultDisplayMode("legacy")
{
ContextCondition = (c => c.Request.IsLegacy())
};
displayModes.Clear();
displayModes.Add(modeSmartphone);
displayModes.Add(modeTablet);
displayModes.Add(modeLegacy);
displayModes.Add(modeDesktop);
}
示例9: Clear
public void Clear(IList list)
{
if (list != null)
{
list.Clear();
}
}
示例10: Apply
private void Apply(IList toFree)
{
for (var slotIter = toFree.GetEnumerator(); slotIter.MoveNext();)
{
var slot = ((Slot) slotIter.Current);
_freespaceManager.Free(slot);
}
toFree.Clear();
}
示例11: RecursiveDelete
public static void RecursiveDelete(string directorypath, IList<DirectoryInfo> directorylist)
{
if (Directory.Exists(directorypath))
{
DirectoryInfo directory = new DirectoryInfo(directorypath);
CollateSubfoldersList(directory, directorylist); //Populate the subfolders to be deleted
foreach (DirectoryInfo d in directorylist)
{
try
{
if (d.Exists)
d.Delete(true);
}
catch (IOException)
{
// Hack: http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true
// If you are getting IOException deleting directories that are open
// in Explorer, add a sleep(0) to give Explorer a chance to release
// the directory handle.
//System.Threading.Thread.Sleep(0);
if (d.Exists)
d.Delete(true);
}
}
directorylist.Clear();
}
}
示例12: ExecuteFutureQueries
/// <summary>
/// Executes the future queries.
/// </summary>
/// <param name="context">The <see cref="ObjectContext"/> to run the queries against.</param>
/// <param name="futureQueries">The future queries list.</param>
public void ExecuteFutureQueries(ObjectContext context, IList<IFutureQuery> futureQueries)
{
if (context == null)
throw new ArgumentNullException("context");
if (futureQueries == null)
throw new ArgumentNullException("futureQueries");
// used to call internal methods
dynamic contextProxy = new DynamicProxy(context);
contextProxy.EnsureConnection();
try
{
using (var command = CreateFutureCommand(context, futureQueries))
using (var reader = command.ExecuteReader())
{
foreach (var futureQuery in futureQueries)
{
futureQuery.SetResult(context, reader);
reader.NextResult();
}
}
}
finally
{
contextProxy.ReleaseConnection();
// once all queries processed, clear from queue
futureQueries.Clear();
}
}
示例13: Arrange
protected void Arrange()
{
var random = new Random();
_closingRegister = new List<EventArgs>();
_exceptionRegister = new List<ExceptionEventArgs>();
_localEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
_remoteEndpoint = new IPEndPoint(IPAddress.Parse("193.168.1.5"),
random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
_connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
_sessionMock.Setup(p => p.IsConnected).Returns(true);
_sessionMock.Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
_forwardedPort = new ForwardedPortLocal(_localEndpoint.Address.ToString(), (uint)_localEndpoint.Port, _remoteEndpoint.Address.ToString(), (uint)_remoteEndpoint.Port);
_forwardedPort.Closing += (sender, args) => _closingRegister.Add(args);
_forwardedPort.Exception += (sender, args) => _exceptionRegister.Add(args);
_forwardedPort.Session = _sessionMock.Object;
_forwardedPort.Start();
_forwardedPort.Stop();
_closingRegister.Clear();
}
示例14: AugmentSignatureHelpSession
public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
{
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);
if (item == null)
return;
Declaration dec = item.FindType<Declaration>();
if (dec == null || dec.PropertyName == null || dec.Colon == null)
return;
var span = _buffer.CurrentSnapshot.CreateTrackingSpan(dec.Colon.Start, dec.Length - dec.PropertyName.Length, SpanTrackingMode.EdgeNegative);
ValueOrderFactory.AddSignatures method = ValueOrderFactory.GetMethod(dec);
if (method != null)
{
signatures.Clear();
method(session, signatures, dec, span);
Dispatcher.CurrentDispatcher.BeginInvoke(
new Action(() => {
session.Properties.AddProperty("dec", dec);
session.Match();
}),
DispatcherPriority.Normal, null);
}
}
示例15: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
int position = session.TextView.Caret.Position.BufferPosition.Position;
var line = _buffer.CurrentSnapshot.Lines.SingleOrDefault(l => l.Start <= position && l.End > position);
if (line != null)
{
string text = line.GetText();
int tagIndex = text.IndexOf("getElementsByTagName(");
int classIndex = text.IndexOf("getElementsByClassName(");
int idIndex = text.IndexOf("getElementById(");
CompletionSet set = null;
if (tagIndex > -1 && position > line.Start + tagIndex)
set = GetElementsByTagName(completionSets, position, line, text, tagIndex + 21);
if (classIndex > -1 && position > line.Start + classIndex)
set = GetElementsByClassName(completionSets, position, line, text, classIndex + 23);
if (idIndex > -1 && position > line.Start + idIndex)
set = GetElementById(completionSets, position, line, text, idIndex + 15);
if (set != null)
{
completionSets.Clear();
completionSets.Add(set);
}
}
}