本文整理汇总了C#中Model.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public void Open(OpenCallback callback)
{
if(IsOpen == false)
{
fDataSources = new List<InterfaceDataSource>();
if(fTwain.Open())
{
fDataSources.AddRange(fTwain.GetDataSources());
}
if(fWia.Open())
{
fDataSources.AddRange(fWia.GetDataSources());
}
foreach(InterfaceDataSource ds in fDataSources)
{
ds.OnNewPictureData += fActiveDataSource_OnNewPictureData;
ds.OnScanningComplete += fActiveDataSource_OnScanningComplete;
}
}
if(callback != null)
{
callback(IsOpen);
}
}
示例2: GetDescendants
public List<RoleAuthorization> GetDescendants(int functionId)
{
List<RoleAuthorization> resultList = new List<RoleAuthorization>();
List<RoleAuthorization> childList = AuthList.FindAll(t => t.ParentId == functionId);
resultList.AddRange(childList);
foreach (var item in childList)
{
var theChildList = GetDescendants(item.FunctionId);
resultList.AddRange(theChildList);
}
return resultList;
}
示例3: GetHotNews
public static List<AModel> GetHotNews()
{
List<AModel> allHot = new List<AModel>();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(System.AppDomain.CurrentDomain.BaseDirectory + @"\Config\websiteConfig.xml");
XmlNode root = xmlDoc.SelectSingleNode("websites");
foreach (XmlNode node in root.ChildNodes)
{
websiteModel model = new websiteModel();
model.Name = node.Attributes[0].Value;
model.Url = node.Attributes[1].Value;
model.Charset = node.Attributes[2].Value;
XmlNode foumRoot = node.SelectSingleNode("forums");
foreach (XmlNode forumNode in foumRoot.ChildNodes)
{
forumModel forummodel = new forumModel();
forummodel.Name = forumNode.Attributes[0].Value;
forummodel.BeginFlag = forumNode.Attributes[1].Value;
forummodel.EndFlag = forumNode.Attributes[2].Value;
model.ForumDic.Add(forummodel.Name, forummodel);
}
Website website = new Website(model.Url);
string forumContent = Forum.GetForum(website.GetWebContent(model.Charset) , model.ForumDic["头条"]);
allHot.AddRange(A.FindAll(forumContent, model.Name));
}
return allHot;
}
示例4: Export
public static string Export(Replay replay)
{
Game game = new Game(replay);
GameState oldState = null;
List<GameAction> actions = new List<GameAction>();
for (int i = 0; i < replay.Actions.Count; i++)
{
if (replay.Actions[i] is ReplayTimeAction)
actions.Add(replay.Actions[i]);
game.Seek(i);
List<GameAction> newActions = StateDelta.Delta(oldState, game.State);
actions.AddRange(newActions);
if (game.State != null)
oldState = game.State.Clone();
}
List<JObject> jActions = new List<JObject>();
TimeSpan time = TimeSpan.Zero;
foreach (var action in actions)
{
if (action is ReplayTimeAction)
time = ((ReplayTimeAction)action).Time;
else
jActions.Add(SerializeAction(action, time));
}
JObject json = new JObject(new JProperty("changes", new JArray(jActions)));
return json.ToString(Newtonsoft.Json.Formatting.None);
}
示例5: getDistrictsList
public List<District> getDistrictsList()
{
List<District> list = new List<District>();
list.Add(new District() { Id=-1, Name="[Select District]"});
list.AddRange(uOW.DistrictRepo.Get());
return list;
}
示例6: Main
private static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Usage: Importer [directory to process]");
return;
}
string directory = args[0];
if (!Directory.Exists(directory))
{
Console.WriteLine("{0} does not exists", directory);
return;
}
Dictionary<Guid, Post> posts = new Dictionary<Guid, Post>();
IDictionary<string, Category> categories = new Dictionary<string, Category>();
List<Comment> comments = new List<Comment>();
AddPosts(categories, directory, posts);
foreach (string file in Directory.GetFiles(directory, "*feedback*.xml"))
{
IList<Comment> day_comments = ProcessComments(file, posts);
comments.AddRange(day_comments);
}
Console.WriteLine("Found {0} posts in {1} categories with {2} comments", posts.Count, categories.Count, comments.Count);
SaveToDatabase(categories, posts.Values, comments);
}
示例7: GetAllowContro
public List<ControllerAction> GetAllowContro(string userName)
{
List<ControllerAction> controAction = new List<ControllerAction>();
var rolesList = _db.Users.SingleOrDefault(a => a.UserName == userName).Roles.ToList();
for (int i = 0; i < rolesList.Count; i++)
{
controAction.AddRange(rolesList[i].ControllerActions);
}
return controAction;
}
示例8: GetPhotosetsResponseFromDictionary
public static PhotosetsResponse GetPhotosetsResponseFromDictionary(this Dictionary<string, object> dictionary) {
var photosets = new List<Photoset>();
IEnumerable<Dictionary<string, object>> photosetDictionary;
if (runningOnMono) {
var photosetListAsArrayList = (ArrayList) dictionary.GetSubValue("photosets", "photoset");
photosetDictionary = photosetListAsArrayList.Cast<Dictionary<string, object>>();
} else {
var photosetListAsIEnumerable = (IEnumerable<object>) dictionary.GetSubValue("photosets", "photoset");
photosetDictionary = photosetListAsIEnumerable.Cast<Dictionary<string, object>>();
}
photosets.AddRange(photosetDictionary.Select(BuildPhotoset));
return new PhotosetsResponse(
int.Parse(dictionary.GetSubValue("photosets", "page").ToString()),
int.Parse(dictionary.GetSubValue("photosets", "pages").ToString()),
int.Parse(dictionary.GetSubValue("photosets", "perpage").ToString()),
int.Parse(dictionary.GetSubValue("photosets", "total").ToString()),
photosets);
}
示例9: GetPhotosResponseFromDictionary
public static PhotosResponse GetPhotosResponseFromDictionary(this Dictionary<string, object> dictionary, bool isAlbum) {
var apiresponseCollectionName = isAlbum ? "photoset" : "photos";
var photos = new List<Photo>();
IEnumerable<Dictionary<string, object>> photoDictionary;
if (runningOnMono) {
var photoListAsArrayList = (ArrayList) dictionary.GetSubValue(apiresponseCollectionName, "photo");
photoDictionary = photoListAsArrayList.Cast<Dictionary<string, object>>();
} else {
var photoListAsIEnumerable = (IEnumerable<object>) dictionary.GetSubValue(apiresponseCollectionName, "photo");
photoDictionary = photoListAsIEnumerable.Cast<Dictionary<string, object>>();
}
photos.AddRange(photoDictionary.Select(BuildPhoto));
return new PhotosResponse(
int.Parse(dictionary.GetSubValue(apiresponseCollectionName, "page").ToString()),
int.Parse(dictionary.GetSubValue(apiresponseCollectionName, "pages").ToString()),
int.Parse(dictionary.GetSubValue(apiresponseCollectionName, "perpage").ToString()),
int.Parse(dictionary.GetSubValue(apiresponseCollectionName, "total").ToString()),
photos);
}
示例10: UCCustomerAddOrEdit_SaveEvent
void UCCustomerAddOrEdit_SaveEvent(object sender, EventArgs e) //数据保存
{
try
{
if (!CheckControlValue()) return;
var sysSqlStrList = new List<SysSQLString>();
var custSql = BuildCustomerSqlString();
sysSqlStrList.Add(custSql.Item1);
sysSqlStrList.AddRange(BuildContactRelation(custSql.Item2));
sysSqlStrList.AddRange(BuildVehicleRelation(custSql.Item2));
sysSqlStrList.AddRange(BuildVipMemberSqlString(custSql.Item2));
//ucAttr.GetAttachmentSql(sysSqlStrList); //保存附件时失败...目前保留此代码
var opName = wStatus == WindowStatus.Edit ? "更新客户档案" : "新增客户档案";
var result = DBHelper.BatchExeSQLStringMultiByTrans(opName, sysSqlStrList);
if (result)
{
var customer = new tb_customer();
customer.cust_id = custSql.Item1.Param["cust_id"];
customer.cust_code = custSql.Item1.Param["cust_code"];
customer.cust_name = custSql.Item1.Param["cust_name"];
customer.cust_short_name = custSql.Item1.Param["cust_short_name"];
customer.cust_quick_code = custSql.Item1.Param["cust_quick_code"];
customer.cust_type = custSql.Item1.Param["cust_type"];
customer.legal_person = custSql.Item1.Param["legal_person"];
customer.enterprise_nature = custSql.Item1.Param["enterprise_nature"];
customer.cust_tel = custSql.Item1.Param["cust_tel"];
customer.cust_fax = custSql.Item1.Param["cust_fax"];
customer.cust_email = custSql.Item1.Param["cust_email"];
customer.cust_phone = custSql.Item1.Param["cust_phone"];
customer.cust_website = custSql.Item1.Param["cust_website"];
customer.province = custSql.Item1.Param["province"];
customer.city = custSql.Item1.Param["city"];
customer.county = custSql.Item1.Param["county"];
customer.cust_address = custSql.Item1.Param["cust_address"];
customer.zip_code = custSql.Item1.Param["zip_code"];
customer.tax_num = custSql.Item1.Param["tax_num"];
customer.indepen_legalperson = custSql.Item1.Param["indepen_legalperson"];
customer.credit_rating = custSql.Item1.Param["credit_rating"];
customer.credit_line = Convert.ToInt32(custSql.Item1.Param["credit_line"]);
customer.credit_account_period = Convert.ToInt32(custSql.Item1.Param["credit_account_period"]);
customer.price_type = custSql.Item1.Param["price_type"];
customer.billing_name = custSql.Item1.Param["billing_name"];
customer.billing_address = custSql.Item1.Param["billing_address"];
customer.billing_account = custSql.Item1.Param["billing_account"];
customer.open_bank = custSql.Item1.Param["open_bank"];
customer.bank_account = custSql.Item1.Param["bank_account"];
customer.bank_account_person = custSql.Item1.Param["bank_account_person"];
customer.cust_remark = custSql.Item1.Param["cust_remark"];
customer.is_member = custSql.Item1.Param["is_member"];
customer.member_number = custSql.Item1.Param["member_number"];
customer.member_class = custSql.Item1.Param["member_class"];
if(rdbis_member_y.Checked) customer.member_period_validity = Convert.ToInt64(custSql.Item1.Param["member_period_validity"]);
customer.status = custSql.Item1.Param["status"];
customer.enable_flag = custSql.Item1.Param["enable_flag"];
customer.data_source = custSql.Item1.Param["data_source"];
customer.cust_crm_guid = custSql.Item1.Param["cust_crm_guid"];
customer.accessories_discount = 0;
customer.workhours_discount = 0;
customer.country = custSql.Item1.Param["country"];
customer.indepen_legalperson = custSql.Item1.Param["indepen_legalperson"];
customer.market_segment = custSql.Item1.Param["market_segment"];
customer.institution_code = custSql.Item1.Param["institution_code"];
customer.com_constitution = custSql.Item1.Param["com_constitution"];
customer.registered_capital = custSql.Item1.Param["registered_capital"];
customer.vehicle_structure = custSql.Item1.Param["vehicle_structure"];
customer.agency = custSql.Item1.Param["agency"];
customer.sap_code = custSql.Item1.Param["sap_code"];
customer.business_scope = custSql.Item1.Param["business_scope"];
customer.ent_qualification = custSql.Item1.Param["ent_qualification"];
if (wStatus == WindowStatus.Edit)
{
customer.update_by = custSql.Item1.Param["update_by"];
customer.update_time = Convert.ToInt64(custSql.Item1.Param["update_time"]);
}
else
{
customer.create_time = Convert.ToInt64(custSql.Item1.Param["create_time"]);
customer.create_by = custSql.Item1.Param["create_by"];
}
var flag = DBHelper.WebServHandler(opName, EnumWebServFunName.UpLoadCustomer, customer);
if (String.IsNullOrEmpty(flag))
{
var contactSql = BuildContactRelation(custSql.Item2).ToArray();
foreach (var sysSqlString in contactSql)
{
if (!sysSqlString.Param.ContainsKey("cont_id")) continue;
var contId = sysSqlString.Param["cont_id"];
var dt1 = DBHelper.GetTable("获取客户CRMID", "tb_customer","*", String.Format("cust_id = '{0}'", customer.cust_id), "", "");
var dt = DBHelper.GetTable("根据客户档案获取联系信息", "v_contacts", string.Format("*,{0} phone", EncryptByDB.GetDesFieldValue("cont_phone")), " cont_id = '" + contId + "'", "", "");
if (dt.DefaultView != null && dt.DefaultView.Count > 0)
{
var cont = new tb_contacts_ex
{
cont_id = CommonCtrl.IsNullToString(dt.DefaultView[0]["cont_id"]),
cont_name = CommonCtrl.IsNullToString(dt.DefaultView[0]["cont_name"]),
//.........这里部分代码省略.........
示例11: GetAffectedMembers
//.........这里部分代码省略.........
}
else
{
var enumerableInterface = propertyType.GetEnumerableType();
var listArgumentType = enumerableInterface.GetGenericArguments()[0];
var listType = typeof (List<>).MakeGenericType(listArgumentType);
targetValue = listType.CreateInstance();
}
attemptedProperty.ValueProvider.SetValue(node.Target, targetValue);
}
}
// the Target becomes the Target's child property value
// the Parent becomes the current Target
node = new Node(targetValue, node.Target);
continue; // keep traversing the path tree
}
if (pathTree[i].Filter != null)
{
// we can only filter enumerable types
if (!attemptedProperty.PropertyType.IsNonStringEnumerable())
{
ErrorType = ScimErrorType.InvalidFilter;
break;
}
var enumerable = attemptedProperty.ValueProvider.GetValue(node.Target) as IEnumerable;
if (enumerable == null)
{
// if the value of the attribute is null then there's nothing to filter
// it should never get here beause ScimObjectAdapter should apply a
// different ruleset for null values; replacing or setting the attribute value
ErrorType = ScimErrorType.NoTarget;
break;
}
dynamic predicate;
try
{
// parse our filter into an expression tree
var lexer = new ScimFilterLexer(new AntlrInputStream(pathTree[i].Filter));
var parser = new ScimFilterParser(new CommonTokenStream(lexer));
// create a visitor for the type of enumerable generic argument
var enumerableType = attemptedProperty.PropertyType.GetGenericArguments()[0];
var filterVisitorType = typeof (ScimFilterVisitor<>).MakeGenericType(enumerableType);
var filterVisitor = (IScimFilterVisitor) filterVisitorType.CreateInstance(_ServerConfiguration);
predicate = filterVisitor.VisitExpression(parser.parse()).Compile();
}
catch (Exception)
{
ErrorType = ScimErrorType.InvalidFilter;
break;
}
// we have an enumerable and a filter predicate
// for each element in the enumerable that satisfies the predicate,
// visit that element as part of the path tree
var originalHasElements = false;
var filteredNodes = new List<Node>();
var enumerator = enumerable.GetEnumerator();
lastPosition = i + 1; // increase the position in the tree
while (enumerator.MoveNext())
{
originalHasElements = true;
dynamic currentElement = enumerator.Current;
if ((bool) predicate(currentElement))
{
filteredNodes.AddRange(
GetAffectedMembers(
pathTree,
ref lastPosition,
new Node(enumerator.Current, node.Target)));
}
}
/* SCIM PATCH 'replace' RULE:
o If the target location is a multi-valued attribute for which a
value selection filter ("valuePath") has been supplied and no
record match was made, the service provider SHALL indicate failure
by returning HTTP status code 400 and a "scimType" error code of
"noTarget".
*/
if (originalHasElements &&
filteredNodes.Count == 0 &&
_Operation != null &&
_Operation.OperationType == OperationType.Replace)
{
throw new ScimPatchException(
ScimErrorType.NoTarget, _Operation);
}
return filteredNodes;
}
}
return new List<Node> { node };
}
示例12: ToByte
//Converts the Data structure into an array of bytes.
public byte[] ToByte()
{
List<byte> result = new List<byte>();
//First four are for the Command.
result.AddRange(BitConverter.GetBytes((int)cmdCommand));
//Add the length of the name.
if (strName != null)
result.AddRange(BitConverter.GetBytes(strName.Length));
else
result.AddRange(BitConverter.GetBytes(0));
//Add the name.
if (strName != null)
result.AddRange(Encoding.UTF8.GetBytes(strName));
return result.ToArray();
}
示例13: GetAllChildren
private List<District> GetAllChildren(int id)
{
var children = new List<District>();
var current = uOW.DistrictRepo.All.Where(d => d.Id == id).Include(d => d.Coordinates).FirstOrDefault();
if (current.IsFolder)
{
var currentChildren = uOW.DistrictRepo.All.Where(d => d.ParentId == id).Include(d=>d.Coordinates).ToList();
foreach(var child in currentChildren)
{
children.AddRange(GetAllChildren(child.Id));
}
children.Add(current);
}
else
{
children.Add(current);
}
return children;
}
示例14: UCPersonnelAddOrEdit_SaveEvent
//.........这里部分代码省略.........
dicFileds.Add("entry_date", Common.LocalDateTimeToUtcLong(dtpentry_date.Value).ToString());// 入职日期
dicFileds.Add("user_weight", txtuser_weight.Caption.Trim());//体重
dicFileds.Add("register_address", txtregister_address.Caption.Trim());//户籍所在地
dicFileds.Add("graduate_date", Common.LocalDateTimeToUtcLong(dtpgraduate_date.Value).ToString());// 毕业时间
dicFileds.Add("wage", txtwage.Caption.Trim());// 工资
dicFileds.Add("birthday", Common.LocalDateTimeToUtcLong(dtpbirthday.Value).ToString());// 出生日期
dicFileds.Add("education", cboeducation.SelectedValue.ToString());//学历
dicFileds.Add("position", cboposition.SelectedValue.ToString());//岗位
dicFileds.Add("political_status", txtpolitical_status.Caption.Trim());//政治面貌
dicFileds.Add("level", cbolevel.SelectedValue.ToString());//级别
dicFileds.Add("health", cbojkzk.SelectedValue.ToString());//健康状况
string nowUtcTicks = Common.LocalDateTimeToUtcLong(HXCPcClient.GlobalStaticObj.CurrentDateTime).ToString();
dicFileds.Add("update_by", HXCPcClient.GlobalStaticObj.UserID);
dicFileds.Add("update_time", nowUtcTicks);
string crmId = string.Empty;
if (wStatus == WindowStatus.Add || wStatus == WindowStatus.Copy)
{
dicFileds.Add("user_code", CommonUtility.GetNewNo(SYSModel.DataSources.EnumProjectType.User));//人员编码
newGuid = Guid.NewGuid().ToString();
currUser_id = newGuid;
dicFileds.Add("user_id", newGuid);//新ID
dicFileds.Add("create_by", HXCPcClient.GlobalStaticObj.UserID);
dicFileds.Add("create_time", nowUtcTicks);
dicFileds.Add("enable_flag", SYSModel.DataSources.EnumEnableFlag.USING.ToString("d"));//1为未删除状态
dicFileds.Add("status", SYSModel.DataSources.EnumStatus.Start.ToString("d"));//启用
dicFileds.Add("data_sources", Convert.ToInt16(SYSModel.DataSources.EnumDataSources.SELFBUILD).ToString());//来源 自建
}
else if (wStatus == WindowStatus.Edit)
{
keyName = "user_id";
keyValue = id;
currUser_id = id;
newGuid = id;
crmId = dr["cont_crm_guid"].ToString();
opName = "更新人员管理";
}
bln = DBHelper.Submit_AddOrEdit(opName, "sys_user", keyName, keyValue, dicFileds);
string photo = string.Empty;
if (picuser.Tag != null)
{
photo = Guid.NewGuid().ToString() + Path.GetExtension(picuser.Tag.ToString());
if (!FileOperation.UploadFile(picuser.Tag.ToString(), photo))
{
return;
}
}
List<SQLObj> listSql = new List<SQLObj>();
listSql = AddPhoto(listSql, currUser_id, photo);
ucAttr.TableName = "sys_user";
ucAttr.TableNameKeyValue = currUser_id;
listSql.AddRange(ucAttr.AttachmentSql);
DBHelper.BatchExeSQLMultiByTrans(opName, listSql);
if (bln)
{
if (wStatus == WindowStatus.Add || wStatus == WindowStatus.Edit)
{
var cont = new tb_contacts_ex
{
cont_id = CommonCtrl.IsNullToString(newGuid),//id
cont_name = CommonCtrl.IsNullToString(this.txtuser_name.Caption.Trim()),//name
cont_post = CommonCtrl.IsNullToString(""),//post
cont_phone = CommonCtrl.IsNullToString(this.txtuser_phone.Caption.Trim()),
nation = CommonCtrl.IsNullToString(this.cbonation.SelectedValue.ToString()),
parent_customer = CommonCtrl.IsNullToString(""),
sex = UpSex(),
status = CommonCtrl.IsNullToString(SYSModel.DataSources.EnumStatus.Start.ToString("d")),
cont_post_remark = CommonCtrl.IsNullToString(""),
cont_crm_guid = CommonCtrl.IsNullToString(crmId),
contact_type = "02"
};
Update.BeginInvoke("上传服务站工作人员", SYSModel.EnumWebServFunName.UpLoadCcontact, cont, null, null);
//DBHelper.WebServHandlerByFun("上传服务站工作人员", SYSModel.EnumWebServFunName.UpLoadCcontact, cont);
}
if (this.RefreshDataStart != null)
{
this.RefreshDataStart();
}
LocalCache._Update(CacheList.User);
MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
deleteMenuByTag(this.Tag.ToString(), this.parentName);
}
else
{
MessageBoxEx.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
示例15: Scan
private void Scan(object sender, DoWorkEventArgs args)
{
var repositories = Repository.MediaRepositories.Select(x => x);
var repositoryCount = 0;
var totalRepositories = repositories.Count();
foreach (var repository in repositories)
{
var paths = new List<string>();
var directory = new DirectoryInfo(repository.Location);
paths.AddRange(FindFiles(directory));
paths.AddRange(ScanSubDirectories(directory));
repository.LastScanned = DateTime.Now;
var pathCount = 0;
Parallel.ForEach(paths, new ParallelOptions {MaxDegreeOfParallelism = 15}, delegate(string path)
{
var repo = DataAccessContext.GetRepository();
pathCount += 1;
ReportProgress(
CalculatePercentage(pathCount, paths.Count, repositoryCount, totalRepositories),
new RepositoryScannerState {CurrentPath = path, CurrentRepository = repository.Location});
var mediaFile = repo.MediaFiles.FirstOrDefault(x => x.FullPath == path);
Track track;
if (mediaFile != null)
{
if (mediaFile.LastModified <
(new FileInfo(mediaFile.FullPath)).LastWriteTime.AddMinutes(-1))
{
track = repo.Tracks.First(x => x.Id == mediaFile.TrackId);
//Update Track metadata
ProcessTrack(path, ref track, ref repo);
repo.SubmitChanges();
}
}
else
{
track = new Track {Id = Guid.NewGuid()};
//Update Track metadata
ProcessTrack(path, ref track, ref repo);
repo.Tracks.InsertOnSubmit(track);
repo.SubmitChanges();
var file = new FileInfo(path);
mediaFile = new MediaFile
{
Id = Guid.NewGuid(),
RepositoryId = repository.Id,
FullPath = path,
DateAdded = DateTime.Now,
LastModified = file.LastWriteTime,
FileType = file.Extension,
Size = file.Length,
TrackId = track.Id
};
repo.MediaFiles.InsertOnSubmit(mediaFile);
repo.SubmitChanges();
}
});
repositoryCount += 1;
}
}