本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.IndexOf方法的具体用法?C# System.Collections.Generic.List.IndexOf怎么用?C# System.Collections.Generic.List.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.IndexOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
/// <summary>
/// Imports (create) a document from a xmlrepresentation of a document, used by the packager
/// </summary>
/// <param name="ParentId">The id to import to</param>
/// <param name="Creator">Creator of the new document</param>
/// <param name="Source">Xmlsource</param>
public static int Import(int ParentId, User Creator, XmlElement Source)
{
// check what schema is used for the xml
bool sourceIsLegacySchema = Source.Name.ToLower() == "node" ? true : false;
// check whether or not to create a new document
int id = int.Parse(Source.GetAttribute("id"));
Document d = null;
if (Document.IsDocument(id))
{
try
{
// if the parent is the same, we'll update the existing document. Else we'll create a new document below
d = new Document(id);
if (d.ParentId != ParentId)
d = null;
}
catch { }
}
// document either didn't exist or had another parent so we'll create a new one
if (d == null)
{
string nodeTypeAlias = sourceIsLegacySchema ? Source.GetAttribute("nodeTypeAlias") : Source.Name;
d = MakeNew(
Source.GetAttribute("nodeName"),
DocumentType.GetByAlias(nodeTypeAlias),
Creator,
ParentId);
}
else
{
// update name of the document
d.Text = Source.GetAttribute("nodeName");
}
d.CreateDateTime = DateTime.Parse(Source.GetAttribute("createDate"));
// Properties
string propertyXPath = sourceIsLegacySchema ? "data" : "* [not(@isDoc)]";
foreach (XmlElement n in Source.SelectNodes(propertyXPath))
{
string propertyAlias = sourceIsLegacySchema ? n.GetAttribute("alias") : n.Name;
Property prop = d.getProperty(propertyAlias);
string propValue = xmlHelper.GetNodeValue(n);
if (prop != null)
{
// only update real values
if (!String.IsNullOrEmpty(propValue))
{
//test if the property has prevalues, of so, try to convert the imported values so they match the new ones
SortedList prevals = cms.businesslogic.datatype.PreValues.GetPreValues(prop.PropertyType.DataTypeDefinition.Id);
//Okey we found some prevalue, let's replace the vals with some ids
if (prevals.Count > 0)
{
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(propValue.Split(','));
foreach (DictionaryEntry item in prevals)
{
string pval = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Value;
string pid = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Id.ToString();
if (list.Contains(pval))
list[list.IndexOf(pval)] = pid;
}
//join the list of new values and return it as the new property value
System.Text.StringBuilder builder = new System.Text.StringBuilder();
bool isFirst = true;
foreach (string str in list)
{
if (!isFirst)
builder.Append(",");
builder.Append(str);
isFirst = false;
}
prop.Value = builder.ToString();
}
else
prop.Value = propValue;
}
}
else
{
LogHelper.Warn<Document>(String.Format("Couldn't import property '{0}' as the property type doesn't exist on this document type", propertyAlias));
}
}
//.........这里部分代码省略.........
示例2: FixList
private void FixList()
{
StoreDBEntities storeDBEntities = new StoreDBEntities();
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
System.Collections.Generic.List<long> list2 = new System.Collections.Generic.List<long>();
System.Collections.Generic.List<long> list3 = new System.Collections.Generic.List<long>();
System.Collections.Generic.List<DailyTransaction> list4 = (
from x in storeDBEntities.DailyTransactions
orderby x.Date
select x).ToList<DailyTransaction>();
for (int i = 0; i < list4.Count; i++)
{
if (!list.Contains(list4[i].Date))
{
list.Add(list4[i].Date);
list2.Add(0L);
list3.Add(0L);
}
if (list4[i].Payment)
{
System.Collections.Generic.List<long> list5;
int index;
(list5 = list2)[index = list.IndexOf(list4[i].Date)] = list5[index] + list4[i].Price;
}
else
{
System.Collections.Generic.List<long> list6;
int index2;
(list6 = list3)[index2 = list.IndexOf(list4[i].Date)] = list6[index2] + list4[i].Price;
}
}
ListViewItem[] array = new ListViewItem[list.Count];
for (int j = 0; j < list.Count; j++)
{
long num = list2[j] - list3[j];
array[j] = new ListViewItem(new string[]
{
list[j],
list2[j].ToString("0,0"),
list3[j].ToString("0,0"),
((num > 0L) ? "+" : "") + num.ToString("0,0")
});
if (num != 0L)
{
array[j].SubItems[3].ForeColor = System.Drawing.Color.OrangeRed;
}
}
this.lstAllTrans.Items.Clear();
this.lstAllTrans.Items.AddRange(array);
lstAllTrans.EnsureVisible(lstAllTrans.Items.Count - 1);
Utilities.ListViewFixColumns(lstAllTrans);
}
示例3: mergeMemberC83
/// <summary>
/// チェックリストを統合し、string[][]型で返す。
/// </summary>
/// <returns></returns>
private string[][] mergeMemberC83()
{
var result = new System.Collections.Generic.List<string[]>();
var recordCircle = new System.Collections.Generic.List<int>();
var Color = new Color();
string[] header = { "Header", "ComicMarketCD-ROMCatalog", "ComicMarket83", "UTF-8", VERSION };
result.Add(header);
foreach (ListViewItem item in memberList.Items)
{
DataContainer obj = item.Tag as DataContainer;
if (obj == null) continue;
for (int i = 0; i < obj.data.GetLength(0); i++)
{
if (obj.data[i][0] != "Circle") continue;
try
{
if (recordCircle.IndexOf(int.Parse(obj.data[i][1])) < 0)
{
result.Add(obj.data[i]);
recordCircle.Add(int.Parse(obj.data[i][1]));
}
else
{
int m = recordCircle.IndexOf(int.Parse(obj.data[i][1])) + 1;
string[] tmp = result.ToArray()[m];
int tmp1 = int.Parse(tmp[2]);
int tmp2 = int.Parse(obj.data[i][2]);
if (tmp1 == 0) tmp1 = 10;
if (tmp2 == 0) tmp2 = 10;
if (tmp1 > tmp2)
tmp1 = tmp2;
if (tmp1 >= 10) tmp1 = 0;
tmp[2] = tmp1.ToString();
tmp[17] += obj.data[i][17];
result.RemoveAt(result.Count);
result.Add(tmp);
}
}
catch (Exception) { continue; }
}
}
foreach (Color item in Settings.colorSettings)
{
if (item.label == null) continue;
string[] tmpcolor = { "Color", item.number.ToString(), Color.ToBGRColor(item.checkcolor), Color.ToBGRColor(item.printcolor), item.label };
result.Add(tmpcolor);
}
return result.ToArray();
}
示例4: GetStandardValues
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
StandardValuesCollection dataSourceNames = _standardValues;
if (null == _standardValues) {
// Get the sources rowset for the SQLOLEDB enumerator
DataTable table = (new OleDbEnumerator()).GetElements();
DataColumn column2 = table.Columns["SOURCES_NAME"];
DataColumn column5 = table.Columns["SOURCES_TYPE"];
//DataColumn column4 = table.Columns["SOURCES_DESCRIPTION"];
System.Collections.Generic.List<string> providerNames = new System.Collections.Generic.List<string>(table.Rows.Count);
foreach(DataRow row in table.Rows) {
int sourceType = (int)row[column5];
if (DBSOURCETYPE_DATASOURCE_TDP == sourceType || DBSOURCETYPE_DATASOURCE_MDP == sourceType) {
string progid = (string)row[column2];
if (!OleDbConnectionString.IsMSDASQL(progid.ToLower(CultureInfo.InvariantCulture))) {
if (0 > providerNames.IndexOf(progid)) {
providerNames.Add(progid);
}
}
}
}
// Create the standard values collection that contains the sources
dataSourceNames = new StandardValuesCollection(providerNames);
_standardValues = dataSourceNames;
}
return dataSourceNames;
}
示例5: PrepareForSerialization
/// <summary>
/// Property helper for Files & WordFiles, ensures the data retrieved
/// from those two properties is 'in sync'
/// </summary>
private void PrepareForSerialization()
{
if (_SerializePreparationDone) return;
_FileList = new List<File>();
_WordfileArray = new CatalogWordFile[_Index.Count];
Word[] wordArray = new Word[_Index.Count];
_Index.Values.CopyTo(wordArray, 0);
// go through all the words
for (int i = 0; i < wordArray.Length; i++)
{
// first, add all files to the 'flist' collection
foreach (File f in wordArray[i].Files)
{
if (!_FileList.Contains(f))
{
_FileList.Add(f);
}
}
// now go through again and use the indexes
CatalogWordFile wf = new CatalogWordFile();
wf.Text = wordArray[i].Text;
foreach (File f in wordArray[i].Files)
{
wf.FileIds.Add(_FileList.IndexOf(f));
}
_WordfileArray[i] = wf;
}
_SerializePreparationDone = true;
}