本文整理汇总了C#中ICollection.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.Clear方法的具体用法?C# ICollection.Clear怎么用?C# ICollection.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CecilVisitor
public CecilVisitor(AssemblyDefinition assembly, ModuleDefinition module)
{
_assembly = assembly;
_module = module;
var program = _module.Types.First(t => t.Name == "Program");
_main = program.Methods.First(m => m.Name == "Main");
_body = _main.Body;
_instructions = _body.Instructions;
_instructions.Clear();
_objCtor = _module.Import(typeof(object).GetConstructor(new System.Type[0]));
var systemFunctions = _module.Types.First(t => t.Name == "SystemFunctions");
// Math methods
_fact = systemFunctions.Methods.First(m => m.Name == "Fact");
_max = systemFunctions.Methods.First(m => m.Name == "Max");
_min = systemFunctions.Methods.First(m => m.Name == "Min");
_pow = systemFunctions.Methods.First(m => m.Name == "Pow");
// Console methods
_printBool = systemFunctions.Methods.First(m => m.Name == "PrintBool");
_printInt = systemFunctions.Methods.First(m => m.Name == "PrintInt");
_userFunctions = _module.Types.First(t => t.Name == "UserFunctions");
}
示例2: TestReadOnly
private void TestReadOnly(ICollection<string> collection)
{
Assert.Equal(true, collection.IsReadOnly);
Assert.Throws<NotSupportedException>(() => collection.Add("x"));
Assert.Throws<NotSupportedException>(() => collection.Remove("x"));
Assert.Throws<NotSupportedException>(() => collection.Clear());
}
示例3: CloneTo
public static void CloneTo(this IEnumerable<ParameterDefinition> sourceCollection, ICollection<ParameterDefinition> destinationCollection)
{
destinationCollection.Clear();
foreach (var element in sourceCollection) {
destinationCollection.Add(element.Clone());
}
}
示例4: LoadSchemaObjects
public void LoadSchemaObjects(ICollection<SchemaObject> objectList, DbConnectionInfo connectionInfo)
{
var extractor = new SchemaExtractor();
objectList.Clear();
var tables = extractor.GetTables(connectionInfo);
var columns = extractor.GetTableColumns(connectionInfo);
AddColumns(tables, columns);
var primaryKeyColumns = GetPrimaryKeyColumns(connectionInfo);
AddPrimaryKeys(tables, primaryKeyColumns);
var views = extractor.GetViews(connectionInfo);
var viewColumns = extractor.GetViewColumns(connectionInfo);
AddViewColumns(views, viewColumns);
var fKeys = GetForeignKeys(connectionInfo);
AddForeignKeysToTables(tables, fKeys);
var procedures = extractor.GetStoredProcedures(connectionInfo);
var parameters = extractor.GetStoredProcedureParameters(connectionInfo);
AddParametersToStoredProcedures(procedures, parameters);
foreach (var procedure in procedures.Values)
objectList.Add(procedure);
foreach (var view in views.Values)
objectList.Add(view);
var sortedTables = from t in tables.Values
orderby t.Name
select t;
foreach (var t in sortedTables)
objectList.Add(t);
}
示例5: GetAllCountries
public void GetAllCountries(ICollection<Country> list)
{
list.Clear();
var flags = _flagsDB.Flags.OrderBy(f => (f.Country));
foreach (var flag in flags)
{
list.Add(CreateCountryUsingFlagData(flag));
}
}
示例6: EmptyCollectionReturnsTrue
public void EmptyCollectionReturnsTrue(SUT sut, IInvocation invocation, ICollection<object> collection)
{
collection.Clear();
invocation.ReturnValue = collection;
var result = sut.ShouldIntercept(invocation);
result.Should().BeTrue();
}
开发者ID:bardock,项目名称:AutoFixture.AutoEntityFramework,代码行数:10,代码来源:EmptyCollectionReturnValueInterceptionPolicyTest.cs
示例7: GetCountriesByParams
public void GetCountriesByParams(ICollection<Country> list, int color, int shape, int add)
{
list.Clear();
if (color % 2 == 0) list.Add(new Country { Tag = "pl", Name = "Poland", FirstLetter = 'P', Continent = "Europe", Capital = "Warsaw" });
if (color % 2 != 0) list.Add(new Country { Tag = "us", Name = "United States", FirstLetter = 'U', Continent = "North America", Capital = "Washington" });
if (shape % 3 == 0) list.Add(new Country { Tag = "at", Name = "Austria", FirstLetter = 'A', Continent = "Europe", Capital = "Vien" });
if (shape % 4 == 0) list.Add(new Country { Tag = "jp", Name = "Japan", FirstLetter = 'J', Continent = "Asia", Capital = "Tokyo" });
if (add % 2 != 0) list.Add(new Country { Tag = "no", Name = "Norway", FirstLetter = 'N', Continent = "Europe", Capital = "Oslo" });
if (add % 3 != 0) list.Add(new Country { Tag = "ar", Name = "Argentina", FirstLetter = 'A', Continent = "South America", Capital = "Buenos Aires" });
}
示例8: OpenXml
/// <summary>
/// Opens the XML stream, given an XSD validation.
/// </summary>
/// <param name="xmlStream">The XML stream.</param>
/// <param name="xsdStream">The XSD stream.</param>
/// <param name="validationErrors">The validation errors.</param>
/// <returns></returns>
private static XmlReader OpenXml(Stream xmlStream, Stream xsdStream, ICollection<string> validationErrors)
{
validationErrors.Clear();
var xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.Schemas.Add(null, XmlReader.Create(xsdStream));
xmlReaderSettings.ValidationType = ValidationType.Schema;
xmlReaderSettings.ValidationEventHandler += ((sender, e) => validationErrors.Add(e.Message));
var xmlValidator = XmlReader.Create(xmlStream, xmlReaderSettings);
return xmlValidator;
}
示例9: FilterByRuntimeVersion
private void FilterByRuntimeVersion (ICollection<ITestMethod> methods)
{
List<ITestMethod> original = new List<ITestMethod>(methods);
methods.Clear();
foreach (ITestMethod method in original) {
// test the runtime version attributes of the method
if (RuntimeVersionMatches (method))
methods.Add(method);
}
}
示例10: GetAllCountries
public void GetAllCountries(ICollection<Country> list)
{
list.Clear();
list.Add(new Country { Tag = "pl", Name = "Poland", FirstLetter = 'P', Continent = "Europe", Capital = "Warsaw" });
list.Add(new Country { Tag = "us", Name = "United States", FirstLetter = 'U', Continent = "North America", Capital = "Washington" });
list.Add(new Country { Tag = "at", Name = "Austria", FirstLetter = 'A', Continent = "Europe", Capital = "Vien" });
list.Add(new Country { Tag = "jp", Name = "Japan", FirstLetter = 'J', Continent = "Asia", Capital = "Tokyo" });
list.Add(new Country { Tag = "no", Name = "Norway", FirstLetter = 'N', Continent = "Europe", Capital = "Oslo" });
list.Add(new Country { Tag = "ar", Name = "Argentina", FirstLetter = 'A', Continent = "South America", Capital = "Buenos Aires" });
list.Add(new Country { Tag = "co", Name = "Columbia", FirstLetter = 'C', Continent = "South America", Capital = "Bogota" });
}
示例11: PositionChartPanel
public PositionChartPanel()
{
InitializeComponent();
_positionCurve = EquityChart.CreateCurve(LocalizedStrings.Str862, Colors.SteelBlue);
var cmdSvc = ConfigManager.GetService<IStudioCommandService>();
cmdSvc.Register<ResetedCommand>(this, false, cmd => _positionCurve.Clear());
cmdSvc.Register<PositionCommand>(this, false, cmd =>
_positionCurve.Add(new EquityData { Time = cmd.Time, Value = cmd.Position.CurrentValue }));
}
示例12: TryC5Coll
public void TryC5Coll(ICollection<double> coll) {
Assert.AreEqual(0, coll.Count);
double[] arr = { };
coll.CopyTo(arr, 0);
Assert.IsFalse(coll.IsReadOnly);
coll.Add(2.3);
coll.Add(3.2);
Assert.AreEqual(2, coll.Count);
Assert.IsTrue(coll.Contains(2.3));
Assert.IsFalse(coll.Contains(3.1));
Assert.IsFalse(coll.Remove(3.1));
Assert.IsTrue(coll.Remove(3.2));
Assert.IsFalse(coll.Contains(3.1));
Assert.AreEqual(1, coll.Count);
coll.Clear();
Assert.AreEqual(0, coll.Count);
Assert.IsFalse(coll.Remove(3.1));
}
示例13: GetBudgetDetail
private void GetBudgetDetail(IEnumerable<TaskDto> taskCollection, ICollection<PRE_DETALLE> detail)
{
var resources = new List<ResourceDto>();
detail.Clear();
GetResources(taskCollection, resources);
var resourcesCopy = CopyResources(resources);
var listItems = resourcesCopy.Select(x => x.Code).Distinct();
foreach (var tmpItem in listItems)
{
var preDetalle = new PRE_DETALLE();
var item = OnlyOneFromSeveral(resourcesCopy.Where(x => x.Code.Equals(tmpItem)).ToList());
Map(item, preDetalle);
detail.Add(preDetalle);
}
}
示例14: Validate
public static bool Validate(object instance, ICollection<ValidationResult> validationResults, Action<string> onErrorsChanged)
{
var propertiesThatHadErrors = validationResults.SelectMany(v => v.MemberNames).Distinct().ToHashSet();
validationResults.Clear();
var validationResult = Validator.TryValidateObject(instance, new ValidationContext(instance),
validationResults, true);
var propertiesThatHaveErrors = validationResults.SelectMany(v => v.MemberNames).Distinct().ToHashSet();
foreach (var property in propertiesThatHaveErrors.Concat(propertiesThatHadErrors).Distinct())
{
onErrorsChanged(property);
}
return validationResult;
}
示例15: EquityCurveChartPanel
public EquityCurveChartPanel()
{
InitializeComponent();
_totalPnL = EquityChart.CreateCurve(LocalizedStrings.PnL, Colors.Green, Colors.Red, EquityCurveChartStyles.Area);
_unrealizedPnL = EquityChart.CreateCurve(LocalizedStrings.PnLUnreal, Colors.Black);
_commission = EquityChart.CreateCurve(LocalizedStrings.Str159, Colors.Red, EquityCurveChartStyles.DashedLine);
var cmdSvc = ConfigManager.GetService<IStudioCommandService>();
cmdSvc.Register<ResetedCommand>(this, false, cmd =>
{
_totalPnL.Clear();
_unrealizedPnL.Clear();
_commission.Clear();
});
cmdSvc.Register<PnLChangedCommand>(this, false, cmd =>
{
_totalPnL.Add(new EquityData { Time = cmd.Time, Value = cmd.TotalPnL });
_unrealizedPnL.Add(new EquityData { Time = cmd.Time, Value = cmd.UnrealizedPnL });
_commission.Add(new EquityData { Time = cmd.Time, Value = cmd.Commission ?? 0 });
});
}