本文整理汇总了C#中IList.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Cast方法的具体用法?C# IList.Cast怎么用?C# IList.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Cast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DropManyU
public static short[] DropManyU(
IVisio.Page page,
IList<IVisio.Master> masters,
IEnumerable<VA.Drawing.Point> points)
{
if (masters == null)
{
throw new System.ArgumentNullException("masters");
}
if (masters.Count < 1)
{
return new short[0];
}
if (points == null)
{
throw new System.ArgumentNullException("points");
}
// NOTE: DropMany will fail if you pass in zero items to drop
var masters_obj_array = masters.Cast<object>().ToArray();
var xy_array = VA.Drawing.Point.ToDoubles(points).ToArray();
System.Array outids_sa;
page.DropManyU(masters_obj_array, xy_array, out outids_sa);
short[] outids = (short[])outids_sa;
return outids;
}
示例2: CreateInsert
public IList<object> CreateInsert(IList<object> list)
{
IList<SampleSQLData> convertedList = list.Cast<SampleSQLData>().ToList();
IList<object> insertList = new List<object>();
foreach (SampleSQLData sample in convertedList)
{
foreach (var fk in sample.FK_References)
{
SampleSQLData sampleDataFiltered = convertedList.Where(l => !_tablesLoaded.ContainsKey(fk.Table) && l.Table == fk.Table).SingleOrDefault();
if (sampleDataFiltered != null)
{
TSQLProcessor.Execute(new CreateInsertSQL(), sampleDataFiltered, insertList);
_tablesLoaded.Add(fk.Table, true);
}
}
if (!_tablesLoaded.ContainsKey(sample.Table))
{
TSQLProcessor.Execute(new CreateInsertSQL(), sample, insertList);
_tablesLoaded.Add(sample.Table, true);
}
}
return insertList;
}
示例3: TransformList
public IList TransformList(IList collection)
{
if (_listTransformation == null)
{
return collection;
}
IEnumerable<object> toTransform;
if (collection.Count > 0 && collection[0] is object[])
{
if (((object[])collection[0]).Length != 1)
{
// We only expect single items
throw new NotSupportedException();
}
toTransform = collection.Cast<object[]>().Select(o => o[0]);
}
else
{
toTransform = collection.Cast<object>();
}
object transformResult = _listTransformation.DynamicInvoke(toTransform);
var resultList = transformResult as IList;
return resultList ?? new List<object> { transformResult };
}
示例4: SetExecReportOrders
private void SetExecReportOrders(IList orders)
{
if (orders == null) return;
ExecutionStatsGenerator.SetOrders(orders.Cast<Order>().ToList());
var window = new ExecutionReportWindow(ExecutionStatsGenerator);
window.Show();
}
示例5: Filter
void IProfileSelector.FillNames(IList<string> profiles)
{
profileComboBox.Items.Clear();
profileComboBox.Items.AddRange(Filter == null
? profiles.Cast<object>().ToArray()
: profiles.Where(x => Filter(x)).Cast<object>().ToArray());
}
示例6: CreateDelete
public IList<object> CreateDelete(IList<object> list, IDictionary<string, string> dynamicParameters)
{
IList<SampleMongoData> convertedList = list.Cast<SampleMongoData>().ToList();
IList<object> deleteList = new List<object>();
foreach (var sample in convertedList)
{
IDictionary<string, IList<BsonElement>> data = new Dictionary<string, IList<BsonElement>>();
IList<BsonElement> elementList = new List<BsonElement>();
foreach (var row in sample.Rows)
{
foreach (var key in sample.Keys)
{
Common.Schema schema = sample.Schema.SingleOrDefault(s => s.Column == key);
string value = JSON.DeserializeDynamic(row.ToString())[schema.Column];
if (dynamicParameters.ContainsKey(value))
{
value = dynamicParameters[value];
}
elementList.Add(new BsonElement(schema.Column, ParserDataType.ParseMongo((ParserDataType.DataType)Enum.Parse(typeof(ParserDataType.DataType), schema.Type, true), value)));
}
}
data.Add(sample.Collection, elementList);
deleteList.Add(data);
}
return deleteList;
}
示例7: AddSongsToPlayListExecute
private void AddSongsToPlayListExecute(IList songs)
{
if (songs != null)
{
PlayerObserver.NotifyAddToPlayList(new ObservableCollection<Song>(songs.Cast<Song>()));
}
}
示例8: AddToIgnoreList
private void AddToIgnoreList(IList itemsToHide)
{
var items = itemsToHide.Cast<ShortcutViewModel>().ToList();
shortcuts.RemoveAll(items);
var entries = items.Select(shortcut => new IgnoreEntry(path: shortcut.ShortcutPath)).ToArray();
tilesDavis.AddToIgnoreList(entries);
}
示例9: TransformList
public IList TransformList(IList collection)
{
if (_listTransformation == null)
{
return collection;
}
object transformResult = collection;
//if (collection.Count > 0)
{
if (collection.Count > 0 && collection[0] is object[])
{
if ( ((object[])collection[0]).Length != 1)
{
// We only expect single items
throw new NotSupportedException();
}
transformResult = _listTransformation.DynamicInvoke(collection.Cast<object[]>().Select(o => o[0]));
}
else
{
transformResult = _listTransformation.DynamicInvoke(collection);
}
}
if (transformResult is IList)
{
return (IList) transformResult;
}
var list = new ArrayList {transformResult};
return list;
}
示例10: Render
public override SqlString Render(IList args, ISessionFactoryImplementor factory)
{
return SqlString.Parse(
args.Cast<object>()
.Select(x => x.ToString())
.ToString(x => "ISNULL(" + x + ", '')", " + ' ' + ")
);
}
示例11: groupByKey
public static IList groupByKey(IList list, IList keys)
{
return
list.Cast<object>().Zip(keys.Cast<object>(), (item, key) => new { item, key })
.GroupBy(x => x.key)
.Select(x => x.Select(y => y.item).ToList())
.ToList();
}
示例12: AddAndNotify
private void AddAndNotify(IList items)
{
if (items.Count > 0)
{
filteredCollection.AddRange(items.Cast<object>());
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, items));
}
}
示例13: Polygon
/// <summary>
/// Create a polygon from a list of at least 3 points with no duplicates.
/// </summary>
/// <param name="points">A list of unique points</param>
public Polygon( IList<PolygonPoint> points ) {
if (points.Count < 3) throw new ArgumentException("List has fewer than 3 points", "points");
// Lets do one sanity check that first and last point hasn't got same position
// Its something that often happen when importing polygon data from other formats
if (points[0].Equals(points[points.Count - 1])) points.RemoveAt(points.Count - 1);
_points.AddRange(points.Cast<TriangulationPoint>());
}
示例14: SetColumns
public void SetColumns(IList<string> nameList, IList<bool> checkedList)
{
checkedListBox1.Items.Clear();
checkedListBox1.Items.AddRange(nameList.Cast<object>().ToArray());
for (int i = 0; i < checkedList.Count; i++)
{
checkedListBox1.SetItemChecked(i, checkedList[i]);
}
}
示例15: RunUserScripts
private void RunUserScripts(IList trades)
{
if (trades == null || trades.Count == 0) return;
Parent.ScriptRunner.RunTradeScripts(trades.Cast<Trade>().ToList(), Context.Strategies.ToList(), Context.Tags.ToList(), Context);
foreach(Trade trade in trades)
{
trade.TagStringUpdated();
}
}