本文整理汇总了C#中IList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Add方法的具体用法?C# IList.Add怎么用?C# IList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDocumentStore
private static void InitializeDocumentStore()
{
DocumentStore = new List<User>();
DocumentStore.Add(new User
{
Username = "Ben"
});
DocumentStore.Add(new User
{
Username = "Jon"
});
DocumentStore.Add(new User
{
Username = "Scott"
});
DocumentStore.Add(new User
{
Username = "Kim"
});
DocumentStore.Add(new User
{
Username = "Jake"
});
DocumentStore.Add(new User
{
Username = "Victoria"
});
DocumentStore.Add(new User
{
Username = "Steve"
});
}
示例2: AddEqStatement
public static void AddEqStatement(string fieldName, object fieldValue, string fieldAlias, ref string whereStatement, IList<object> param)
{
if (fieldValue == null)
{
return;
}
if (fieldValue.GetType() != typeof(string) || !string.IsNullOrWhiteSpace((string)fieldValue))
{
if (!string.IsNullOrWhiteSpace(fieldAlias))
{
fieldName = fieldAlias + "." + fieldName;
}
if (whereStatement == string.Empty)
{
whereStatement = " where " + fieldName + " = ?";
}
else
{
whereStatement += " and " + fieldName + " = ?";
}
if (fieldValue.GetType() == typeof(string))
{
param.Add(fieldValue.ToString().Trim());
}
else
{
param.Add(fieldValue);
}
}
}
示例3: SaveAllProperties
public virtual void SaveAllProperties(IList<KeyValuePair<string, object>> output)
{
output.Add(new KeyValuePair<string, object>("name", this.Name));
if (this.Content != null)
output.Add(new KeyValuePair<string, object>("content", this.Content));
}
示例4: CalculadorPreco
public CalculadorPreco()
{
regras = new List<IRegraPreco>();
regras.Add(new RegraPrecoEspecial());
regras.Add(new RegraPrecoPorGrama());
regras.Add(new RegraPrecoCada());
}
示例5: SafeDirectoryCatalog
public SafeDirectoryCatalog(string path)
{
exceptions = new List<Exception>();
var files = Directory.EnumerateFiles(GetFullPath(path), "*.dll", SearchOption.AllDirectories);
aggregateCatalog = new AggregateCatalog();
foreach (var file in files)
{
try
{
var assemblyCatalog = new AssemblyCatalog(file);
if (assemblyCatalog.Parts.ToList().Count > 0)
aggregateCatalog.Catalogs.Add(assemblyCatalog);
}
catch (ReflectionTypeLoadException ex)
{
foreach (var exception in ex.LoaderExceptions)
{
exceptions.Add(exception);
}
}
catch (Exception ex)
{
exceptions.Add(ex);
}
}
}
示例6: Execute
public void Execute(IDice dice, Combatant attacker, Combatant defender, IList<CombatLogEntry> combatLog)
{
int attack = attacker.ToHitAttack;
int defend = defender.ToHitDefense;
var toHitThreshold = ((attack + ((attacker.Level - defender.Level) / 2)) / ((double)attack + defend)).ConstrainWithinBounds(0.20, 0.80);
Debug.WriteLine("{0} has a {1:P0} chance to hit {2}", attacker.Name, toHitThreshold, defender.Name);
if (dice.Random() < toHitThreshold)
{
var damage = Math.Max(1, attacker.GetAttackDamage(dice));
defender.LowerHealth(damage);
combatLog.Add(new CombatLogEntryFromAction<Attack>(Name)
{
Text = string.Format("{0} hits {1} with {2} for {3} points!", attacker.Name, defender.Name, Name, damage),
Attacker = attacker,
CombatEffect = new CombatOutcome() { Damage = damage }
});
}
else
{
combatLog.Add(
new CombatLogEntry
{
Text = string.Format("{0} attempts to hit {1} with {2} and fails miserably!", attacker.Name, defender.Name, Name),
Attacker = attacker
});
}
}
示例7: AddEffectsInfo
public override void AddEffectsInfo(IList<string> list)
{
list.Add("Decrease Paladin stats by 25%, and pulse a 300 points group heal with a 750 units range every 3 seconds for 15 seconds total.");
list.Add("");
list.Add("Duration: 15 sec");
list.Add("Casting time: instant");
}
示例8: 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)
);
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
Proveedores = new Dictionary<string, int>();
Unidades = new Dictionary<string, int>();
TipoSuministro = new List<string>();
Proveedores = cProveedor.ListarDicProveedores();
IList<Unidad> unidades = cUnidad.ListarUnidades();
foreach (var unit in unidades) {
Unidades.Add(unit.NombreUnidad, unit.UnidadId);
}
TipoSuministro.Add("Medio de Cultivo");
TipoSuministro.Add("Reactivo Quimico");
TipoSuministro.Add("Material");
selectTipoSuministro.DataSource = TipoSuministro;
selectTipoSuministro.DataBind();
selectProveedor.DataSource = Proveedores;
selectProveedor.DataTextField = "Key";
selectProveedor.DataValueField = "Value";
selectProveedor.DataBind();
selectUnidad.DataSource = Unidades;
selectUnidad.DataTextField = "Key";
selectUnidad.DataValueField = "Value";
selectUnidad.DataBind();
}
}
示例10: Rewrite
// Arg(ControllerName),Param(..),.. -> Arg(ControllerName),Arg('Index'),...
public static IList<Token> Rewrite(IList<Token> tokens)
{
//"--command"
if (tokens.Count() >= 2
&& tokens[0].TokenType==TokenType.Argument
&& tokens[0].Value.EqualsIC("help")
&& tokens[1].TokenType==TokenType.Argument)
{
tokens[1] = new Token(tokens[1].Value,TokenType.ParameterValue,tokens[1].Index);
tokens.Insert(1,new Token("command",TokenType.Parameter,1));
//index:2
if (tokens.Count() >= 4) { tokens[3] = new Token(tokens[3].Value, TokenType.ParameterValue, tokens[1].Index); }
tokens.Insert(3, new Token("action", TokenType.Parameter, 2));
}
//help maps to index (should have routing here)
if (tokens.Count() == 0)
{
tokens.Add(new Token("help",TokenType.Argument,0));
}
//Index rewrite:
var indexToken= new Token("Index", TokenType.Argument,1);
if (tokens.Count()>=2
&& tokens[1].TokenType!=TokenType.Argument
&& tokens[0].TokenType==TokenType.Argument)
{
tokens.Insert(1,indexToken);
}
else if (tokens.Count()==1
&& tokens[0].TokenType==TokenType.Argument)
{
tokens.Add(indexToken);
}
return tokens;
}
示例11: AIMoveStore
public AIMoveStore(Transform chess)
{
Chess = chess;
CharacterProperty chessP = chess.GetComponent<CharacterProperty>();
CmdsLeft = new List<UICommands>();
CmdsUsed = new List<UICommands>();
if(!chessP.Moved)
CmdsLeft.Add(UICommands.Move);
else if(!chessP.Defensed)
CmdsUsed.Add(UICommands.Move);
if(!chessP.Attacked)
CmdsLeft.Add(UICommands.Attack);
else if(!chessP.Defensed)
CmdsUsed.Add(UICommands.Attack);
if(!chessP.Activated)
CmdsLeft.Add(UICommands.Skill);
else
CmdsUsed.Add(UICommands.Skill);
if(!chessP.Defensed)
CmdsLeft.Add(UICommands.Defense);
else
CmdsUsed.Add(UICommands.Defense);
if(chessP.Summoner)
CmdsLeft.Add(UICommands.Summon);
}
示例12: BushService
public BushService()
{
_bushes = new List<BushModel>();
_bushes.Add(new BushModel() {Id = 1, Genus = "Forsythia"});
_bushes.Add(new BushModel() {Id = 2, Genus = "Hydrangea"});
_bushes.Add(new BushModel() {Id = 3, Genus = "Buddleia"});
}
示例13: PopulateStrEntries
public override void PopulateStrEntries(IList<StrEntry> strEntries)
{
PopulateJan2004StrEntries(strEntries);
strEntries.Add(new SamlDirectStrEntry());
strEntries.Add(new X509ThumbprintStrEntry(this.SecurityTokenSerializer.EmitBspRequiredAttributes));
strEntries.Add(new EncryptedKeyHashStrEntry(this.SecurityTokenSerializer.EmitBspRequiredAttributes));
}
示例14: InitializeFakeEmployeeRepository
private void InitializeFakeEmployeeRepository()
{
Employees = new List<EmployeeReport>();
Employees.Add(new EmployeeReport {Id = Guid.NewGuid(), Name = "Jens Pettersson", Available = false});
Employees.Add(new EmployeeReport {Id = Guid.NewGuid(), Name = "Mr Sir Developer", Available = true});
}
示例15: PatternDropDownList
public void PatternDropDownList(IList<Pattern> _Pattern)
{
NpgsqlDataReader _dr = null;
DataBaseHelper _db = new DataBaseHelper(Command, CommandType.Text);
try
{
_dr = _db.ExecuteReader(returnParam());
_Pattern.Add(new Pattern(0, "Select Pattern"));
while (_dr.Read())
{
_Pattern.Add(new Pattern(int.Parse(_dr[0].ToString()), _dr[1].ToString()));
}
}
catch (Exception ex)
{
throw new Exception(" :: " + ex.Message);
}
finally
{
if(_dr!=null)
{
_db = null;
_dr=null;
_Pattern = null;
}
}
}