protected void RPC_LobbyMsg(BitStream stream, LobbyMessageInfo info) { ELobbyMsgType msgType = ELobbyMsgType.Max; try { msgType = stream.Read <ELobbyMsgType>(); if (CheckHandler(msgType)) { msgHandlers[msgType](stream, info); } else if (LogFilter.logError) { Debug.LogWarningFormat("Message:[{0}]|[{1}] does not implement", msgType, GetType()); } } catch (Exception e) { if (LogFilter.logError) { Debug.LogErrorFormat("Message:[{0}]\r\n{1}\r\n{2}\r\n{3}", GetType(), msgType, e.Message, e.StackTrace); } } }
internal static void HandleOrder() { var orderRows = OrderRowHandlers.CreateOrderList(); while (true) { MessageHandlers.DisplayOrderList(orderRows); MessageHandlers.AskForConfirmation(); var answer = UserInputHandlers.GetUserInput(); var confirmation = UserInputHandlers .ValidateConfirmationAnswer(answer); if (confirmation.Item1) { break; } var pizza = OrderRowHandlers.HandlePizzaChoice(); if (pizza.Name != Pizzas.None.Name) { pizza = OrderRowHandlers.HandleExtrasChoice(pizza); } var drink = OrderRowHandlers.HandleDrinkChoice(); var orderRow = OrderRowFactory.RowFactory .CreateOrderRow(pizza, drink); var updatedOrder = OrderRowDecorator.RowDecorator .ReplaceOrderRow(confirmation.Item2, orderRow); OrderRows.Rows.OrderBy(row => row.RowId); } var rows = OrderRows.Rows.ToList(); var order = OrderFactory.Factory .CreateOrder(rows); Orders.OrdersList.Add(order); MessageHandlers.PrintSubmitted(); }
/// <summary> /// Creates a new IRC client, but will not connect until ConnectAsync is called. /// </summary> /// <param name="serverAddress">Server address including port in the form of "hostname:port".</param> /// <param name="user">The IRC user to connect as.</param> /// <param name="useSSL">Connect with SSL if true.</param> public IrcClient(string serverAddress, IrcUser user, bool useSSL = false) { if (serverAddress == null) { throw new ArgumentNullException("serverAddress"); } if (user == null) { throw new ArgumentNullException("user"); } User = user; ServerAddress = serverAddress; Encoding = Encoding.UTF8; Channels = new ChannelCollection(this); Settings = new ClientSettings(); Handlers = new Dictionary <string, MessageHandler>(); MessageHandlers.RegisterDefaultHandlers(this); RequestManager = new RequestManager(); UseSSL = useSSL; WriteQueue = new ConcurrentQueue <string>(); ServerInfo = new ServerInfo(); PrivmsgPrefix = ""; Users = new UserPool(); Users.Add(User); // Add self to user pool this.ConnectCompleted = false; }
public async Task HandshakeTest(KeyPair clientKeyPair, ApplicationState alphaState, Type expectedException) { Global.AppState.State = alphaState; var clientConnection = new AlphaWebSocketConnection(new FakeWebSocket(), "127.0.0.1"); var message = new HandshakeInit { HandshakeData = clientConnection.HandshakeData }; var envelope = message.CreateEnvelope(); envelope.Sign(clientKeyPair); if (expectedException == null) { var isHandled = await MessageHandlers <AlphaWebSocketConnection> .HandleMessage(clientConnection, envelope); Assert.IsTrue(isHandled); Assert.AreEqual(clientConnection.ClientPubKey, new RawPubKey(clientKeyPair.AccountId)); if (clientConnection.ClientPubKey.Equals((RawPubKey)TestEnvironment.Auditor1KeyPair)) { Assert.AreEqual(clientConnection.ConnectionState, ConnectionState.Validated); } else { Assert.AreEqual(clientConnection.ConnectionState, ConnectionState.Ready); } } else { Assert.ThrowsAsync(expectedException, async() => await MessageHandlers <AlphaWebSocketConnection> .HandleMessage(clientConnection, envelope)); } }
/// <summary> /// Event fired when one or more new messages are ready for use. /// </summary> /// <param name="sender">Originator of call for this event.</param> /// <param name="e">Event args for the message.</param> protected override void OnIncomingMessage(object sender, IncomingMessageEventArgs <TSession, TConfig> e) { MqMessage message; // Continue to parse the messages in this queue. while (e.Messages.Count > 0) { message = e.Messages.Dequeue(); // Read the first byte for the ID. var handlerId = message[0].ReadByte(0); var handledMessage = false; // See if we have a handler for the requested Id. if (MessageHandlers.ContainsKey(handlerId)) { handledMessage = MessageHandlers[handlerId].HandleMessage(message); } // If the we can not handle this message, disconnect the session. if (handledMessage == false) { Close(SocketCloseReason.ProtocolError); return; } } }
public static Pizza HandleExtrasChoice(Pizza pizza) { while (true) { MessageHandlers.AskForExtras(); var extraChoice = UserInputHandlers.GetUserInput(); var validatedChoice = UserInputHandlers .ValidateExtrasChoice(extraChoice); if (!validatedChoice.Item1) { MessageHandlers.PrintWrongChoice(); } else { var decorator = PizzaDecorator.Decorator; pizza = decorator .AddExtras(pizza, validatedChoice.Item2); MessageHandlers.AskForMoreIngredients(); var answer = UserInputHandlers.GetUserInput(); var validatedAnswer = UserInputHandlers .ValidateMoreAnswer(answer); if (!validatedAnswer) { break; } } } return(pizza); }
private static bool HandleMoreOrderRowsChoice() { MessageHandlers.AskForMoreOrderRows(); var answer = UserInputHandlers.GetUserInput(); return(UserInputHandlers.ValidateMoreAnswer(answer)); }
void RegisterMsgHandlers() { MessageHandlers handlers = new MessageHandlers(); handlers.RegisterHandler(ELobbyMsgType.SendMsg, RPC_L2C_SendMsg); handlers.RegisterHandler(ELobbyMsgType.RoleInfoAllGot, RPC_L2C_RoleInfoAllGot); handlers.RegisterHandler(ELobbyMsgType.RoleInfoNone, RPC_L2C_RoleInfoNone); handlers.RegisterHandler(ELobbyMsgType.SteamLogin, RPC_L2C_SteamLogin); handlers.RegisterHandler(ELobbyMsgType.RolesInLobby, RPC_L2C_RolesInLobby); handlers.RegisterHandler(ELobbyMsgType.RepeatLogin, RPC_L2C_RepeatLogin); handlers.RegisterHandler(ELobbyMsgType.AccountLogout, RPC_L2C_AccountLogOut); handlers.RegisterHandler(ELobbyMsgType.RoleLogin, RPC_L2C_RoleLoggedIn); handlers.RegisterHandler(ELobbyMsgType.CloseServer, RPC_L2C_CloseServer); handlers.RegisterHandler(ELobbyMsgType.RoleCreateSuccess, RPC_L2C_CreateRoleSuccess); handlers.RegisterHandler(ELobbyMsgType.RoleCreateFailed, RPC_L2C_CreateRoleFailed); handlers.RegisterHandler(ELobbyMsgType.EnterLobbySuccess, RPC_L2C_EnterLobbySuccuss); handlers.RegisterHandler(ELobbyMsgType.EnterLobbyFailed, RPC_L2C_EnterLobbyFailed); handlers.RegisterHandler(ELobbyMsgType.DeleteRoleSuccess, RPC_L2C_TryDeleteRoleSuccess); handlers.RegisterHandler(ELobbyMsgType.DeleteRoleFailed, RPC_L2C_TryDeleteRoleFailed); handlers.RegisterHandler(ELobbyMsgType.SteamInvite, RPC_L2C_Invite); handlers.RegisterHandler(ELobbyMsgType.SteamInviteData, RPC_L2C_SyncInviteData); handlers.RegisterHandler(ELobbyMsgType.ShopData, RPC_L2C_ShopData); handlers.RegisterHandler(ELobbyMsgType.ShopDataAll, RPC_L2C_ShopDataAll); handlers.RegisterHandler(ELobbyMsgType.BuyItems, RPC_L2C_BuyItems); handlers.RegisterHandler(ELobbyMsgType.QueryLobbyExp, RPC_L2C_QueryLobbyExp); handlers.RegisterHandler(ELobbyMsgType.UploadISO, RPC_L2C_UploadIso); SetHandlers(handlers); }
/// <summary> /// Returns a combined set of message handlers including shared message handlers. /// </summary> public MessageHandlerCollection GetCombinedMessageHandlers() { foreach (var item in ServiceBusConfig.MessageHandlers) { MessageHandlers.AddMessageHandler(item); } return(MessageHandlers); }
private async Task ConfigureConstellation(AlphaSettings settings) { await Global.Setup(settings, new MongoStorage()); Global.AppState.StateChanged += Current_StateChanged; MessageHandlers <AlphaWebSocketConnection> .Init(); }
/// <inheritdoc/> protected override void InitConnection(LobbyMember member) { if (!IsHost && member != Lobby.Members.Owner) { return; } MessageHandlers.Listen(member); }
internal UNETConnection(UNETNetworkInterface networkInterface, int connectionId) { NetworkInterface = networkInterface; HostID = NetworkInterface.HostID; MessageHandlers = networkInterface.MessageHandlers; ConnectionID = connectionId; ConnectTask = new TaskCompletionSource <object>(); }
public void PrintSubmittedTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.PrintSubmitted(); var expected = "You Order Has Been Submitted." + Environment.NewLine; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
public void PrintWrongChoiceTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.PrintWrongChoice(); var expected = "Wrong input! Please try again." + Environment.NewLine; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Get all modules that have registered handle a message /// </summary> /// <param name="messageId">Unique message identifier</param> /// <returns></returns> public List <IModule> GetModulesForMessage(Guid messageId) { var modules = new List <IModule>(); if (MessageHandlers.ContainsKey(messageId)) { modules = MessageHandlers[messageId]; } return(modules); }
protected ActorXmlService(DeviceType ownDeviceType, string ownDeviceName) { _ownDeviceType = ownDeviceType; _ownDeviceName = ownDeviceName; ActorXmlDispatcher = new ActorXmlDispatcher(() => GetHelloMessage(false)); ActorXmlDispatcher.AddIncomingMessageHandler("hello", new Version(), MessageHandlers.Hello(this)); ActorXmlDispatcher.AddIncomingMessageHandler("ping", new Version(), MessageHandlers.Ping); }
public void AskForNextStepTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.AskForNextStep(); var expected = "\n\nWhat would you like to do next?"; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Starts a Trinity instance. /// </summary> public void Start() { lock (m_lock) { if (m_started) { return; } try { Log.WriteLine(LogLevel.Debug, "Starting communication instance."); var _config = TrinityConfig.CurrentClusterConfig; _config.RunningMode = this.RunningMode; Global.CommunicationInstance = this; if (_InstanceList.Count == 0) { Log.WriteLine(LogLevel.Warning, "No distributed instances configured. Turning on local test mode."); TrinityConfig.LocalTest = true; } // Initialize message handlers MessageHandlers.Initialize(); RegisterMessageHandler(); // Initialize message passing networking NativeNetwork.StartTrinityServer((UInt16)_config.ListeningPort); Log.WriteLine("My IPEndPoint: " + _config.MyBoundIP + ":" + _config.ListeningPort); // Initialize cloud storage memory_cloud = Global.CloudStorage; // Initialize the modules _InitializeModules(); if (HasHttpEndpoints()) { StartHttpServer(); } Console.WriteLine("Working Directory: {0}", Global.MyAssemblyPath); Console.WriteLine(_config.OutputCurrentConfig()); Console.WriteLine(TrinityConfig.OutputCurrentConfig()); m_started = true; Log.WriteLine("{0} {1} is successfully started.", RunningMode, _config.MyInstanceId); _RaiseStartedEvents(); } catch (Exception ex) { Log.WriteLine(LogLevel.Error, "CommunicationInstance: " + ex.ToString()); } } }
public void DisplayOrderListTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); var pizza = Pizzas.Hawaii; pizza.ExtraIngredients = new List <Ingredient> { Ingredients.Ham }; var orderList = new List <OrderRow> { OrderRowFactory.RowFactory.CreateOrderRow (pizza, Sodas.CocaCola) }; var ingredientsString = string.Empty; foreach (var ing in orderList[0].Pizza.Ingredients) { ingredientsString += ing.Name + Environment.NewLine; } var extraIngredients = string.Empty; foreach (var ing in orderList[0].Pizza.ExtraIngredients) { extraIngredients += ing.Name + Environment.NewLine; } var totalPrice = OrderRowHandlers.GetTotalPriceForOrderRow(); MessageHandlers.DisplayOrderList(orderList); var expected = "\n\nYou have the following order rows:" + Environment.NewLine + $"Row ID:{orderList[0].RowId}" + Environment.NewLine + $"Pizza:{orderList[0].Pizza.Name}" + Environment.NewLine + "Ingredients:" + Environment.NewLine + ingredientsString + "Extra ingredients:" + Environment.NewLine + extraIngredients + $"Soda: {orderList[0].Soda.Name}" + Environment.NewLine + $"Total Price: {orderList[0].TotalPrice}" + Environment.NewLine + $"\n\nTotal price for the order row: {totalPrice}" + Environment.NewLine; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
protected override async Task <bool> HandleMessage(MessageEnvelope envelope) { var isHandled = await MessageHandlers <AlphaWebSocketConnection> .HandleMessage(this, envelope); //reset invalidation timer only if message has been handled if (isHandled) { invalidationTimer?.Reset(); } return(isHandled); }
/// <summary> /// Remove message handler /// </summary> /// <param name="messageTypes">Message types</param> public static void RemoveMessageHandler(params string[] messageTypes) { if (messageTypes.IsNullOrEmpty()) { return; } foreach (var msgType in messageTypes) { MessageHandlers.Remove(msgType); } }
void OnRecieveData(int connectionId) { UNETConnection connection; if (!connectionMap.TryGetValue(connectionId, out connection)) { return; } messageReader.SeekZero(); MessageHandlers.Execute(connection, messageReader); }
public void AskForMoreTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.AskForMoreIngredients(); var expected = "Would you like to add more?" + "\nYes(0)" + "\nNo(1)" + Environment.NewLine; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
public UNETNetworkInterface() { MessageHandlers = new MessageHandlers(); Channels = new Dictionary <NetworkReliablity, int>(); connectionMap = new Dictionary <int, UNETConnection>(); connections = new List <INetworkConnection>(); Connections = new ReadOnlyCollection <INetworkConnection>(connections); readBuffer = ArrayPool <byte> .Shared.Rent(NetworkMessage.MaxMessageSize); messageReader = new NetworkReader(readBuffer); }
public void AskForMoreOrderRowsTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.AskForMoreOrderRows(); var expected = "Would you like to add more order rows?" + "\nYes(0)" + "\nNo(1)"; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
public void PrintWelcomeTest() { using var stringWriter = new StringWriter(); Console.SetOut(stringWriter); MessageHandlers.PrintWelcome(); var expected = "Hello!" + "\nWelcome to our pizzeria!" + "\nPlease enter the corresponding number and press ENTER."; var actual = stringWriter.ToString(); Assert.AreEqual(expected, actual); }
public MessageTcpService(IMessageSerializer serializer, Action <TcpSession, object> messageHandler, Func <TcpSession> creator) { handlers = new MessageHandlers(serializer); base.Initialize(() => { var session = creator(); session.Initialize(handlers.CreateReceivedHandler(session, messageHandler), handlers.CreateSendingHandler()); return(session); }); }
/// <summary> /// Get message handler /// </summary> /// <param name="messageType">Message type</param> /// <returns>Return message handler</returns> public static IMessageHandler GetMessageHandler(string messageType) { if (MessageHandlers.IsNullOrEmpty()) { return(null); } if (MessageHandlers.ContainsKey(messageType)) { return(MessageHandlers[messageType]); } return(null); }
public async Task HeartbeatTest() { Global.AppState.State = ApplicationState.Ready; var clientConnection = new AlphaWebSocketConnection(new FakeWebSocket(), "127.0.0.1"); var envelope = new Heartbeat().CreateEnvelope(); envelope.Sign(TestEnvironment.Client1KeyPair); var isHandled = await MessageHandlers <AlphaWebSocketConnection> .HandleMessage(clientConnection, envelope); Assert.IsTrue(isHandled); }
protected Peer(Lobby lobby) { Lobby = lobby; MessageHandlers = new MessageHandlers(); Lobby.OnMemberJoin += InitConnection; Lobby.OnMemberLeave += DestroyConnection; foreach (var member in Lobby.Members) { InitConnection(member); } }
public Task Upgrade(IEnumerable<string> packageList, MessageHandlers messageHandlers = null) { if( packageList == null || packageList.Count() == 0 ) { packageList = new[] {"*"}; } return Task.Factory.StartNew(() => { messageHandlers.Register(); GetInstalledPackages().ContinueWith((antecedent) => { var installedPackages = antecedent.Result; var newPackages = new List<Package>(); foreach (var pkg in installedPackages) { foreach (var supercedents in from packageMask in packageList where packageMask.Equals("all", StringComparison.CurrentCultureIgnoreCase) || pkg.CosmeticName.IsWildcardMatch(packageMask) select Registrar.Packages.SupercedentPackages(pkg)) { if (supercedents.Count() > 0) { foreach (var supercedent in supercedents.Where(supercedent => CanSatisfyPackage(supercedent, null, null))) { if (!supercedent.IsInstalled) { newPackages.Add(supercedent); } break; } } break; } } PackageManagerMessages.Invoke.UpgradingPackage(newPackages); InstallPackages(newPackages).Wait(); }, TaskContinuationOptions.AttachedToParent ); }); }
/// <summary> /// Returns a list of packages matching a given list of desired packages. /// /// This method should be aggressive in locating packages /// </summary> /// <param name = "packageNames"></param> /// <returns></returns> public static Task<IEnumerable<Package>> GetPackagesByName(IEnumerable<string> packageNames, MessageHandlers messageHandlers = null) { return CoTask<IEnumerable<Package>>.Factory.StartNew(() => { var packageFiles = new List<Package>(); var unknownPackages = new List<string>(); foreach (var item in packageNames) { var currentItem = item; Recognizer.Recognize(currentItem, ensureLocal: true).ContinueWithParent(antecedent0 => { try { var info = antecedent0.Result; if (info.RemoteFile != null) { PackageManagerMessages.Invoke.DownloadingFile(info.RemoteFile); info.RemoteFile.DownloadProgress.Notification += (progress) => PackageManagerMessages.Invoke.DownloadingFileProgress(info.RemoteFile, progress); info.Recognized.Notification += v => { if (info.IsPackageFeed) { // we have been given a package feed, and asked to return all the packages from it PackageFeed.GetPackageFeedFromLocation(currentItem).ContinueWithParent(antecedent => { packageFiles.AddRange(antecedent.Result.FindPackages("*")); }).Wait(); } else if (info.IsPackageFile) { packageFiles.Add(GetPackage(info.FullPath)); } else { unknownPackages.Add(currentItem); } }; } else if (info.IsPackageFile) { packageFiles.Add(GetPackage(info.FullPath)); } else { unknownPackages.Add(currentItem); } } catch (PackageNotFoundException) { unknownPackages.Add(item); } }); } Tasklet.WaitforCurrentChildTasks(); // HACK HACK HACK ??? if (unknownPackages.Count > 0) { ScanForPackages(unknownPackages); foreach (var item in unknownPackages) { IEnumerable<Package> possibleMatches; lock (_packages) { possibleMatches = _packages.Match(item + (item.Contains("*") || item.Contains("-") ? "*" : "-*")).HighestPackages(); } if (possibleMatches.Count() == 0) { throw new PackageNotFoundException(item); } if (possibleMatches.Count() == 1) { packageFiles.Add(possibleMatches.First()); } else { // for package matching, we only support 1 match for a given unknown. PackageManagerMessages.Invoke.MultiplePackagesMatch(item, possibleMatches); throw new OperationCompletedBeforeResultException(); } } } return packageFiles; }, messageHandlers); }
public Task DeleteSystemFeeds(IEnumerable<string> feedLocations, MessageHandlers messageHandlers = null) { return Registrar.DeleteSystemFeedLocations(feedLocations); }
internal Task RemovePackages(IEnumerable<string> packages, MessageHandlers messageHandlers = null) { // scan return Task.Factory.StartNew(() => { messageHandlers.Register(); GetInstalledPackages().Wait(); // this is going to be too aggressive I think... var packageFiles = Registrar.GetInstalledPackagesByName(packages); if (IsCancellationRequested) { return; } foreach (var p in packageFiles) { if (IsCancellationRequested) { return; } if (!p.IsInstalled) { throw new PackageIsNotInstalledException(p); } } foreach (var p in packageFiles) { if (IsCancellationRequested) { return; } PackageManagerMessages.Invoke.RemovingPackage(p); if (!Pretend) { p.Remove((percentage) => { PackageManagerMessages.Invoke.RemovingProgress(p, percentage); }); } PackageManagerMessages.Invoke.RemovingProgress(p, 100); } }); }
internal Task InstallPackages(IEnumerable<Package> packages, MessageHandlers messageHandlers = null) { return Task.Factory.StartNew(() => { messageHandlers.Register(); // if we're gonna install packages, we should make sure that CoApp has been properly installed EnsureCoAppIsInstalledInPath(); RunCompositionOnInstlledPackages(); // GS01: hack. foreach (var p in from p in packages from pas in PackagesAsSpecified where p.CosmeticName.IsWildcardMatch(pas) select p) { p.DoNotSupercede = true; } foreach ( var p in from p in packages from pas in PackagesAreUpgradable where p.CosmeticName.IsWildcardMatch(pas) select p) { p.UpgradeAsNeeded = true; } int state; GetInstalledPackages(); var downloadQueue = new List<Package>(); var installQueue = new List<Package>(); do { if (IsCancellationRequested) { return; } state = Registrar.StateCounter; downloadQueue.Clear(); installQueue.Clear(); // Tasklet.WaitforCurrentChildTasks(); // HACK HACK HACK ??? Registrar.ScanForPackages(packages); foreach (var eachPackage in packages) { try { if (CanSatisfyPackage(eachPackage, installQueue, downloadQueue)) { break; } } catch (PackageHasPotentialUpgradesException) { // if this throws, this is a signal to gtfo. (get-the-function-out) ... // ... what did you think gtfo meant? throw; } if (Registrar.StateCounter != state) { // if stuff has changed, perhaps the registrar should scan again, // just in case it can find anything new Registrar.ScanForPackages(packages); break; } // so, no scanning has been done since it wasn't likely to find anything new // and we can't satisfy this package. Bummer. // throw new PackageNotSatisfiedException(eachPackageFile); PackageManagerMessages.Invoke.PackageNotSatisfied(eachPackage); throw new OperationCompletedBeforeResultException(); } if (IsCancellationRequested) { return; } // if we're done here, make sure that any changes to the state are accounted for if (Registrar.StateCounter != state) { continue; } if(!DownloadPackages(downloadQueue)) continue; // if we're done here, make sure that any changes to the state are accounted for if (Registrar.StateCounter != state) { continue; } if( downloadQueue.Count > 0 ) { // we've got packages that should have been downloaded, but seem to have not been // BAD. GS01: TODO look into this if it occurs. throw new Exception("SHOULD NOT HAPPEN: DownloadQueue is not empty"); } if (installQueue.Count > 0) { foreach (var pkg in installQueue) { try { if (IsCancellationRequested) { return; } if (!pkg.IsInstalled) { PackageManagerMessages.Invoke.InstallingPackage(pkg); if (!Pretend) { pkg.Install(percentage => { PackageManagerMessages.Invoke.InstallProgress(pkg, percentage); }); PackageManagerMessages.Invoke.InstallProgress(pkg, 100); } pkg.IsInstalled = true; } } catch (PackageInstallFailedException) { if (!pkg.AllowedToSupercede) { throw; // user specified packge as critical. } PackageManagerMessages.Invoke.FailedDependentPackageInstall(pkg); pkg.PackageFailedInstall = true; GetInstalledPackages(); break; // let it try to find another package. } } // ... // if we're done here, make sure that any changes to the state are accounted for if (Registrar.StateCounter != state) { continue; } } // try to find them } while (Registrar.StateCounter != state); }); }
internal Task<IEnumerable<Package>> GetPackagesInScanLocations(MessageHandlers messageHandlers = null) { return Task.Factory.StartNew<IEnumerable<Package>>(() => { messageHandlers.Register(); MSIBase.ScanInstalledMSIs(); Registrar.SaveCache(); return Registrar.Packages.Union(Registrar.ScanForPackages("*")); }); }
internal Task<IEnumerable<Package>> GetInstalledPackages(MessageHandlers messageHandlers = null) { return Task.Factory.StartNew<IEnumerable<Package>>(() => { messageHandlers.Register(); MSIBase.ScanInstalledMSIs(); Registrar.SaveCache(); return Registrar.InstalledPackages; }); }
public Task InstallPackages(IEnumerable<string> packageMasks, MessageHandlers messageHandlers = null) { return Registrar.GetPackagesByName(packageMasks, messageHandlers).ContinueWith(antecedent => { foreach (var p in antecedent.Result) { p.UserSpecified = true; } return antecedent.Result; }, TaskContinuationOptions.AttachedToParent ).ContinueWith(antecedent => { InstallPackages(antecedent.Result); }, TaskContinuationOptions.AttachedToParent ); }