Pass a List of Series to SetSeries

I am using DotNet.Highcharts in conjunction with Visual Studio 2010. I have created an array of Series:

List<Series> allSeries = new List<Series>();

I then looped through a database and added several different Series. Then I created a Highchart and need to add the allSeries list to it. I have the code below that I used to create a Series one at a time. How can I take the allSeries list and pass it to SetSeries?

.SetSeries(new[]
           {
               new Series { Name = "Combiner 2", Data = new Data(myData2) },
               new Series { Name = "Combiner 3", Data = new Data(myData3) }
           });

Answers


if I am left to assume that the myData2 and myData3 objects are contained in or could be extracted from allSeries, then you should be able to do something like this:

.SetSeries(allSeries.Select(s=> new Series { Name = s.Name, Data = s.Data }));

EDIT: If set series isn't looking for an IEnumerable<Series> but instead needs Object[] or Series[], then you could do this:

//casts series elements to object, then projects to array
.SetSeries(allSeries.Select(s=> (object)new Series { Name = s.Name, Data = s.Data }).ToArray());

or maybe this:

//projects series elements to array of series
.SetSeries(allSeries.Select(s=> new Series { Name = s.Name, Data = s.Data }).ToArray());

it all depends on what the method signature for SetSeries is.


Need Your Help

Calling WP functions outside of functions.php

php wordpress

Is it possible to call WordPress functions outside of the functions.php file of a WordPress theme in a non-standard WP-theme file?

Python variable assignment doesn't work

python

&gt;&gt;&gt; header = 'subject'

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.