|
|
От: |
V.Petrovski
|
|
| Дата: | 15.07.03 07:54 | ||
| Оценка: | |||
.....
public void ParseValue(string value)
{
try
{
....
}
catch(Exception ex)
{
throw new ParseException("Invalid value format",ex);
}
}
.....
private void btnOk_Click(object sender, EventArgs args)
{
try
{
ParseValue(txtValue.Text);
}
catch(ParseException ex)
{
MessageBox.Show(ex.Message);
}
catch(Exception ex)
{
MessageBox.Show("Unknown error "+ex.Message);
}
}
........
Arg_IndexOutOfRangeException = Index was outside the bounds of the array.
Arg_NotSupportedException = Specified method is not supported.
...
//------------------------------------------------------------------------------
// This file is autogenerated by gensr.pl utilitity. Do not modify.
//------------------------------------------------------------------------------
namespace MyNameSpace {
using System;
using System.Reflection;
using System.Globalization;
using System.Resources;
using System.Text;
using System.Threading;
using System.ComponentModel;
/// <summary>
/// AutoGenerated resource class. Usage:
///
/// string s = StrR.GetString(StrR.m_MyIdenfitier);
/// OR
/// string s = StrR.MyIdenfitier;
///
/// </summary>
internal sealed class SR {
static SR loader = null;
static CultureInfo info = Thread.CurrentThread.CurrentCulture;
ResourceManager resources;
...
internal const string Arg_IndexOutOfRangeException = "Arg_IndexOutOfRangeException";
internal const string Arg_NotSupportedException = "Arg_NotSupportedException";
...
private SR() {
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
resources = new System.Resources.ResourceManager("MyNameSpace.resource", this.GetType().Module.Assembly);
}
private static SR GetLoader() {
if (loader == null) {
lock(typeof(SR)) {
if (loader == null) {
loader = new SR();
}
}
}
return loader;
}
public static string GetString(string name, params object[] args) {
// null CultureInfo: let ResouceManager determine the culture
return GetString(info, name, args);
}
public static string GetString(CultureInfo culture, string name, params object[] args) {
SR sys = GetLoader();
if (sys == null)
return null;
string res = sys.resources.GetString(name, culture);
if (args != null && args.Length > 0) {
return String.Format(res, args);
}
else {
return res;
}
}
public static string GetString(string name) {
return GetString(info, name);
}
public static string GetString(CultureInfo culture, string name) {
SR sys = GetLoader();
if (sys == null)
return null;
return sys.resources.GetString(name, culture);
}
public static bool GetBoolean(string name) {
return GetBoolean(name);
}
public static bool GetBoolean(CultureInfo culture, string name) {
bool val = false;
SR sys = GetLoader();
if (sys != null) {
object res = sys.resources.GetObject(name, culture);
if (res is bool) {
val = (bool)res;
}
}
return val;
}
.....
}
}.....
public void ParseValue(string value)
{
try
{
....
}
catch(Exception ex)
{
throw new ParseException(SR.GetString(SR.Invalid_value_format),ex);
}
}
.....
private void btnOk_Click(object sender, EventArgs args)
{
try
{
ParseValue(txtValue.Text);
}
catch(ParseException ex)
{
MessageBox.Show(ex.Message);
}
catch(Exception ex)
{
MessageBox.Show(SR.GetString(SR.Unknown_error,ex.Message));
}
}
.....