- Add configuration in ServiceReferences.ClientConfig
eg)
<configuration>
<appSettings>
<add key="MAX_UPLOAD_SIZE" value="3145728" />
</appSettings>
<system.serviceModel>
....
</system.serviceModel>
</configuration>
2. Create your own ConfigurationManager
- Add reference System.Xml.Linq;
eg)
public static class ConfigurationManager
{
static ConfigurationManager()
{
AppSettings = new Dictionary();
ReadSettings();
}
public static DictionaryAppSettings { get; set; }
private static void ReadSettings()
{
string strKey = string.Empty;
string strValue = string.Empty;
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = new XmlXapResolver();
XmlReader reader = XmlReader.Create("ServiceReferences.ClientConfig");
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "add")
{
if (reader.HasAttributes)
{
strKey = reader.GetAttribute("key");
if (!string.IsNullOrEmpty(strKey))
{
strValue = reader.GetAttribute("value");
AppSettings.Add(strKey, strValue);
}
}
}
}
}
}
3. Create property in your class
eg)
public class Consts
{
public Int64 MAX_UPLOAD_SIZE
{
get
{
string MaxUploadSize = ConfigurationManager.AppSettings["MAX_UPLOAD_SIZE"];
return int.Parse(MaxUploadSize);
}
}
}
4. Create instance in App.xaml
eg)
<local:Consts x:Key="Consts" />
5. Bind with StaticResource
eg)
<telerik:RadUpload MaxFileSize="{Binding Source={StaticResource Consts}, Path=MAX_UPLOAD_SIZE}" />
댓글 없음:
댓글 쓰기