Here are the examples of the csharp api Locale.GetText(string, params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
511 Examples
19
View Source File : AuthenticodeBase.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
internal bool ReadFirstBlock ()
{
if (fs == null)
return false;
fs.Position = 0;
// read first block - it will include (100% sure)
// the MZ header and (99.9% sure) the PE header
blockLength = fs.Read (fileblock, 0, fileblock.Length);
blockNo = 1;
if (blockLength < 64)
return false; // invalid PE file
// 1. Validate the MZ header informations
// 1.1. Check for magic MZ at start of header
if (BitConverterLE.ToUInt16 (fileblock, 0) != 0x5A4D)
return false;
// 1.2. Find the offset of the PE header
peOffset = BitConverterLE.ToInt32 (fileblock, 60);
if (peOffset > fileblock.Length) {
// just in case (0.1%) this can actually happen
string msg = String.Format (Locale.GetText (
"Header size too big (> {0} bytes)."),
fileblock.Length);
throw new NotSupportedException (msg);
}
if (peOffset > fs.Length)
return false;
// 2. Read between DOS header and first part of PE header
// 2.1. Check for magic PE at start of header
// PE - NT header ('P' 'E' 0x00 0x00)
if (BitConverterLE.ToUInt32 (fileblock, peOffset) != 0x4550)
return false;
// 2.2. Locate IMAGE_DIRECTORY_ENTRY_SECURITY (offset and size)
dirSecurityOffset = BitConverterLE.ToInt32 (fileblock, peOffset + 152);
dirSecuritySize = BitConverterLE.ToInt32 (fileblock, peOffset + 156);
// COFF symbol tables are deprecated - we'll strip them if we see them!
// (otherwise the signature won't work on MS and we don't want to support COFF for that)
coffSymbolTableOffset = BitConverterLE.ToInt32 (fileblock, peOffset + 12);
return true;
}
19
View Source File : DSAManaged.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override void ImportParameters (DSAParameters parameters)
{
if (m_disposed)
throw new ObjectDisposedException (Locale.GetText ("Keypair was disposed"));
// if missing "mandatory" parameters
if ((parameters.P == null) || (parameters.Q == null) || (parameters.G == null))
throw new CryptographicException (Locale.GetText ("Missing mandatory DSA parameters (P, Q or G)."));
// We can calculate Y from X, but both can't be missing
if ((parameters.X == null) && (parameters.Y == null))
throw new CryptographicException (Locale.GetText ("Missing both public (Y) and private (X) keys."));
p = new BigInteger (parameters.P);
q = new BigInteger (parameters.Q);
g = new BigInteger (parameters.G);
// optional parameter - private key
if (parameters.X != null)
x = new BigInteger (parameters.X);
else
x = null;
// we can calculate Y from X if required
if (parameters.Y != null)
y = new BigInteger (parameters.Y);
else
y = g.ModPow (x, p);
// optional parameter - pre-computation
if (parameters.J != null) {
j = new BigInteger (parameters.J);
} else {
j = (p - 1) / q;
j_missing = true;
}
// optional - seed and counter must both be present (or absent)
if (parameters.Seed != null) {
seed = new BigInteger (parameters.Seed);
counter = parameters.Counter;
}
else
seed = 0;
// we now have a keypair
keypairGenerated = true;
}
19
View Source File : DSAManaged.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override byte[] CreateSignature (byte[] rgbHash)
{
if (m_disposed)
throw new ObjectDisposedException (Locale.GetText ("Keypair was disposed"));
if (rgbHash == null)
throw new ArgumentNullException ("rgbHash");
if (rgbHash.Length != 20)
throw new CryptographicException ("invalid hash length");
if (!keypairGenerated)
Generate ();
// if required key must be generated before checking for X
if (x == null)
throw new CryptographicException ("no private key available for signature");
BigInteger m = new BigInteger (rgbHash);
// (a) Select a random secret integer k; 0 < k < q.
BigInteger k = BigInteger.GenerateRandom (160);
while (k >= q)
k.Randomize ();
// (b) Compute r = (g^k mod p) mod q
BigInteger r = (g.ModPow (k, p)) % q;
// (c) Compute k -1 mod q (e.g., using Algorithm 2.142).
// (d) Compute s = k -1 fh(m) +arg mod q.
BigInteger s = (k.ModInverse (q) * (m + x * r)) % q;
// (e) A's signature for m is the pair (r; s).
byte[] signature = new byte [40];
byte[] part1 = r.GetBytes ();
byte[] part2 = s.GetBytes ();
// note: sometime (1/256) we may get less than 20 bytes (if first is 00)
int start = 20 - part1.Length;
Array.Copy (part1, 0, signature, start, part1.Length);
start = 40 - part2.Length;
Array.Copy (part2, 0, signature, start, part2.Length);
return signature;
}
19
View Source File : SymmetricTransform.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public virtual int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
if (m_disposed)
throw new ObjectDisposedException ("Object is disposed");
CheckInput (inputBuffer, inputOffset, inputCount);
// check output parameters
if (outputBuffer == null)
throw new ArgumentNullException ("outputBuffer");
if (outputOffset < 0)
throw new ArgumentOutOfRangeException ("outputOffset", "< 0");
// ordered to avoid possible integer overflow
int len = outputBuffer.Length - inputCount - outputOffset;
if (!encrypt && (0 > len) && ((algo.Padding == PaddingMode.None) || (algo.Padding == PaddingMode.Zeros))) {
throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
} else if (KeepLastBlock) {
if (0 > len + BlockSizeByte) {
#if NET_2_0
throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
#else
throw new IndexOutOfRangeException (Locale.GetText ("Overflow"));
#endif
}
} else {
if (0 > len) {
// there's a special case if this is the end of the decryption process
if (inputBuffer.Length - inputOffset - outputBuffer.Length == BlockSizeByte)
inputCount = outputBuffer.Length - outputOffset;
else
throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
}
}
return InternalTransformBlock (inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
}
19
View Source File : Decimal.mono.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
static void ThrowInvalidExp()
{
throw new FormatException(Locale.GetText("Invalid exponent"));
}
19
View Source File : Decimal.mono.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private static string stripStyles(string s, NumberStyles style, NumberFormatInfo nfi,
out int decPos, out bool isNegative, out bool expFlag, out int exp, bool throwex)
{
isNegative = false;
expFlag = false;
exp = 0;
decPos = -1;
bool hreplacedign = false;
bool hasOpeningParentheses = false;
bool hasDecimalPoint = false;
bool allowedLeadingWhiteSpace = ((style & NumberStyles.AllowLeadingWhite) != 0);
bool allowedTrailingWhiteSpace = ((style & NumberStyles.AllowTrailingWhite) != 0);
bool allowedLeadingSign = ((style & NumberStyles.AllowLeadingSign) != 0);
bool allowedTrailingSign = ((style & NumberStyles.AllowTrailingSign) != 0);
bool allowedParentheses = ((style & NumberStyles.AllowParentheses) != 0);
bool allowedThousands = ((style & NumberStyles.AllowThousands) != 0);
bool allowedDecimalPoint = ((style & NumberStyles.AllowDecimalPoint) != 0);
bool allowedExponent = ((style & NumberStyles.AllowExponent) != 0);
/* get rid of currency symbol */
bool hasCurrency = false;
if ((style & NumberStyles.AllowCurrencySymbol) != 0)
{
int index = s.IndexOf(nfi.CurrencySymbol);
if (index >= 0)
{
s = s.Remove(index, nfi.CurrencySymbol.Length);
hasCurrency = true;
}
}
string decimalSep = (hasCurrency) ? nfi.CurrencyDecimalSeparator : nfi.NumberDecimalSeparator;
string groupSep = (hasCurrency) ? nfi.CurrencyGroupSeparator : nfi.NumberGroupSeparator;
int pos = 0;
int len = s.Length;
StringBuilder sb = new StringBuilder(len);
// leading
while (pos < len)
{
char ch = s[pos];
if (Char.IsDigit(ch))
{
break; // end of leading
}
else if (allowedLeadingWhiteSpace && Char.IsWhiteSpace(ch))
{
pos++;
}
else if (allowedParentheses && ch == '(' && !hreplacedign && !hasOpeningParentheses)
{
hasOpeningParentheses = true;
hreplacedign = true;
isNegative = true;
pos++;
}
else if (allowedLeadingSign && ch == nfi.NegativeSign[0] && !hreplacedign)
{
int slen = nfi.NegativeSign.Length;
if (slen == 1 || s.IndexOf(nfi.NegativeSign, pos, slen) == pos)
{
hreplacedign = true;
isNegative = true;
pos += slen;
}
}
else if (allowedLeadingSign && ch == nfi.PositiveSign[0] && !hreplacedign)
{
int slen = nfi.PositiveSign.Length;
if (slen == 1 || s.IndexOf(nfi.PositiveSign, pos, slen) == pos)
{
hreplacedign = true;
pos += slen;
}
}
else if (allowedDecimalPoint && ch == decimalSep[0])
{
int slen = decimalSep.Length;
if (slen != 1 && s.IndexOf(decimalSep, pos, slen) != pos)
{
if (throwex)
ThrowAtPos(pos);
else
return null;
}
break;
}
else
{
if (throwex)
ThrowAtPos(pos);
else
return null;
}
}
if (pos == len)
{
if (throwex)
throw new FormatException(Locale.GetText("No digits found"));
else
return null;
}
// digits
while (pos < len)
{
char ch = s[pos];
if (Char.IsDigit(ch))
{
sb.Append(ch);
pos++;
}
else if (allowedThousands && ch == groupSep[0])
{
int slen = groupSep.Length;
if (slen != 1 && s.IndexOf(groupSep, pos, slen) != pos)
{
if (throwex)
ThrowAtPos(pos);
else
return null;
}
pos += slen;
}
else if (allowedDecimalPoint && ch == decimalSep[0] && !hasDecimalPoint)
{
int slen = decimalSep.Length;
if (slen == 1 || s.IndexOf(decimalSep, pos, slen) == pos)
{
decPos = sb.Length;
hasDecimalPoint = true;
pos += slen;
}
}
else
{
break;
}
}
// exponent
if (pos < len)
{
char ch = s[pos];
if (allowedExponent && Char.ToUpperInvariant(ch) == 'E')
{
expFlag = true;
pos++;
if (pos >= len)
{
if (throwex)
ThrowInvalidExp();
else
return null;
}
ch = s[pos];
bool isNegativeExp = false;
if (ch == nfi.PositiveSign[0])
{
int slen = nfi.PositiveSign.Length;
if (slen == 1 || s.IndexOf(nfi.PositiveSign, pos, slen) == pos)
{
pos += slen;
if (pos >= len)
{
if (throwex)
ThrowInvalidExp();
else
return null;
}
}
}
else if (ch == nfi.NegativeSign[0])
{
int slen = nfi.NegativeSign.Length;
if (slen == 1 || s.IndexOf(nfi.NegativeSign, pos, slen) == pos)
{
pos += slen;
if (pos >= len)
{
if (throwex)
ThrowInvalidExp();
else
return null;
}
isNegativeExp = true;
}
}
ch = s[pos];
if (!Char.IsDigit(ch))
{
if (throwex)
ThrowInvalidExp();
else
return null;
}
exp = ch - '0';
pos++;
while (pos < len && Char.IsDigit(s[pos]))
{
exp *= 10;
exp += s[pos] - '0';
pos++;
}
if (isNegativeExp) exp *= -1;
}
}
// trailing
while (pos < len)
{
char ch = s[pos];
if (allowedTrailingWhiteSpace && Char.IsWhiteSpace(ch))
{
pos++;
}
else if (allowedParentheses && ch == ')' && hasOpeningParentheses)
{
hasOpeningParentheses = false;
pos++;
}
else if (allowedTrailingSign && ch == nfi.NegativeSign[0] && !hreplacedign)
{
int slen = nfi.NegativeSign.Length;
if (slen == 1 || s.IndexOf(nfi.NegativeSign, pos, slen) == pos)
{
hreplacedign = true;
isNegative = true;
pos += slen;
}
}
else if (allowedTrailingSign && ch == nfi.PositiveSign[0] && !hreplacedign)
{
int slen = nfi.PositiveSign.Length;
if (slen == 1 || s.IndexOf(nfi.PositiveSign, pos, slen) == pos)
{
hreplacedign = true;
pos += slen;
}
}
else
{
if (throwex)
ThrowAtPos(pos);
else
return null;
}
}
if (hasOpeningParentheses)
{
if (throwex)
throw new FormatException(Locale.GetText("Closing Parentheses not found"));
else
return null;
}
if (!hasDecimalPoint)
decPos = sb.Length;
return sb.ToString();
}
19
View Source File : Exception.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override string ToString()
{
StringBuilder result = new StringBuilder(GetType().FullName);
result.Append(": ").Append(Message);
if (inner_exception != null)
{
result.Append(" ---> ").Append(inner_exception.ToString());
result.Append(Locale.GetText("--- End of inner exception stack trace ---"));
result.AppendLine();
}
if (StackTrace != null)
result.AppendLine().Append(StackTrace);
return result.ToString();
}
19
View Source File : FloatingPointFormatter.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private string FormatCurrency (Format formatData, double value,
NumberFormatInfo nfi, int precision) {
precision = (precision >= 0) ? precision : nfi.CurrencyDecimalDigits;
string numb = FormatNumberInternal (formatData, value, nfi, precision);
if (value < 0) {
switch (nfi.CurrencyNegativePattern) {
case 0:
return "(" + nfi.CurrencySymbol + numb + ")";
case 1:
return nfi.NegativeSign + nfi.CurrencySymbol + numb;
case 2:
return nfi.CurrencySymbol + nfi.NegativeSign + numb;
case 3:
return nfi.CurrencySymbol + numb + nfi.NegativeSign;
case 4:
return "(" + numb + nfi.CurrencySymbol + ")";
case 5:
return nfi.NegativeSign + numb + nfi.CurrencySymbol;
case 6:
return numb + nfi.NegativeSign + nfi.CurrencySymbol;
case 7:
return numb + nfi.CurrencySymbol + nfi.NegativeSign;
case 8:
return nfi.NegativeSign + numb + " " + nfi.CurrencySymbol;
case 9:
return nfi.NegativeSign + nfi.CurrencySymbol + " " + numb;
case 10:
return numb + " " + nfi.CurrencySymbol + nfi.NegativeSign;
case 11:
return nfi.CurrencySymbol + " " + numb + nfi.NegativeSign;
case 12:
return nfi.CurrencySymbol + " " + nfi.NegativeSign + numb;
case 13:
return numb + nfi.NegativeSign + " " + nfi.CurrencySymbol;
case 14:
return "(" + nfi.CurrencySymbol + " " + numb + ")";
case 15:
return "(" + numb + " " + nfi.CurrencySymbol + ")";
default:
throw new ArgumentException(Locale.GetText(
"Invalid CurrencyNegativePattern"));
}
}
else {
switch (nfi.CurrencyPositivePattern) {
case 0:
return nfi.CurrencySymbol + numb ;
case 1:
return numb + nfi.CurrencySymbol;
case 2:
return nfi.CurrencySymbol + " " + numb;
case 3:
return numb + " " + nfi.CurrencySymbol;
default:
throw new ArgumentException(Locale.GetText(
"invalid CurrencyPositivePattern"));
}
}
}
19
View Source File : FloatingPointFormatter.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private string FormatNumber (Format formatData, double value, NumberFormatInfo nfi, int precision) {
precision = (precision >= 0) ? precision : nfi.NumberDecimalDigits;
string numb = FormatNumberInternal (formatData, value, nfi, precision);
if (value < 0) {
switch (nfi.NumberNegativePattern) {
case 0:
return "(" + numb + ")";
case 1:
return nfi.NegativeSign + numb;
case 2:
return nfi.NegativeSign + " " + numb;
case 3:
return numb + nfi.NegativeSign;
case 4:
return numb + " " + nfi.NegativeSign;
default:
throw new ArgumentException(Locale.GetText(
"Invalid NumberNegativePattern"));
}
}
return numb;
}
19
View Source File : FloatingPointFormatter.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private string FormatPercent (Format formatData, double value, NumberFormatInfo nfi,
int precision) {
precision = (precision >= 0) ? precision : nfi.PercentDecimalDigits;
string numb = FormatNumberInternal (formatData, value*100, nfi, precision);
if (value < 0) {
switch (nfi.PercentNegativePattern) {
case 0:
return nfi.NegativeSign + numb + " " + nfi.PercentSymbol;
case 1:
return nfi.NegativeSign + numb + nfi.PercentSymbol;
case 2:
return nfi.NegativeSign + nfi.PercentSymbol + numb;
default:
throw new ArgumentException(Locale.GetText(
"Invalid PercentNegativePattern"));
}
}
else {
switch (nfi.PercentPositivePattern) {
case 0:
return numb + " " + nfi.PercentSymbol;
case 1:
return numb + nfi.PercentSymbol;
case 2:
return nfi.PercentSymbol + numb;
default:
throw new ArgumentException(Locale.GetText(
"invalid PercehtPositivePattern"));
}
}
}
19
View Source File : MulticastDelegate.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
protected override sealed Delegate CombineImpl(Delegate follow)
{
MulticastDelegate combined, orig, clone;
if (GetType() != follow.GetType())
throw new ArgumentException(Locale.GetText("Incompatible Delegate Types."));
combined = (MulticastDelegate)follow.Clone();
//combined.SetMulticastInvoke();
for (clone = combined, orig = ((MulticastDelegate)follow).m_prev; orig != null; orig = orig.m_prev)
{
clone.m_prev = (MulticastDelegate)orig.Clone();
clone = clone.m_prev;
}
clone.m_prev = (MulticastDelegate)Clone();
for (clone = clone.m_prev, orig = m_prev; orig != null; orig = orig.m_prev)
{
clone.m_prev = (MulticastDelegate)orig.Clone();
clone = clone.m_prev;
}
return combined;
}
19
View Source File : TimeZone.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
internal
#endif
override DaylightTime GetDaylightChanges(int year)
{
if (year < 1 || year > 9999)
throw new ArgumentOutOfRangeException("year", year +
Locale.GetText(" is not in a range between 1 and 9999."));
DaylightTime dlt = new DaylightTime(DateTime.MinValue, DateTime.MinValue, TimeSpan.Zero);
return dlt;
}
19
View Source File : TypedReference.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override bool Equals (object o)
{
throw new NotSupportedException (Locale.GetText ("This operation is not supported for this type."));
}
19
View Source File : TypedReference.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[MonoTODO]
[CLSCompliant (false)]
public static TypedReference MakeTypedReference (object target, FieldInfo[] flds)
{
if (target == null) {
throw new ArgumentNullException ("target");
}
if (flds == null) {
throw new ArgumentNullException ("flds");
}
if (flds.Length == 0) {
throw new ArgumentException (Locale.GetText ("flds has no elements"));
}
throw new NotImplementedException ();
}
19
View Source File : UInt16.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int CompareTo(object value)
{
if (value == null)
return 1;
if (!(value is UInt16))
throw new ArgumentException(Locale.GetText("Value is not a System.UInt16."));
return m_value - ((ushort)value);
}
19
View Source File : UInt16.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[CLSCompliant(false)]
public static ushort Parse(string s, NumberStyles style, IFormatProvider provider)
{
uint tmpResult = UInt32.Parse(s, style, provider);
if (tmpResult > MaxValue)
throw new OverflowException(Locale.GetText("Value too large."));
return (ushort)tmpResult;
}
19
View Source File : UInt32.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int CompareTo(object value)
{
if (value == null)
return 1;
if (!(value is UInt32))
throw new ArgumentException(Locale.GetText("Value is not a System.UInt32."));
uint v = (uint)value;
if (m_value == v)
return 0;
if (m_value < v)
return -1;
return 1;
}
19
View Source File : UInt32.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
internal static bool Parse(string s, bool tryParse, out uint result, out Exception exc)
{
uint val = 0;
int len;
int i;
bool digits_seen = false;
bool has_negative_sign = false;
result = 0;
exc = null;
if (s == null)
{
if (!tryParse)
exc = new ArgumentNullException("s");
return false;
}
len = s.Length;
char c;
for (i = 0; i < len; i++)
{
c = s[i];
if (!Char.IsWhiteSpace(c))
break;
}
if (i == len)
{
if (!tryParse)
exc = IntParser.GetFormatException();
return false;
}
if (s[i] == '+')
i++;
else
if (s[i] == '-')
{
i++;
has_negative_sign = true;
}
for (; i < len; i++)
{
c = s[i];
if (c >= '0' && c <= '9')
{
uint d = (uint)(c - '0');
ulong v = ((ulong)val) * 10 + d;
if (v > MaxValue)
{
if (!tryParse)
exc = IntParser.GetOverflowException();
return false;
}
val = (uint)v;
digits_seen = true;
}
else
{
if (Char.IsWhiteSpace(c))
{
for (i++; i < len; i++)
{
if (!Char.IsWhiteSpace(s[i]))
{
if (!tryParse)
exc = IntParser.GetFormatException();
return false;
}
}
break;
}
else
{
if (!tryParse)
exc = IntParser.GetFormatException();
return false;
}
}
}
if (!digits_seen)
{
if (!tryParse)
exc = IntParser.GetFormatException();
return false;
}
// -0 is legal but other negative values are not
if (has_negative_sign && (val > 0))
{
if (!tryParse)
exc = new OverflowException(
Locale.GetText("Negative number"));
return false;
}
result = val;
return true;
}
19
View Source File : Comparer.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int Compare (object a, object b)
{
if (a == b)
return 0;
else if (a == null)
return -1;
else if (b == null)
return 1;
if (m_compareInfo != null) {
string sa = a as string;
string sb = b as string;
if (sa != null && sb != null)
return m_compareInfo.Compare (sa, sb);
}
if (a is IComparable)
return (a as IComparable).CompareTo (b);
else if (b is IComparable)
return -(b as IComparable).CompareTo (a);
throw new ArgumentException (Locale.GetText ("Neither 'a' nor 'b' implements IComparable."));
}
19
View Source File : SortedList.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static SortedList Synchronized (SortedList list)
{
if (list == null)
throw new ArgumentNullException (Locale.GetText ("Base list is null."));
return new SynchedSortedList (list);
}
19
View Source File : SortedList.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PutImpl (object key, object value, bool overwrite)
{
if (key == null)
throw new ArgumentNullException ("null key");
Slot [] table = this.table;
int freeIndx = -1;
try {
freeIndx = Find (key);
} catch (Exception) {
throw new InvalidOperationException();
}
if (freeIndx >= 0) {
if (!overwrite) {
string msg = Locale.GetText ("Key '{0}' already exists in list.", key);
throw new ArgumentException (msg);
}
table [freeIndx].value = value;
++modificationCount;
return;
}
freeIndx = ~freeIndx;
if (freeIndx > Capacity + 1)
throw new Exception ("SortedList::internal error ("+key+", "+value+") at ["+freeIndx+"]");
EnsureCapacity (Count+1, freeIndx);
table = this.table;
table [freeIndx].key = key;
table [freeIndx].value = value;
++inUse;
++modificationCount;
}
19
View Source File : StackFrame.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
if (methodBase == null) {
sb.Append (Locale.GetText ("<unknown method>"));
} else {
sb.Append (methodBase.Name);
}
sb.Append (Locale.GetText (" at "));
if (ilOffset == OFFSET_UNKNOWN) {
sb.Append (Locale.GetText ("<unknown offset>"));
} else {
sb.Append (Locale.GetText ("offset "));
sb.Append (ilOffset);
}
sb.Append (Locale.GetText (" in file:line:column "));
if (fileName == null) {
sb.Append (Locale.GetText ("<filename unknown>"));
} else {
try {
sb.Append (GetFileName ());
}
catch (SecurityException) {
sb.Append (Locale.GetText ("<filename unknown>"));
}
}
sb.AppendFormat (":{0}:{1}", lineNumber, columnNumber);
return sb.ToString ();
}
19
View Source File : StackTrace.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override string ToString ()
{
string newline = String.Format ("{0} {1} ", Environment.NewLine, Locale.GetText ("at"));
string unknown = Locale.GetText ("<unknown method>");
string debuginfo = Locale.GetText (" in {0}:line {1}");
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < FrameCount; i++) {
StackFrame frame = GetFrame (i);
if (i > 0)
sb.Append (newline);
else
sb.AppendFormat (" {0} ", Locale.GetText ("at"));
MethodBase method = frame.GetMethod ();
if (method != null) {
// Method information available
sb.AppendFormat ("{0}.{1}", method.DeclaringType.FullName, method.Name);
/* Append parameter information */
sb.Append ("(");
ParameterInfo[] p = method.GetParameters ();
for (int j = 0; j < p.Length; ++j) {
if (j > 0)
sb.Append (", ");
Type pt = p[j].ParameterType;
bool byref = pt.IsByRef;
if (byref)
pt = pt.GetElementType ();
if (pt.IsClreplaced && pt.Namespace != String.Empty) {
sb.Append (pt.Namespace);
sb.Append (".");
}
sb.Append (pt.Name);
if (byref)
sb.Append (" ByRef");
sb.AppendFormat (" {0}", p [j].Name);
}
sb.Append (")");
}
else {
// Method information not available
sb.Append (unknown);
}
if (debug_info) {
// we were asked for debugging informations
try {
// but that doesn't mean we have the debug information available
string fname = frame.GetFileName ();
if ((fname != null) && (fname.Length > 0))
sb.AppendFormat (debuginfo, fname, frame.GetFileLineNumber ());
}
catch (SecurityException) {
// don't leak information (about the filename) if the security
// manager doesn't allow it (but don't loop on this exception)
debug_info = false;
}
}
}
return sb.ToString ();
}
19
View Source File : X501Name.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
static private X520.AttributeTypeAndValue ReadAttribute (string value, ref int pos)
{
while ((value[pos] == ' ') && (pos < value.Length))
pos++;
// get '=' position in substring
int equal = value.IndexOf ('=', pos);
if (equal == -1) {
string msg = Locale.GetText ("No attribute found.");
throw new FormatException (msg);
}
string s = value.Substring (pos, equal - pos);
X520.AttributeTypeAndValue atv = GetAttributeFromOid (s);
if (atv == null) {
string msg = Locale.GetText ("Unknown attribute '{0}'.");
throw new FormatException (String.Format (msg, s));
}
pos = equal + 1; // skip the '='
return atv;
}
19
View Source File : X501Name.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
static private int ReadEscaped (StringBuilder sb, string value, int pos)
{
switch (value[pos]) {
case '\\':
case '"':
case '=':
case ';':
case '<':
case '>':
case '+':
case '#':
case ',':
sb.Append (value[pos]);
return pos;
default:
if (pos >= value.Length - 2) {
string msg = Locale.GetText ("Malformed escaped value '{0}'.");
throw new FormatException (string.Format (msg, value.Substring (pos)));
}
// it's either a 8 bits or 16 bits char
sb.Append (ReadHex (value, ref pos));
return pos;
}
}
19
View Source File : X501Name.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
static private int ReadQuoted (StringBuilder sb, string value, int pos)
{
int original = pos;
while (pos <= value.Length) {
switch (value[pos]) {
case '"':
return pos;
case '\\':
return ReadEscaped (sb, value, pos);
default:
sb.Append (value[pos]);
pos++;
break;
}
}
string msg = Locale.GetText ("Malformed quoted value '{0}'.");
throw new FormatException (string.Format (msg, value.Substring (original)));
}
19
View Source File : X501Name.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
static private string ReadValue (string value, ref int pos)
{
int original = pos;
StringBuilder sb = new StringBuilder ();
while (pos < value.Length) {
switch (value [pos]) {
case '\\':
pos = ReadEscaped (sb, value, ++pos);
break;
case '"':
pos = ReadQuoted (sb, value, ++pos);
break;
case '=':
case ';':
case '<':
case '>':
string msg = Locale.GetText ("Malformed value '{0}' contains '{1}' outside quotes.");
throw new FormatException (string.Format (msg, value.Substring (original), value[pos]));
case '+':
case '#':
throw new NotImplementedException ();
case ',':
pos++;
return sb.ToString ();
default:
sb.Append (value[pos]);
break;
}
pos++;
}
return sb.ToString ();
}
19
View Source File : Activator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
internal static object CreateInstance(Type type, bool nonPublic)
{
CheckType(type);
#if NET_2_0
if (type.ContainsGenericParameters)
throw new ArgumentException (type + " is an open generic type", "type");
#endif
CheckAbstractType(type);
#if AVM
return type.CreateInstance();
#else
BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
if (nonPublic)
flags |= BindingFlags.NonPublic;
ConstructorInfo ctor = type.GetConstructor (flags, null, CallingConventions.Any, Type.EmptyTypes, null);
if (ctor == null) {
if (type.IsValueType)
return CreateInstanceInternal (type);
throw new MissingMethodException (Locale.GetText ("Default constructor not found."),
".ctor() of " + type.FullName);
}
return ctor.Invoke (null);
#endif
}
19
View Source File : Activator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private static void CheckType(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
if (
#if NOT_PFX
(type == typeof(TypedReference)) ||
(type == typeof (ArgIterator)) ||
#endif
(type == typeof(void))
|| (type == typeof(RuntimeArgumentHandle)))
{
string msg = Locale.GetText("CreateInstance cannot be used to create this type ({0}).", type.FullName);
throw new NotSupportedException(msg);
}
}
19
View Source File : Activator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private static void CheckAbstractType(Type type)
{
if (type.IsAbstract)
{
string msg = Locale.GetText("Cannot create an abstract clreplaced '{0}'.", type.FullName);
//#if NET_2_0
// throw new MissingMethodException (msg);
//#else
throw new MemberAccessException(msg);
//#endif
}
}
19
View Source File : ArgIterator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public override bool Equals (object o)
{
throw new NotSupportedException (Locale.GetText ("ArgIterator does not support Equals."));
}
19
View Source File : ArgIterator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[CLSCompliant (false)]
public TypedReference GetNextArg ()
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg ();
}
19
View Source File : ArgIterator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[CLSCompliant (false)]
public TypedReference GetNextArg (RuntimeTypeHandle rth)
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg (rth.Value);
}
19
View Source File : ArgIterator.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public RuntimeTypeHandle GetNextArgType ()
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return new RuntimeTypeHandle (IntGetNextArgType ());
}
19
View Source File : Attribute.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private static void CheckParameters (object element, Type attributeType)
{
// neither parameter is allowed to be null
if (element == null)
throw new ArgumentNullException ("element");
if (attributeType == null)
throw new ArgumentNullException ("attributeType");
if (!typeof (Attribute).IsreplacedignableFrom (attributeType))
throw new ArgumentException (Locale.GetText (
"Type is not derived from System.Attribute."), "attributeType");
}
19
View Source File : Attribute.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private static Attribute FindAttribute (object[] attributes)
{
// if there exists more than one attribute of the given type, throw an exception
if (attributes.Length > 1) {
throw new AmbiguousMatchException (Locale.GetText (
"<element> has more than one attribute of type <attribute_type>"));
}
if (attributes.Length < 1)
return null;
// tested above for '> 1' and and '< 1', so only '== 1' is left,
// i.e. we found the attribute
return (Attribute) attributes[0];
}
19
View Source File : Attribute.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static bool IsDefined (MemberInfo element, Type attributeType, bool inherit)
{
CheckParameters (element, attributeType);
MemberTypes mtype = element.MemberType;
if (mtype != MemberTypes.Constructor && mtype != MemberTypes.Event &&
mtype != MemberTypes.Field && mtype != MemberTypes.Method &&
mtype != MemberTypes.Property && mtype != MemberTypes.TypeInfo &&
mtype != MemberTypes.NestedType)
throw new NotSupportedException (Locale.GetText (
"Element is not a constructor, method, property, event, type or field."));
return ((MemberInfo) element).IsDefined (attributeType, inherit);
}
19
View Source File : Boolean.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int CompareTo(object obj)
{
if (obj == null)
return 1;
if (!(obj is System.Boolean))
throw new ArgumentException(Locale.GetText("Object is not a Boolean."));
if (m_value == (bool)obj)
return 0;
return m_value ? 1 : -1;
}
19
View Source File : Boolean.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static bool Parse(string value)
{
if (value == null)
throw new ArgumentNullException("value");
value = value.Trim();
if (String.Compare(value, TrueString, true, CultureInfo.InvariantCulture) == 0)
return true;
if (String.Compare(value, FalseString, true, CultureInfo.InvariantCulture) == 0)
return false;
throw new FormatException(Locale.GetText("Value is not equivalent to either TrueString or FalseString."));
}
19
View Source File : Buffer.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static int ByteLength(Array array)
{
// note: the other methods in this clreplaced also use ByteLength to test for
// null and non-primitive arguments as a side-effect.
if (array == null)
throw new ArgumentNullException("array");
int length = ByteLengthInternal(array);
if (length < 0)
throw new ArgumentException(Locale.GetText("Object must be an array of primitives."));
return length;
}
19
View Source File : Buffer.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static byte GetByte(Array array, int index)
{
if (index < 0 || index >= ByteLength(array))
throw new ArgumentOutOfRangeException("index", Locale.GetText(
"Value must be non-negative and less than the size of the collection."));
return GetByteInternal(array, index);
}
19
View Source File : Buffer.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static void SetByte(Array array, int index, byte value)
{
if (index < 0 || index >= ByteLength(array))
throw new ArgumentOutOfRangeException("index", Locale.GetText(
"Value must be non-negative and less than the size of the collection."));
SetByteInternal(array, index, value);
}
19
View Source File : Buffer.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static void BlockCopy(Array src, int srcOffset, Array dest, int destOffset, int count)
{
if (src == null)
throw new ArgumentNullException("src");
if (dest == null)
throw new ArgumentNullException("dest");
if (srcOffset < 0)
throw new ArgumentOutOfRangeException("srcOffset", Locale.GetText(
"Non-negative number required."));
if (destOffset < 0)
throw new ArgumentOutOfRangeException("destOffset", Locale.GetText(
"Non-negative number required."));
if (count < 0)
throw new ArgumentOutOfRangeException("count", Locale.GetText(
"Non-negative number required."));
// We do the checks in unmanaged code for performance reasons
bool res = BlockCopyInternal(src, srcOffset, dest, destOffset, count);
if (!res)
{
// watch for integer overflow
if ((srcOffset > ByteLength(src) - count) || (destOffset > ByteLength(dest) - count))
throw new ArgumentException(Locale.GetText(
"Offset and length were out of bounds for the array or count is greater than" +
"the number of elements from index to the end of the source collection."));
}
}
19
View Source File : Byte.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int CompareTo(object value)
{
if (value == null)
return 1;
if (!(value is Byte))
throw new ArgumentException(Locale.GetText("Value is not a System.Byte."));
byte xv = (byte)value;
if (m_value == xv)
return 0;
if (m_value > xv)
return 1;
return -1;
}
19
View Source File : Byte.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static byte Parse(string s, NumberStyles style, IFormatProvider provider)
{
uint tmpResult = UInt32.Parse(s, style, provider);
if (tmpResult > Byte.MaxValue)
throw new OverflowException(Locale.GetText("Value too large."));
return (byte)tmpResult;
}
19
View Source File : Char.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public int CompareTo(object v)
{
if (v == null)
return 1;
if (!(v is Char))
throw new ArgumentException(Locale.GetText("Value is not a System.Char"));
char xv = (char)v;
if (m_value == xv)
return 0;
if (m_value > xv)
return 1;
else
return -1;
}
19
View Source File : Char.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static double GetNumericValue(string str, int index)
{
if (str == null)
throw new ArgumentNullException("str");
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException(Locale.GetText(
"The value of index is less than zero, or greater than or equal to the length of str."));
return GetNumericValue(str[index]);
}
19
View Source File : Char.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static UnicodeCategory GetUnicodeCategory(string str, int index)
{
if (str == null)
throw new ArgumentNullException("str");
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException(Locale.GetText(
"The value of index is less than zero, or greater than or equal to the length of str."));
return GetUnicodeCategory(str[index]);
}
19
View Source File : Char.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static bool IsControl(string str, int index)
{
if (str == null)
throw new ArgumentNullException("str");
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException(Locale.GetText(
"The value of index is less than zero, or greater than or equal to the length of str."));
return IsControl(str[index]);
}
19
View Source File : Char.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
public static bool IsDigit(string str, int index)
{
if (str == null)
throw new ArgumentNullException("str");
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException(Locale.GetText(
"The value of index is less than zero, or greater than or equal to the length of str."));
return IsDigit(str[index]);
}
See More Examples