Exemplo n.º 1
0
        private void HandleEntityRemoved(EntitySave entity, List <string> filesToRemove)
        {
            if (NetworkEntityViewModel.IsNetworked(entity))
            {
                var filePaths = CodeGeneratorCommonLogic.GetAllNetworkFilesFor(entity);
                filesToRemove.AddRange(filePaths.Select(item => item.FullPath));


                // All screens no longer need to handle creating this:
                TaskManager.Self.AddSync(NetworkScreenCodeGenerator.GenerateAllNetworkScreenCode,
                                         "Regenerating network screens due to entity removal");
            }
        }
Exemplo n.º 2
0
        private void HandleEntityViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var currentEntity = GlueState.Self.CurrentEntitySave;

            if (currentEntity != null && entityViewModel != null)
            {
                TaskManager.Self.AddSync(() =>
                {
                    var createdNewVariable = entityViewModel.ApplyTo(currentEntity);

                    if (createdNewVariable)
                    {
                        GlueCommands.Self.RefreshCommands.RefreshUi(currentEntity);
                    }

                    GlueCommands.Self.GluxCommands.SaveGluxTask();

                    NetworkEntityCodeGenerator.GenerateCodeFor(currentEntity);

                    // Whenever a new entity is modified, we may need to re-generate all screens because screens
                    // have a switch statement for creating entities based on networked entities:
                    var changedIsNetworked = e.PropertyName ==
                                             nameof(NetworkEntityViewModel.IsNetworkEntity);
                    if (changedIsNetworked)
                    {
                        if (NetworkEntityViewModel.IsNetworked(currentEntity) == false)
                        {
                            // set this to not be networked, need to remove the files:
                            var networkedFiles = CodeGeneratorCommonLogic.GetAllNetworkFilesFor(currentEntity);

                            foreach (var file in networkedFiles)
                            {
                                CodeGeneratorCommonLogic.RemoveCodeFileFromProject(file);
                            }
                        }
                        else
                        {
                            NetworkConfigurationCodeGenerator.GenerateConfiguration();
                            MessagesCodeGenerator.GenerateAllMessages();
                        }
                        NetworkScreenCodeGenerator.GenerateAllNetworkScreenCode();
                    }
                }, "Reacting to networked entity view model change");
            }
        }