public override void OnRawMessage(string data, Socket handler) { base.OnRawMessage(data, handler); var message = new FileAssociationSingleInstance.SingleInstanceSocket.ParsedMessage(data).message; var str = "OK"; if (!string.IsNullOrEmpty(message)) { var length = 1; for (var startIndex = 0; message.IndexOf('\t', startIndex) > 0; startIndex = message.IndexOf('\t', startIndex) + 1) { ++length; } string[] strArray = new string[length]; if (length == 1) { strArray[0] = message; } else { var startIndex = 0; for (var index = 0; index < length; ++index) { var num = message.IndexOf('\t', startIndex); if (num < 0) { num = message.Length - 1; } strArray[index] = message.Substring(startIndex, num - startIndex); startIndex = num + 1; } } try { callback?.Invoke(strArray); } catch (Exception ex) { str = "FAIL"; } } try { byte[] bytes = Encoding.UTF8.GetBytes(str + "<EOF>"); handler.Send(bytes); } catch (Exception ex) { str = "FAIL"; } if (!(str == "FAIL")) { return; } FileAssociationSingleInstance.UnRegisterAsSingleInstance(); }
private static void NewInstanceEventCallback(string[] arg) { if (arg == null || arg.Length != 1 || FileAssociationSingleInstance.OnNewInstance == null) { return; } FileAssociationSingleInstance.OnNewInstance(arg); }