fix merge conflict
This commit is contained in:
commit
399a5c8e34
@ -240,9 +240,21 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event EventHandler<CancelEventArgs> BeforeStartInternal;
|
||||||
|
protected virtual void OnBeforeStartInternal(CancelEventArgs e)
|
||||||
|
{
|
||||||
|
BeforeStartInternal?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
public int Start()
|
public int Start()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
|
CancelEventArgs e = new CancelEventArgs();
|
||||||
|
OnBeforeStartInternal(e);
|
||||||
|
if (e.Cancel)
|
||||||
|
return 2;
|
||||||
|
|
||||||
int exitCode = StartInternal();
|
int exitCode = StartInternal();
|
||||||
|
|
||||||
Instance = null;
|
Instance = null;
|
||||||
|
|||||||
@ -163,7 +163,10 @@ namespace MBS.Core
|
|||||||
|
|
||||||
public const string DefaultAlphabet = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
public const string DefaultAlphabet = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
public const string DefaultAlphabetNoSpecialChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
public const string DefaultAlphabetNoSpecialChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
public const string CapitalAlphabetNoSpecialChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
public const string CapitalAlphabetNoSpecialChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
|
public const string CapitalAlphanumeric = "_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
public const string CapitalAlphanumericNoSpecialChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
public const string CapitalAlphanumericNoSpecialChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
private static readonly CryptoRandom Random = new CryptoRandom();
|
private static readonly CryptoRandom Random = new CryptoRandom();
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
namespace MBS.Core.Reflection;
|
||||||
|
|
||||||
|
public static class TypeExtensions
|
||||||
|
{
|
||||||
|
public static bool IsSubclassOfGeneric(this Type toCheck, Type generic)
|
||||||
|
{
|
||||||
|
// thanks https://stackoverflow.com/a/457708
|
||||||
|
|
||||||
|
while (toCheck != null && toCheck != typeof(object))
|
||||||
|
{
|
||||||
|
var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck;
|
||||||
|
if (generic == cur)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Type[] intfs = toCheck.GetInterfaces();
|
||||||
|
foreach (Type intf in intfs)
|
||||||
|
{
|
||||||
|
// !!! HACK HACK HACK !!!
|
||||||
|
bool hack = intf.Namespace.Equals(generic.Namespace) && intf.Name.Equals(generic.Name);
|
||||||
|
if (hack)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toCheck = toCheck.BaseType;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -98,27 +98,33 @@ public static class StreamExtensions
|
|||||||
}
|
}
|
||||||
_streamPositions[st].Push(st.Position);
|
_streamPositions[st].Push(st.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const long BUFFER_SIZE=4096;
|
||||||
public static byte[] ReadToEnd(this Stream st)
|
public static byte[] ReadToEnd(this Stream st)
|
||||||
{
|
{
|
||||||
byte[] retval = new byte[0];
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
byte[] buffer = new byte[4096];
|
byte[] output = new byte[0];
|
||||||
|
int i = 0;
|
||||||
long j = 0;
|
bool done = false;
|
||||||
bool remaining = true;
|
while (!done)
|
||||||
while (remaining)
|
|
||||||
{
|
{
|
||||||
int count = st.Read(buffer, 0, buffer.Length);
|
int length = st.Read(buffer, 0, buffer.Length);
|
||||||
if (count < buffer.Length)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
Array.Resize<byte>(ref buffer, count);
|
done = true;
|
||||||
remaining = false;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length < BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
Array.Resize<byte>(ref buffer, length);
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array.Resize<byte>(ref retval, retval.Length + buffer.Length);
|
Array.Resize<byte>(ref output, output.Length + buffer.Length);
|
||||||
Array.Copy(buffer, 0, retval, j, buffer.Length);
|
Array.Copy(buffer, 0, output, i, buffer.Length);
|
||||||
j += buffer.Length;
|
i += buffer.Length;
|
||||||
}
|
}
|
||||||
return retval;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user