Beispiel #1
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value is string)
     {
         try
         {
             string     s    = (string)value;
             string[]   strs = s.Split(new char[] { ',' });
             NoiseValue tr   = new NoiseValue();
             tr.NIoutHigh = double.Parse(strs[0]);
             tr.NFTC1Low  = double.Parse(strs[1]);
             tr.NFTC1High = double.Parse(strs[2]);
             tr.NFTC2Low  = double.Parse(strs[3]);
             tr.NFTC2High = double.Parse(strs[4]);
             tr.NtcLow    = double.Parse(strs[5]);
             tr.Nd2_1     = double.Parse(strs[6]);
             tr.Nd2_2     = double.Parse(strs[7]);
             tr.Nd2_3     = double.Parse(strs[8]);
             tr.NIoutLow  = double.Parse(strs[9]);
             tr.Ta        = double.Parse(strs[10]);
             tr.NVoutLow  = double.Parse(strs[11]);
             tr.NVoutHigh = double.Parse(strs[12]);
             tr.NtcHigh   = double.Parse(strs[13]);
             tr.Ttca      = double.Parse(strs[14]);
             return(tr);
         }
         catch
         {
             throw new Exception("Type can't be converted.");
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Beispiel #2
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string) && value is NoiseValue)
     {
         NoiseValue tr = (NoiseValue)value;
         return(tr.NIoutHigh.ToString() + "," + tr.NFTC1Low.ToString() + "," + tr.NFTC1High.ToString() + "," + tr.NFTC2Low.ToString() + "," + tr.NFTC2High.ToString() + "," +
                tr.NtcLow.ToString() + "," + tr.Nd2_1.ToString() + "," + tr.Nd2_2.ToString() + "," + tr.Nd2_3.ToString() + "," + tr.NIoutLow.ToString() + "," +
                tr.Ta.ToString() + "," + tr.NVoutLow.ToString() + "," + tr.NVoutHigh.ToString() + "," + tr.NtcHigh.ToString() + "," + tr.Ttca.ToString());
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }