public EntityInspectorElement(Session session, NativeList <Entity> targets)
        {
            m_Session       = session;
            m_Targets       = targets;
            m_Components    = new List <IComponentDataElement>();
            m_WorldManager  = m_Session.GetManager <IWorldManagerInternal>();
            m_ChangeManager = m_Session.GetManager <IChangeManager>();

            var entityManager = m_Session.GetManager <IWorldManager>().EntityManager;

            var firstTarget = m_Targets[0];
            var container   = new EntityContainer(entityManager, firstTarget);

            var visitor = new InspectorVisitor <Entity>(m_Session, m_Targets);

            visitor.AddAdapter(new EntityContainerAdapter(visitor));
            visitor.AddAdapter(new PrimitivesAdapter <Entity>(visitor));

            visitor.Context.PushParent(this);

            StronglyTypedVisit(visitor, ref container);

            m_EntityHeader = this.Q <EntityHeaderElement>();
            m_Components   = Children().OfType <IComponentDataElement>().ToList();
            OrderComponentsFromComponentOrder();
        }
Example #2
0
        public SoccerLineupDetailsViewModel(Team team, IChangeManager changeManager, CollectionFactory collections)
        {
            _changeManager = changeManager;
            _teamModel     = team;

            Collections = collections;
            Team        = new TeamViewModel(team, _changeManager, Collections);

            SoccerPlayerViewModel.IsSelectedPropertyChanged += SoccerPlayerViewModel_IsSelectedPropertyChanged;

            Substitutions = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Substitute).ToSquadList();
            if (Substitutions.Count < 7)
            {
                Substitutions.Add(new SoccerPlayerViewModel()
                {
                    Name = new EditableCellViewModel(string.Empty, _changeManager), Position = new ComboBoxCellViewModel(null, null, _changeManager)
                });
            }
            Substitutions.RemoveFirstNames();
            Substitutions.ArrangePositionRoleAsec();

            Reserves = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Reserves).ToSquadList();
            Reserves.RemoveFirstNames();
            Reserves.ArrangePositionRoleAsec();

            DragDropPlayer = new RelayCommand <SoccerPlayerViewModel>(DragOrDropFieldPlayer);
        }
            public AssetTreeView(Project project, TreeViewState state) : base(state)
            {
                m_Project = project;
                showAlternatingRowBackgrounds = true;

                m_ChangeManager = project.Session.GetManager <IChangeManager>();
                m_ChangeManager.RegisterChangeCallback(OnChangeDetected);
            }
Example #4
0
 public Commander(string name, IChangeManager manager)
 {
     Name              = name;
     Soldiers          = new List <Soldier>();
     ReportResult      = new Dictionary <string, MapPoint>();
     observers_soldier = new List <ISubscriber>();
     _changeManager    = manager;
 }
Example #5
0
 public SoccerViewModelSource(Team team, Injector injector, IChangeManager changeManager, CollectionFactory collections, ISquadRepository squadRepository, Application app)
 {
     SoccerTeamDetails   = injector.New <SoccerTeamDetailsViewModel>(team: team);
     SoccerNavigationBar = new SoccerNavigationBarViewModel(team, changeManager);
     SoccerSquadDetails  = new SoccerSquadDetailsViewModel(team, changeManager, collections, squadRepository, app);
     SoccerPlayerDetails = new SoccerPlayerDetailsViewModel(null, collections, changeManager);
     SoccerLineupDetails = new SoccerLineupDetailsViewModel(team, changeManager, collections);
     SoccerFieldDetails  = new SoccerFieldDetailsViewModel(team, changeManager, collections, squadRepository);
 }
        public SoccerPlayerDetailsViewModel(SoccerPlayer player, CollectionFactory collections, IChangeManager changesManager)
        {
            Collections = collections;

            _changesManager = changesManager;
            _playerModel    = player;

            Player = new SoccerPlayerViewModel(player);
        }
        public override void Load()
        {
            m_WorldManager  = Session.GetManager <IWorldManager>();
            m_ChangeManager = Session.GetManager <IChangeManager>();
            m_ChangeManager.RegisterChangeCallback(HandleChanges, int.MinValue);

            m_Undo = Session.GetManager <IEditorUndoManager>();
            m_Undo.UndoRedoBatchStarted += HandleUndoRedoStarted;
            m_Undo.UndoRedoBatchEnded   += HandleUndoRedoEnded;
        }
Example #8
0
        public Injector(ContainerViewModel container)
        {
            _app             = new Application();
            _browser         = new ViewModelBrowser(container);
            _squadRepository = new SquadRepository();
            _collections     = new CollectionFactory(_app, _squadRepository);
            _changeManager   = new ChangeManager();

            _app.Managers = _squadRepository.GetManagers();
            _app.Teams    = _squadRepository.GetTeams();
        }
        /// <summary>
        /// 修改数据
        /// </summary>
        public static void Update(this DbContext context, IChangeManager changeManager, object entry)
        {
            if (entry == null)
            {
                throw new RepositoryDataException("Update newestEntity and originalEntity Can not be empty");
            }

            //删除
            var removes = changeManager.GetDifferences(EntityChangeType.Remove);

            if (removes.IsNullOrAuy())
            {
                foreach (var remove in removes)
                {
                    context.Delete(remove.OldEntity);
                }
            }

            List <int> addEntity = new List <int>();

            //遍历图形 设置对象修改或者添加
            context.ChangeTracker.TrackGraph(entry, e =>
            {
                int sourceHashCode      = e.SourceEntry?.Entity.GetHashCode() ?? 0;
                int entityHashCode      = e.Entry.Entity.GetHashCode();
                EntityDifference change = changeManager.GetDifference(entityHashCode);
                //如果上级添加,子级也添加
                if (addEntity.Contains(sourceHashCode))
                {
                    addEntity.Add(e.Entry.Entity.GetHashCode());
                    e.Entry.State = EntityState.Added;
                    return;
                }
                if (change == null)
                {
                    e.Entry.State = EntityState.Unchanged;
                    return;
                }
                if (change.Type == EntityChangeType.Addition)
                {
                    addEntity.Add(entityHashCode);
                    e.Entry.State = EntityState.Added;
                    return;
                }
                else
                {
                    e.Entry.State = EntityState.Unchanged;
                    foreach (var item in change.ChangePropertys)
                    {
                        e.Entry.Member(item.Name).IsModified = true;
                    }
                }
            });
        }
Example #10
0
        public override void Load()
        {
            m_WorldManager  = Session.GetManager <IWorldManager>();
            m_ChangeManager = Session.GetManager <IChangeManager>();

            if (null == m_WorldManager)
            {
                throw new ArgumentNullException(nameof(m_WorldManager));
            }

            m_ChangeManager.RegisterChangeCallback(HandleChanges);
        }
Example #11
0
 public override void Load()
 {
     LoadUnityScratchPadScene();
     m_WorldManager  = Session.GetManager <IWorldManager>();
     m_EntityManager = m_WorldManager.EntityManager;
     m_SceneManager  = Session.GetManager <IEditorSceneManagerInternal>();
     m_ChangeManager = Session.GetManager <IChangeManager>();
     m_ChangeManager.RegisterChangeCallback(HandleChanges, int.MinValue);
     m_Undo = Session.GetManager <IEditorUndoManager>();
     m_Undo.UndoRedoBatchEnded += HandleUndoEnded;
     UnityEditor.SceneManagement.EditorSceneManager.sceneOpening += HandleUnitySceneOpening;
 }
Example #12
0
 public EditableCellViewModel(object value, IChangeManager changeManager, ColumnName?column = null, SoccerPlayer player = null, bool isEnabled = true) : base(value)
 {
     _changeManager = changeManager;
     IsEnabled      = isEnabled;
     if (player != null)
     {
         _player = player;
     }
     if (column.HasValue)
     {
         _column = column;
     }
 }
        public SoccerTeamDetailsViewModel(Team team, IChangeManager changesManager, CollectionFactory collections)
        {
            _changesManager = changesManager;
            _teamModel      = team;

            Collections = collections;

            Managers = Collections.ManagerViewModels;

            TeamDetails         = new TeamViewModel(_teamModel, _changesManager, Collections);
            TeamDetails.Manager = Managers.Find(p => p.Id == TeamDetails.Manager.Id);

            SetTeamSquadDetails();
        }
        public BuildManifestView(TreeViewState state) : base(state, new MultiColumnHeader(CreateMultiColumnHeaderState()))
        {
            var session = Application.AuthoringProject.Session;

            m_PersistenceManager = session.GetManager <IPersistenceManager>();
            m_ChangeManager      = session.GetManager <IChangeManager>();
            m_ChangeManager.RegisterChangeCallback(HandleChanges);
            AssetPostprocessorCallbacks.RegisterAssetMovedHandlerForType <SceneAsset>(HandleMovedAsset);

            multiColumnHeader.sortingChanged += OnSortingChanged;
            showAlternatingRowBackgrounds     = true;

            Reload();
        }
Example #15
0
        public async override Task <TEntity> UpdateAsync(TEntity entity)
        {
            try
            {
                IChangeManager changeManager = await this.GetChangeManagerAsync(entity);

                this.dbContext.Update(changeManager, entity);
                this.dbContext.SaveChanges();
                return(entity);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public TeamViewModel(Team team, IChangeManager changeManager, CollectionFactory collections)
        {
            _changeManager = changeManager;

            Collections = collections;

            Id      = team.Id;
            Name    = team.Name;
            Manager = Collections.ManagerViewModels.Find(m => m.Id == team.ManagerId);
            Captain = team.Squad.Exists(p => p.IsCaptain) ? new SoccerPlayerViewModel(team.Squad.Find(p => p.IsCaptain), Collections, _changeManager) : new SoccerPlayerViewModel();
            Nation  = Collections.NationViewModels.Find(n => n.Id == team.NationId);
            City    = Collections.CityViewModels.Find(c => c.Id == team.CityId);
            Sport   = Collections.SportViewModels.Find(s => s.Id == team.SportId);
            Crest   = new EditableCellViewModel(team.CrestImagePath, _changeManager);
            Squad   = team.Squad.Count > 0 ? team.Squad.Select(p => new SoccerPlayerViewModel(p, Collections, _changeManager)).ToList() : new List <SoccerPlayerViewModel>();
        }
Example #17
0
        public EnigmaContext(IEnigmaConnection engineConnection, bool ownsConnection)
        {
            _engineConnection = engineConnection;
            _ownsConnection = ownsConnection;

            _details = ReflectionManager.GetDetails(this.GetType(), model =>
            {
                OnModelCreating(new ModelBuilder(model));
                _engine = _engineConnection.CreateEngine(model);
                _engine.Synchronize();
            });
            if (_engine == null)
                _engine = _engineConnection.CreateEngine(_details.Model);

            _changeManager = new ChangeManager(_details.Model);
            InitializeSets();
        }
        public SoccerSquadDetailsViewModel(Team team, IChangeManager changesManager, CollectionFactory collections, ISquadRepository squadRepository, Application app)
        {
            _changesManager = changesManager;
            _teamModel      = team;

            App             = app;
            SquadRepository = squadRepository;
            Collections     = collections;

            SetColumns();
            SetPlayers();

            AddNewPlayer             = new RelayCommand(AddNewPlayerToSquad, CanAdd);
            RemovePlayerConfirmation = new RelayCommand <SoccerPlayerViewModel>(ExecuteRemovePlayerConfirmation);
            RemovePlayerConfirmed    = new RelayCommand <bool>(ExecuteRemovePlayerConfirmed);

            PanelEnabled = true;
            ConfirmationOverlayVisible = false;
        }
        public SoccerFieldDetailsViewModel(Team team, IChangeManager changeManager, CollectionFactory collections, ISquadRepository squadRepository)
        {
            _changeManager = changeManager;
            _teamModel     = team;

            SquadRepository = squadRepository;
            Collections     = collections;

            Team            = new TeamViewModel(team, _changeManager, Collections);
            Team.Formations = _teamModel.Formations.Select(f => SetFormation(f, f.Name.Contains("Default"))).ToList();

            // TODO: Find(f => f.IsInUse)
            SelectedFormation = Team.Formations.First();
            SelectedFormation.Lineup.RemoveFirstNames();

            Substitute          = new RelayCommand(SubstitutePlayers, CanSubstitute);
            ToggleEditFormation = new RelayCommand(ToggleEditFormationMode);
            DragDropPlayer      = new RelayCommand <SoccerPlayerViewModel>(DragOrDropFieldPlayer);
        }
 public SimpleEventTracker(IChangeManager changeManager)
 {
     _notifyManager = new NotifyManager(changeManager);
 }
 public ComboBoxCellViewModel(object value, IEnumerable items, IChangeManager changeManager, SoccerPlayer player = null, ColumnName?column = null, bool isEnabled = true)
     : base(value, changeManager, column, player, isEnabled)
 {
     Items = items;
 }
        public void Detector()
        {
            var date  = DateTime.Now;
            var user1 = new User(1)
            {
                Password = null,
                Posts    = new List <Post>()
                {
                    new Post(1)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔ1", Author = new Author(1)
                        {
                            Title = "author"
                        }
                    }
                    , new Post(2)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔ", Author = new Author(2)
                        {
                            Title = "author"
                        }
                    }
                    , new Post(3)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔ", Author = new Author(3)
                        {
                            Title = null
                        }
                    }
                    , new Post(4)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔ2", Author = null
                    }
                    , new Post(5)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔb", Author = null
                    }
                    , new Post(6)
                    {
                        CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔb", Author = new Author(3)
                        {
                        }
                    }
                }
            };

            var user2 = user1.Clone <User>();

            user2.Password = "";
            user2.Aaccount = null;
            var post1 = user2.Posts.FirstOrDefault(f => f.Id == 1);

            user2.Posts.Remove(post1);
            var post2 = user2.Posts.FirstOrDefault(f => f.Id == 2);

            post2.Title = "²âÊÔÐÞ¸Ä×Ó¼¶";
            var post3 = user2.Posts.FirstOrDefault(f => f.Id == 3);

            post3.Author.Title = "²âÊÔÐÞ¸Ä×Ó×Ó¼¶";
            var post4 = user2.Posts.FirstOrDefault(f => f.Id == 4);

            post4.Author = new Author(1)
            {
                Title = "Ìí¼Ó×Ó×Ó¼¶£¬ÉèÖÃID"
            };
            var post5 = user2.Posts.FirstOrDefault(f => f.Id == 5);

            post5.Author = new Author()
            {
                Title = "Ìí¼Ó×Ó×Ó¼¶£¬²»ÉèÖÃID"
            };
            var post6 = user2.Posts.FirstOrDefault(f => f.Id == 6);

            post6.Author = null;
            var post7 = new Post(7)
            {
                CreatedDate = date, Description = date.Ticks.ToString(), Title = "²âÊÔ", Author = null
            };

            user2.Posts.Add(post7);


            CompareLogic compareLogic = new CompareLogic();

            compareLogic.Config.MaxDifferences          = int.MaxValue;
            compareLogic.Config.CompareStaticFields     = false; //¾²Ì¬×ֶβ»±È½Ï
            compareLogic.Config.CompareStaticProperties = false; //¾²Ì¬ÊôÐÔ²»±È½Ï
            compareLogic.Config.Caching = true;
            compareLogic.Config.CustomComparers.Add(new ZopDictionaryComparer(RootComparerFactory.GetRootComparer()));
            compareLogic.Config.CustomComparers.Add(new ZopListComparer(RootComparerFactory.GetRootComparer()));
            compareLogic.Config.CustomComparers.Add(new EntityCollectionComparer(RootComparerFactory.GetRootComparer()));

            var result = compareLogic.Compare(user1, user2);

            ChangeManagerFactory changeManagerFactory = new ChangeManagerFactory();
            IChangeManager       changeManager        = changeManagerFactory.Create(new EntityChange(user1, user2, 0), result);
            var    ch   = changeManager.GetChange();
            string json = ch.ToJsonString();

            User user3 = json.ToFromJson <User>();
        }
Example #23
0
 public NotifyManager(IChangeManager changeManager)
 {
     _changeManager = changeManager;
 }
 public SoccerNavigationBarViewModel(Team team, IChangeManager changesManager)
 {
     _changesManager = changesManager;
 }
Example #25
0
        public SoccerViewModel(Team team, Application app, CollectionFactory collections, ISquadRepository squadRepository, ViewModelBrowser browser, IChangeManager changeManager, Injector injector)
        {
            App             = app;
            SquadRepository = squadRepository;
            Collections     = collections;
            Browser         = browser;

            Source = new SoccerViewModelSource(team, injector, changeManager, Collections, SquadRepository, App);

            changeManager.Changeables = new List <IChangeable>()
            {
                this,
                Source.SoccerSquadDetails,
                Source.SoccerNavigationBar,
                Source.SoccerTeamDetails,
                Source.SoccerPlayerDetails,
                Source.SoccerLineupDetails,
                Source.SoccerFieldDetails,
            };
        }
Example #26
0
 public ChangeManagerFactory(IChangeManager _changeManager)
 {
     this.changeManager = _changeManager;
 }
 public SimpleEventTracker(IChangeManager changeManager)
 {
     _notifyManager = new NotifyManager(changeManager);
 }
Example #28
0
 public Soldier(string name, IChangeManager manager)
 {
     Name            = name;
     CurrentMapPoint = new MapPoint(0, 0);
     _changeManager  = manager;
 }
Example #29
0
        public SoccerPlayerViewModel(SoccerPlayer model = null, CollectionFactory collections = null, IChangeManager changeManager = null)
        {
            if (model == null)
            {
                return;
            }
            Id           = model.Id;
            TeamId       = model.TeamId;
            Name         = new EditableCellViewModel(model.Name, changeManager, ColumnName.PlayerName, model);
            Age          = new CellViewModel(model.Age);
            BirthDate    = new EditableCellViewModel(model.BirthDate.ToShortDateString(), changeManager, ColumnName.BirthDate, model);
            IsCaptain    = new EditableCellViewModel(model.IsCaptain, changeManager, ColumnName.IsCaptain, model);
            Position     = new ComboBoxCellViewModel(collections.PositionRoles.Find(pr => pr == model.Position.Role), collections.PositionRoles, changeManager, model, ColumnName.Position);
            Group        = model.Position.Group;
            Rating       = new EditableCellViewModel(model.Rating, changeManager, ColumnName.Rating, model);
            Nationality  = new ComboBoxCellViewModel(collections.NationViewModels.Find(n => n.Id == model.Nationality), collections.NationViewModels, changeManager, model, ColumnName.Nationality);
            RotationTeam = new CellViewModel(model.Rotation);
            IsLineup     = model.IsLineup;
            IsNewPlayer  = new CellViewModel(false);

            IsEnabled = true;
        }
Example #30
0
        public SoccerPlayerViewModel(SoccerPlayerViewModel viewModel, CollectionFactory collections, IChangeManager changeManager)
        {
            if (viewModel == null)
            {
                return;
            }
            var playerModel = new SoccerPlayer(viewModel);

            Id     = viewModel.Id;
            TeamId = viewModel.TeamId;
            Name   = new EditableCellViewModel(viewModel.Name.Value, changeManager, ColumnName.PlayerName, playerModel);

            DateTime birthDate = new DateTime();

            if (viewModel.BirthDate.Value is DateTime)
            {
                birthDate = (DateTime)viewModel.BirthDate.Value;
            }
            else
            {
                birthDate = DateTime.Parse((string)viewModel.BirthDate.Value);
            }
            BirthDate = new EditableCellViewModel(birthDate.ToShortDateString(), changeManager, ColumnName.BirthDate, playerModel);

            Age          = new CellViewModel(DateTime.Now.Year - birthDate.Year);
            IsCaptain    = new EditableCellViewModel(viewModel.IsCaptain.Value, changeManager, ColumnName.IsCaptain, playerModel);
            Position     = new ComboBoxCellViewModel(collections.PositionRoles.Find(pr => pr == (PositionRole)viewModel.Position.Value), collections.PositionRoles, changeManager, playerModel, ColumnName.Position);
            Group        = viewModel.Group;
            Nationality  = new ComboBoxCellViewModel(collections.NationViewModels.Find(n => n.Id == (viewModel.Nationality.Value as ComboBoxItemViewModel).Id), collections.NationViewModels, changeManager, playerModel, ColumnName.Nationality);
            Rating       = new EditableCellViewModel(viewModel.Rating.Value, changeManager, ColumnName.Rating, playerModel);
            RotationTeam = new CellViewModel(viewModel.RotationTeam.Value);
            IsNewPlayer  = new CellViewModel(false);
            IsLineup     = viewModel.IsLineup;

            IsEnabled = true;
        }