Click here to Skip to main content
15,889,728 members
Home / Discussions / C#
   

C#

 
AnswerRe: Run List Of Tasks Sequentially and Process Them As The Complete Pin
ZurdoDev1-Nov-17 9:37
professionalZurdoDev1-Nov-17 9:37 
AnswerRe: Run List Of Tasks Sequentially and Process Them As The Complete Pin
Sascha Lefèvre1-Nov-17 10:31
professionalSascha Lefèvre1-Nov-17 10:31 
AnswerRe: Run List Of Tasks Sequentially and Process Them As The Complete Pin
BillWoodruff2-Nov-17 17:56
professionalBillWoodruff2-Nov-17 17:56 
AnswerRe: Run List Of Tasks Sequentially and Process Them As The Complete Pin
MadMyche14-Nov-17 8:35
professionalMadMyche14-Nov-17 8:35 
QuestionC#+WebBrowser+JavaScript - full download Pin
kama_kama31-Oct-17 12:03
kama_kama31-Oct-17 12:03 
QuestionRe: C#+WebBrowser+JavaScript - full download Pin
Karthik_Mahalingam31-Oct-17 17:00
professionalKarthik_Mahalingam31-Oct-17 17:00 
AnswerRe: C#+WebBrowser+JavaScript - full download Pin
kama_kama31-Oct-17 20:08
kama_kama31-Oct-17 20:08 
QuestionWhat's The Best Way To Do This? Pin
Kevin Marois31-Oct-17 7:04
professionalKevin Marois31-Oct-17 7:04 
We have 2 files with settings in them.

The first is a constants file that has all kinds of data in it:
public struct General
{
    public static float FAIL_CODE = -999999;
    public static int BayPort = 0xc000;
}

public struct Thermal
{
    public static float Gi = 1;
    public static float Gv = 4.0875f;
    public static int Resistance = 1;
    public static int Temp = 0;
}

public struct BlisterMotor
{
    public static uint MIN_BLISTER_POSITION = 0;
    public static uint MAX_BLISTER_POSITION = 56250;
}
The other is an embedded xml file resource:
<Parameter>
    <Name>Effector</Name>
    <Value>150</Value>
</Parameter>
<Parameter>
    <Name>SampleHeaterSetPoint</Name>
    <Value>66</Value>
</Parameter>
<Parameter>
    <Name>SampleHeaterSamples</Name>
    <Value>18</Value>
</Parameter>

We want to make all of this user editable with a UI, so I want to serialize all of them to XML.

I'm trying to find a way to do this with generics, so...
public class Setting<T>
{
    public T SettingValue { get; set; }
    public T MinValue { get; set; }
    public T MaxValue { get; set; }
    public string Key { get; set; }
    public string Description { get; set; }
}
Then a class to hold all of them:
public List<Setting> MySettings { get; set; }
But this won't compile because the Setting class in the List<> requires a type argument.

But I don't see how this would work with generics. That really only leave overriding the base class with a different type for each:
public List<SettingBase> MySettings { get; set; }

public class SettingBase
{
    public string Key { get; set; }
    public string Description { get; set; }
}

public class SettingInt : SettingBase
{
    public int SettingValue { get; set; }
    public int MinValue { get; set; }
    public int MaxValue { get; set; }
}

public class SettingDouble : SettingBase
{
    public double SettingValue { get; set; }
    public double MinValue { get; set; }
    public double MaxValue { get; set; }
}

Anyone have a better idea?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: What's The Best Way To Do This? Pin
Gerry Schmitz31-Oct-17 12:08
mveGerry Schmitz31-Oct-17 12:08 
GeneralRe: What's The Best Way To Do This? Pin
Rob Philpott1-Nov-17 3:04
Rob Philpott1-Nov-17 3:04 
GeneralRe: What's The Best Way To Do This? Pin
peterkmx2-Nov-17 3:49
professionalpeterkmx2-Nov-17 3:49 
GeneralRe: What's The Best Way To Do This? Pin
Gerry Schmitz2-Nov-17 5:31
mveGerry Schmitz2-Nov-17 5:31 
AnswerRe: What's The Best Way To Do This? Pin
Pete O'Hanlon31-Oct-17 21:45
mvePete O'Hanlon31-Oct-17 21:45 
GeneralRe: What's The Best Way To Do This? Pin
Kevin Marois1-Nov-17 5:43
professionalKevin Marois1-Nov-17 5:43 
GeneralRe: What's The Best Way To Do This? Pin
Pete O'Hanlon1-Nov-17 5:59
mvePete O'Hanlon1-Nov-17 5:59 
AnswerRe: What's The Best Way To Do This? Pin
Nathan Minier1-Nov-17 1:36
professionalNathan Minier1-Nov-17 1:36 
SuggestionRe: What's The Best Way To Do This? Pin
Sascha Lefèvre1-Nov-17 2:01
professionalSascha Lefèvre1-Nov-17 2:01 
GeneralRe: What's The Best Way To Do This? Pin
Nathan Minier1-Nov-17 2:34
professionalNathan Minier1-Nov-17 2:34 
QuestionRe: What's The Best Way To Do This? Pin
Eddy Vluggen1-Nov-17 10:19
professionalEddy Vluggen1-Nov-17 10:19 
AnswerRe: What's The Best Way To Do This? Pin
Wendelius1-Nov-17 10:51
mentorWendelius1-Nov-17 10:51 
QuestionNext generics Problem Pin
Kevin Marois31-Oct-17 6:03
professionalKevin Marois31-Oct-17 6:03 
AnswerRe: Next generics Problem Pin
harold aptroot31-Oct-17 6:11
harold aptroot31-Oct-17 6:11 
GeneralRe: Next generics Problem Pin
Kevin Marois31-Oct-17 6:25
professionalKevin Marois31-Oct-17 6:25 
QuestionHow To Make This Generic Pin
Kevin Marois31-Oct-17 5:02
professionalKevin Marois31-Oct-17 5:02 
AnswerRe: How To Make This Generic Pin
Sascha Lefèvre31-Oct-17 5:43
professionalSascha Lefèvre31-Oct-17 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.