M
mark4asp
In trying to get the C# conversion code for Head First Design Patterns
to work I came accross a number of warnings. e.g.
Warning
Number: 10
Description: 'System.Configuration.ConfigurationSettings.AppSettings'
is obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!System.Configuration.ConfigurationManager.AppSettings'
E:\code\HeadFirstDesignPatternsInCSharp\Decorator.Starbuzz\Expresso.cs
Line: 31
Col: 30
Project: Decorator.Starbuzz
How do I fix it?
The file includes "System.Configuration", but when I write
ConfigurationManager I don't see the usual object there. How do I fix
this?
Here is the example offending file: Expresso.cs
using System;
using System.Configuration;
namespace HeadFirstDesignPatterns.Decorator.Starbuzz
{
/// <summary>
/// Summary description for Expresso.
/// </summary>
public class Expresso: Beverage
{
public Expresso()
{}
public override double Cost()
{
return GetSize(base.Size);
}
public override string GetDescription()
{
return "Expresso";
}
private double GetSize(BeverageSize size)
{
switch(size)
{
case BeverageSize.TALL:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeTall"]);
case BeverageSize.GRANDE:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeGrande"]);
case BeverageSize.VENTI:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeVenti"]);
default:
return 1.50;
}
}
}
}
to work I came accross a number of warnings. e.g.
Warning
Number: 10
Description: 'System.Configuration.ConfigurationSettings.AppSettings'
is obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!System.Configuration.ConfigurationManager.AppSettings'
E:\code\HeadFirstDesignPatternsInCSharp\Decorator.Starbuzz\Expresso.cs
Line: 31
Col: 30
Project: Decorator.Starbuzz
How do I fix it?
The file includes "System.Configuration", but when I write
ConfigurationManager I don't see the usual object there. How do I fix
this?
Here is the example offending file: Expresso.cs
using System;
using System.Configuration;
namespace HeadFirstDesignPatterns.Decorator.Starbuzz
{
/// <summary>
/// Summary description for Expresso.
/// </summary>
public class Expresso: Beverage
{
public Expresso()
{}
public override double Cost()
{
return GetSize(base.Size);
}
public override string GetDescription()
{
return "Expresso";
}
private double GetSize(BeverageSize size)
{
switch(size)
{
case BeverageSize.TALL:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeTall"]);
case BeverageSize.GRANDE:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeGrande"]);
case BeverageSize.VENTI:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeVenti"]);
default:
return 1.50;
}
}
}
}