A function as a generic (template) class variable


i having trouble finding documentation on how use func<typename> constructor.  perhaps wrong approach let me describe need.

creating generic/template class stores function return type parameter.  whole purpose of class base class "data" classes used draw control based on large sets of data , simplify process of adding new data points in future.  data types simple variable types (bool, string, int, float, etc...)

abstract class geodataset<datatype> : geodatasetbase { 	protected func<datatype> _datafunction; 	protected geodataset(string name, func<datatype> datafunction, resourcetype resourcetype, int menupriority) : base(name, resourcetype, menupriority) 	{ 		_datafunction = datafunction; 	} }

an example of how going use lets want color data points celsius temperature.  create "temperature" class uses float template argument this:

public class somedatasourceclass { 	float gettemperature() 	{ 		//some code here returns float 	} }  public class temperature : geodataset<float> { 	public temperature() : base("temperature", /*????*/, resourcetype.color, 100) 	{ 		// necessary construction code here... 	} }

replace /*????*/ designate somedatasourceclass.gettemperature() method?  or need go different way?





try argument:

   new somedatasourceclass().gettemperature

the above somedatasourceclass object can made differently. example, if exists, can passed parameter constructor of temperature.




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'