本文整理汇总了C#中ICollection类的典型用法代码示例。如果您正苦于以下问题:C# ICollection类的具体用法?C# ICollection怎么用?C# ICollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICollection类属于命名空间,在下文中一共展示了ICollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddContracts
public override void AddContracts(
ICSharpContextActionDataProvider provider,
Func<IExpression, IExpression> getContractExpression,
out ICollection<ICSharpStatement> firstNonContractStatements)
{
var contractInvariantMethodDeclaration = classLikeDeclaration.EnsureContractInvariantMethod(provider.PsiModule);
if (contractInvariantMethodDeclaration.Body != null)
{
var factory = CSharpElementFactory.GetInstance(provider.PsiModule);
var expression = factory.CreateExpression("$0", declaration.DeclaredElement);
ICSharpStatement firstNonContractStatement;
AddContract(
ContractKind.Invariant,
contractInvariantMethodDeclaration.Body,
provider.PsiModule,
() => getContractExpression(expression),
out firstNonContractStatement);
firstNonContractStatements = firstNonContractStatement != null ? new[] { firstNonContractStatement } : null;
}
else
{
firstNonContractStatements = null;
}
}
示例2: ExcludeMultiples
private static void ExcludeMultiples(ICollection<long> crossedOffList, long candidate, int max)
{
for (var i = candidate; i < max + 1; i += candidate)
{
crossedOffList.Add(i);
}
}
示例3: AreComponentsRemovable
internal static bool AreComponentsRemovable(ICollection components)
{
if (components == null)
{
throw new ArgumentNullException("components");
}
foreach (object obj2 in components)
{
Activity activity = obj2 as Activity;
ConnectorHitTestInfo info = obj2 as ConnectorHitTestInfo;
if ((activity == null) && (info == null))
{
return false;
}
if (activity != null)
{
ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
if ((designer != null) && designer.IsLocked)
{
return false;
}
}
if ((info != null) && !(info.AssociatedDesigner is FreeformActivityDesigner))
{
return false;
}
}
return true;
}
示例4: In
/// <summary>
/// Where a field value is one in a set.
/// </summary>
public static iCondition In(this iCondition pCon, string pFieldName, ICollection<string> pValues)
{
IEnumerable<string> strings = from str in pValues select string.Format("'{0}'", str);
return pValues.Count == 0
? pCon
: Expression(pCon, pFieldName, string.Format("IN ({0})", string.Join(",", strings)));
}
示例5: GetCardWithSuitThatEnemyDoesNotHave
public Card GetCardWithSuitThatEnemyDoesNotHave(bool enemyHasATrumpCard, CardSuit trumpSuit, ICollection<Card> playerCards)
{
if (!enemyHasATrumpCard)
{
// In case the enemy does not have any trump cards and Stalker has a trump, he should throw a trump.
var myTrumpCards = playerCards.Where(c => c.Suit == trumpSuit).ToList();
if (myTrumpCards.Count() > 0)
{
return myTrumpCards.OrderBy(c => c.GetValue()).LastOrDefault();
}
}
var orderedCards = playerCards.OrderBy(c => c.GetValue());
foreach (var card in orderedCards)
{
if (this.cardHolder.EnemyCards.All(c => c.Suit != card.Suit))
{
if (enemyHasATrumpCard)
{
return playerCards.Where(c => c.Suit == card.Suit).OrderBy(c => c.GetValue()).FirstOrDefault();
}
return playerCards.Where(c => c.Suit == card.Suit).OrderByDescending(c => c.GetValue()).FirstOrDefault();
}
}
return null;
}
示例6: Execute
/// <summary>
/// Executes the specified pipeline.
/// </summary>
/// <param name="pipelineName">The name.</param>
/// <param name="pipeline">The pipeline.</param>
/// <param name="translateRows">Translate the rows into another representation</param>
public void Execute(string pipelineName,
ICollection<IOperation> pipeline,
Func<IEnumerable<Row>, IEnumerable<Row>> translateRows)
{
try
{
IEnumerable<Row> enumerablePipeline = PipelineToEnumerable(pipeline, new List<Row>(), translateRows);
try
{
raiseNotifyExecutionStarting();
DateTime start = DateTime.Now;
ExecutePipeline(enumerablePipeline);
raiseNotifyExecutionCompleting();
Trace("Completed process {0} in {1}", pipelineName, DateTime.Now - start);
}
catch (Exception e)
{
string errorMessage = string.Format("Failed to execute pipeline {0}", pipelineName);
Error(e, errorMessage);
}
}
catch (Exception e)
{
Error(e, "Failed to create pipeline {0}", pipelineName);
}
DisposeAllOperations(pipeline);
}
示例7: CheckDataIfStartMenuIsExpectedToNotExist
private static CheckResult CheckDataIfStartMenuIsExpectedToNotExist(ICollection<FileChange> fileChanges, ICollection<Registryhange> registryChanges,
FileChange fileChange, StartMenuData startMenuData, Registryhange registryChange)
{
if (fileChange == null)
{
return CheckResult.Succeeded(startMenuData);
}
if (fileChange.Type != FileChangeType.Delete)
{
fileChanges.Remove(fileChange);
if (registryChange != null)
{
registryChanges.Remove(registryChange);
}
return CheckResult.Failure("Found menu item:'" + startMenuData.Name + "' when is was not expected");
}
// When uninstalling this key get changed
const string startPageKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartPage";
var uninstallStartMenuKey =
registryChanges.FirstOrDefault(x => string.Equals(x.Key, startPageKey, StringComparison.InvariantCultureIgnoreCase) &&
x.ValueName == "FavoritesRemovedChanges" &&
x.Type == RegistryChangeType.SetValue);
if (uninstallStartMenuKey == null)
{
fileChanges.Remove(fileChange);
return CheckResult.Failure("");
}
registryChanges.Remove(uninstallStartMenuKey);
fileChanges.Remove(fileChange);
return CheckResult.Succeeded(startMenuData);
}
示例8: getSteering
public Vector3 getSteering(Rigidbody2D target, ICollection<Rigidbody2D> obstacles, out Vector3 bestHidingSpot)
{
//Find the closest hiding spot
float distToClostest = Mathf.Infinity;
bestHidingSpot = Vector3.zero;
foreach(Rigidbody2D r in obstacles)
{
Vector3 hidingSpot = getHidingPosition(r, target);
float dist = Vector3.Distance(hidingSpot, transform.position);
if(dist < distToClostest)
{
distToClostest = dist;
bestHidingSpot = hidingSpot;
}
}
//If no hiding spot is found then just evade the enemy
if(distToClostest == Mathf.Infinity)
{
return evade.getSteering(target);
}
//Debug.DrawLine(transform.position, bestHidingSpot);
return steeringBasics.arrive(bestHidingSpot);
}
示例9: GoToEvent
/// <summary>
/// Creates a new GoToEvent using the given locations.
/// </summary>
/// <param name="locations">List of MarkerID's</param>
public GoToEvent(ICollection<Point> locations)
{
if (locations == null)
this.locations = new List<Point>();
else
this.locations = new List<Point>(locations);
}
示例10: DoCheck
public override CheckResult DoCheck(BaseTestData data, ICollection<FileChange> fileChanges, ICollection<Registryhange> registryChanges)
{
if (!VerifyIfCorrectTestData(data))
{
return CheckResult.NotCheckDone();
}
var startMenuData = data as StartMenuData;
var path = startMenuData.AllUsers ? GetAllUsersMenuFolder() : Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
// To get the program folder
var dirInfo = new DirectoryInfo(path);
path = Path.Combine(path, dirInfo.GetDirectories()[0].Name);
path = Path.Combine(path, startMenuData.Name + ".lnk");
// Find registry GlobalAssocChangedCounter key that is updated when creating a startmenu
var globalAssocChangedCounterKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer";
if (Environment.Is64BitOperatingSystem)
{
globalAssocChangedCounterKey = @"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\explorer";
}
var registryChange = registryChanges.FirstOrDefault(x => string.Equals(x.Key, globalAssocChangedCounterKey, StringComparison.InvariantCultureIgnoreCase) &&
x.ValueName == "GlobalAssocChangedCounter" &&
x.Type == RegistryChangeType.SetValue);
var fileChange = fileChanges.FirstOrDefault(x => x.Path == path);
return startMenuData.Exist ? CheckDataIfStartMenuIsExpectedToExist(fileChanges, registryChanges, fileChange, startMenuData, registryChange) :
CheckDataIfStartMenuIsExpectedToNotExist(fileChanges, registryChanges, fileChange, startMenuData, registryChange);
}
示例11: AddProperty
private static void AddProperty(ICollection<SearchResult> results, string field, string searchTerm)
{
if (field.ToLowerInvariant().Contains(searchTerm.ToLowerInvariant().Trim()))
{
results.Add(new SearchResult { id = field, name = field });
}
}
示例12: Init
/// <summary>
/// Initializes the loggly logger
/// </summary>
/// <param name="session">Current encompass session, used to load the config file</param>
/// <param name="config">Config file to load. Will re-initialize when this is used.</param>
/// <param name="tags">Collection of loggly tags. If null, we will load the Loggly.Tags element from the config.</param>
public static void Init(Session session, IEncompassConfig config, ICollection<string> tags = null)
{
config.Init(session);
if (tags != null)
{
foreach (string tag in tags)
{
AddTag(tag);
}
}
foreach (var tag in config.GetValue(LOGGLY_TAGS, string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
AddTag(tag);
}
string configLogglyUrl = config.GetValue(LOGGLY_URL);
if (configLogglyUrl != null)
{
SetPostUrl(configLogglyUrl);
}
bool allEnabled = config.GetValue(LOGGLY_ALL, false);
bool errorEnabled = config.GetValue(LOGGLY_ERROR, false);
bool warnEnabled = config.GetValue(LOGGLY_WARN, false);
bool infoEnabled = config.GetValue(LOGGLY_INFO, false);
bool debugEnabled = config.GetValue(LOGGLY_DEBUG, false);
bool fatalEnabled = config.GetValue(LOGGLY_FATAL, false);
Instance.ErrorEnabled = allEnabled || errorEnabled;
Instance.WarnEnabled = allEnabled || warnEnabled;
Instance.InfoEnabled = allEnabled || infoEnabled;
Instance.DebugEnabled = allEnabled || debugEnabled;
Instance.FatalEnabled = allEnabled || fatalEnabled;
}
示例13: TryGetSubscribers
public bool TryGetSubscribers(ICollection<Type> contracts, out ICollection<Address> subscribers)
{
Mandate.ParameterNotNull(contracts, "contracts");
locker.EnterReadLock();
var allSubscriptions = new List<Address>();
subscribers = allSubscriptions;
try
{
foreach (var subscriptions in contracts.Select(GetSubscribers))
{
if (subscriptions == null)
continue;
allSubscriptions.AddRange(subscriptions);
}
return allSubscriptions.Any();
}
finally
{
locker.ExitReadLock();
}
}
示例14: DotExpression
public DotExpression(IExpression expression, string name, ICollection<IExpression> arguments)
{
this.expression = expression;
this.name = name;
this.arguments = arguments;
this.type = AsType(this.expression);
}
示例15: ConfigSettingMetadata
public ConfigSettingMetadata(string location, string text, string sort, string className,
string helpText, ICollection<string> listenTo) : base(location, text, sort)
{
_className = className;
_helpText = helpText;
_listenTo = listenTo;
}