// If necessary, in future versions we could implement support for // multiple hooks attached to the same interrupt and execute them based on some priority condition public bool TryAttachHook(byte intNum, IntHandler handler) { if (intHooks.ContainsKey(intNum)) { intHooks.Remove(intNum); } intHooks.Add(intNum, handler); return(true); }
public void SetCallbacks(GMHandler addMissileScore, GMHandler addEnemyPos, ButtonHandler UseItem, GetPostionHandler GetRandomEnemyPos, IntHandler RefreshCreditPVC, IntHandler GetBestScore, GMHandler BossDie) { onAddMissileScore = addMissileScore; onAddEnemyPos = addEnemyPos; onUseItem = UseItem; onGetRandomEnemyPos = GetRandomEnemyPos; onRefreshCredit = RefreshCreditPVC; onGetBestScore = GetBestScore; onBossDie = BossDie; }
public int CompareTo(object second) { int result = LongHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).commitTimestamp , ((CommitTimestampSupport.TimestampEntry)second).commitTimestamp); if (result != 0) { return(result); } return(IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId , ((CommitTimestampSupport.TimestampEntry)second).objectId)); }
private static void InitBeans() { HandlerFactory handlerFactory = new HandlerFactory(); StringHandler stringHandler = new StringHandler(); IntHandler intHandler = new IntHandler(); ByteSteamHandler byteSteamHandler = new ByteSteamHandler(); OrderedDictHandler dictHandler = new OrderedDictHandler(handlerFactory); handlerFactory.AddHandler(stringHandler); handlerFactory.AddHandler(dictHandler); handlerFactory.AddHandler(intHandler); handlerFactory.AddHandler(byteSteamHandler); CloudSyncKey cloudSyncKey = new CloudSyncKey(KeyFilePath); IExceptionHandler exceptionHandler = new ConsoleExceptionHandler(); _facade = new CloudSyncFileProcessorFacade(handlerFactory, cloudSyncKey, exceptionHandler); }
public void Handler() { var f = delegate() { LuaConsole.Print(1, 2, 3); }; Test(123); IntHandler t = Test; t(1); IntHandler t2 = this.Test; t2(2); IntHandler aa; aa = Test; TestDelegate(Test); }
private void RegisterBuiltinHandlers() { IntHandler intHandler = new IntHandler(); RegisterBuiltinHandler(Handlers4.IntId, intHandler); RegisterHandlerVersion(intHandler, 0, new IntHandler0()); LongHandler longHandler = new LongHandler(); RegisterBuiltinHandler(Handlers4.LongId, longHandler); RegisterHandlerVersion(longHandler, 0, new LongHandler0()); FloatHandler floatHandler = new FloatHandler(); RegisterBuiltinHandler(Handlers4.FloatId, floatHandler); RegisterHandlerVersion(floatHandler, 0, new FloatHandler0()); BooleanHandler booleanHandler = new BooleanHandler(); RegisterBuiltinHandler(Handlers4.BooleanId, booleanHandler); // TODO: Are we missing a boolean handler version? DoubleHandler doubleHandler = new DoubleHandler(); RegisterBuiltinHandler(Handlers4.DoubleId, doubleHandler); RegisterHandlerVersion(doubleHandler, 0, new DoubleHandler0()); ByteHandler byteHandler = new ByteHandler(); RegisterBuiltinHandler(Handlers4.ByteId, byteHandler); // TODO: Are we missing a byte handler version? CharHandler charHandler = new CharHandler(); RegisterBuiltinHandler(Handlers4.CharId, charHandler); // TODO: Are we missing a char handler version? ShortHandler shortHandler = new ShortHandler(); RegisterBuiltinHandler(Handlers4.ShortId, shortHandler); RegisterHandlerVersion(shortHandler, 0, new ShortHandler0()); _stringHandler = new StringHandler(); RegisterBuiltinHandler(Handlers4.StringId, _stringHandler); RegisterHandlerVersion(_stringHandler, 0, new StringHandler0()); DateHandler dateHandler = new DateHandler(); RegisterBuiltinHandler(Handlers4.DateId, dateHandler); RegisterHandlerVersion(dateHandler, 0, new DateHandler0()); RegisterUntypedHandlers(); RegisterCompositeHandlerVersions(); }
public void TestDelegate(IntHandler handler) { }
public MappedIDPairHandler() { _origHandler = new IntHandler(); _mappedHandler = new IntHandler(); }
public static INumberHandler Get(Type type) { INumberHandler result; if (!handlers.TryGetValue(type, out result)) { if (type == typeof(int)) { result = new IntHandler(); } else if (type == typeof(float)) { result = new FloatHandler(); } else if (type == typeof(long)) { result = new LongHandler(); } else if (type == typeof(double)) { result = new DoubleHandler(); } else if (type == typeof(byte)) { result = new ByteHandler(); } else if (type == typeof(char)) { result = new CharHandler(); } else if (type == typeof(short)) { result = new ShortHandler(); } else if (type == typeof(uint)) { result = new UIntHandler(); } else if (type == typeof(ulong)) { result = new ULongHandler(); } else if (type == typeof(sbyte)) { result = new SByteHandler(); } else if (type == typeof(ushort)) { result = new UShortHandler(); } else if (type == typeof(decimal)) { result = new DecimalHandler(); } else { result = null; } handlers[type] = result; } return(result); }
private void IntValidationHandler(object sender, TextCompositionEventArgs e) { e.Handled = !IntHandler.IsTextInt(e.Text); }
public int CompareTo(object second) { return(IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId , ((CommitTimestampSupport.TimestampEntry)second).objectId)); }
private void ParseFile() { var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var path = $"{directory}\\Resources\\crypto\\encrypted_jpg_01.jpg"; string magic = "__CLOUDSYNC_ENC__"; byte[] magicBytes = Encoding.ASCII.GetBytes(magic); using FileStream fs = new FileStream(path, FileMode.Open); using BinaryReader br = new BinaryReader(fs); byte[] value = br.ReadBytes(magicBytes.Length); Console.WriteLine(ByteArrayCompare(magicBytes, value)); //check "__CLOUDSYNC_ENC__" Md5 hash value = br.ReadBytes(32); byte[] expectedMagicHash = Encoding.ASCII.GetBytes(BytesUtils.ByteArrayToLowerHexString(Md5(magicBytes))); Assert.AreEqual(expectedMagicHash, value); // HandlerFactory handlerFactory = new HandlerFactory(); StringHandler stringHandler = new StringHandler(); IntHandler intHandler = new IntHandler(); ByteSteamHandler byteSteamHandler = new ByteSteamHandler(); OrderedDictHandler dictHandler = new OrderedDictHandler(handlerFactory); handlerFactory.AddHandler(stringHandler); handlerFactory.AddHandler(dictHandler); handlerFactory.AddHandler(intHandler); handlerFactory.AddHandler(byteSteamHandler); byte metaTag = br.ReadByte(); if (metaTag != 0x42) { throw new InvalidDataException(); } IFileStreamHandler <IDictionary <string, object> > metaHandler = handlerFactory.GetHandler <IDictionary <string, object> >(metaTag); IDictionary <string, object> metaDict = metaHandler.Handle(br); if (!(metaDict.ContainsKey("type") && "metadata".Equals(metaDict["type"]))) { throw new InvalidDataException(); } FileMeta3 fileMeta = FileMeta3.fromDictionary(metaDict); Console.WriteLine(fileMeta); AsymmetricKeyParameter akp = CryptoUtils.readPemPk(this.privateKey); byte[] sessionKeyCharArray = CryptoUtils.RsaOaepDeciper(fileMeta.EncKey2, akp); string computedSessionKeyHash = CryptoUtils.SaltedMd5( fileMeta.SessionKeyHash.Substring(0, 10), sessionKeyCharArray); if (!fileMeta.SessionKeyHash.Equals(computedSessionKeyHash)) { throw new InvalidDataException("key is incorrect"); } //decrypt content byte[] sessionKey = BytesUtils.HexStringToByteArray( Encoding.ASCII.GetString(sessionKeyCharArray)); Console.Write(sessionKey); ParametersWithIV keys = CryptoUtils.DeriveAESKeyParameters(sessionKey, null); AesCbcCryptor decryptor = new AesCbcCryptor(((KeyParameter)keys.Parameters).GetKey(), keys.GetIV()); List <byte[]> decryptedData = new List <byte[]>(); byte[] buf = null; byte[] decBuf = null; IDictionary <string, object> dataResult = null; while (true) { byte dataTag = br.ReadByte(); if (dataTag == 0x40) { Console.WriteLine("come here"); } if (dataTag != 0x42) { decBuf = decryptor.DecryptBlock(buf, true); decryptedData.Add(decBuf); break; } if (buf != null) { decBuf = decryptor.DecryptBlock(buf, false); decryptedData.Add(decBuf); } IFileStreamHandler <IDictionary <string, object> > dataHandler = handlerFactory.GetHandler <IDictionary <string, object> >(metaTag); dataResult = dataHandler.Handle(br); object typeValue = null; dataResult.TryGetValue("type", out typeValue); string typeValueString = typeValue as string; if (!"data".Equals(typeValueString)) { break; } buf = (byte[])dataResult["data"]; } byte[] decData = CryptoUtils.Concat(decryptedData.ToArray()); File.WriteAllBytes("z:\\123.jpg.lz4", decData); //last directory //TODO validate dataResult["type"] == "metadata" string fileMd5 = (string)dataResult["file_md5"]; Console.Write(fileMd5); }