Exemplo n.º 1
0
        public EntryRefContract(EntryRef entryRef)
        {
            ParamIs.NotNull(() => entryRef);

            EntryType = entryRef.EntryType;
            Id        = entryRef.Id;
        }
Exemplo n.º 2
0
        public EntryRefContract(EntryRef entryRef)
        {
            ParamIs.NotNull(() => entryRef);

            EntryType = entryRef.EntryType;
            Id = entryRef.Id;
        }
Exemplo n.º 3
0
        public void Initialize(MapEditorActionsToolVM vm)
        {
            _vm = vm;

            EntryRef.Initialize(vm.RefIdEditor);
            ActionsSelector.Initialize(vm.ActionsSelector);
        }
Exemplo n.º 4
0
        public IEntryWithNames Load(EntryRef entryRef, IDatabaseContext ctx)
        {
            switch (entryRef.EntryType)
            {
            case EntryType.Album:
                return(ctx.Load <Album>(entryRef.Id));

            case EntryType.Artist:
                return(ctx.Load <Artist>(entryRef.Id));

            case EntryType.ReleaseEvent:
                return(ctx.Load <ReleaseEvent>(entryRef.Id));

            case EntryType.ReleaseEventSeries:
                return(ctx.Load <ReleaseEventSeries>(entryRef.Id));

            case EntryType.Song:
                return(ctx.Load <Song>(entryRef.Id));

            case EntryType.Tag:
                return(ctx.Load <Tag>(entryRef.Id));

            case EntryType.Venue:
                return(ctx.Load <Venue>(entryRef.Id));
            }

            throw new ArgumentException("Unsupported entry type: " + entryRef.EntryType);
        }
Exemplo n.º 5
0
        public void Initialize(MapEditorTilesToolVM vm)
        {
            _vm = vm ?? throw new InvalidOperationException(nameof(vm));

            EntryRef.Initialize(vm.RefIdEditor);
            TilesSelector.Initialize(_vm.TilesSelector);
        }
 public void SetUp()
 {
     entryRef = new EntryRef(EntryType.Artist, 39);
     manager  = new ConcurrentEntryEditManager();
     miku     = new User("Miku", "3939", "*****@*****.**", 39)
     {
         Id = 1
     };
 }
Exemplo n.º 7
0
 public void SetUp()
 {
     entryRef = new EntryRef(EntryType.Artist, 39);
     manager  = new ConcurrentEntryEditManager();
     miku     = new User("Miku", "3939", "*****@*****.**", PasswordHashAlgorithms.Default)
     {
         Id = 1
     };
 }
Exemplo n.º 8
0
        private EntryEditData GetEditor(EntryRef entry)
        {
            ParamIs.NotNull(() => entry);

            lock (editors) {
                if (editors.ContainsKey(entry))
                {
                    return(editors[entry]);
                }
            }

            return(Nothing);
        }
        private EntryEditData GetEditor(EntryRef entry)
        {
            ParamIs.NotNull(() => entry);

            lock (editors) {

                if (editors.ContainsKey(entry))
                    return editors[entry];

            }

            return Nothing;
        }
        private void AddOrUpdate(EntryRef entry, IUser user)
        {
            ParamIs.NotNull(() => entry);
            ParamIs.NotNull(() => user);

            lock (editors) {

                if (editors.ContainsKey(entry))
                    editors[entry].Refresh(user);
                else
                    editors.Add(entry, CreateEntryEditData(user));

            }
        }
Exemplo n.º 11
0
        private void AddOrUpdate(EntryRef entry, IUser user)
        {
            ParamIs.NotNull(() => entry);
            ParamIs.NotNull(() => user);

            lock (editors) {
                if (editors.ContainsKey(entry))
                {
                    editors[entry].Refresh(user);
                }
                else
                {
                    editors.Add(entry, CreateEntryEditData(user));
                }
            }
        }
        public EntryEditData CheckConcurrentEditsInst(EntryRef entry, IUser user)
        {
            ParamIs.NotNull(() => entry);
            ParamIs.NotNull(() => user);

            ClearExpiredUsages();

            var editor = GetEditor(entry);

            if (editor.UserId != Nothing.UserId && editor.UserId != user.Id)
                return editor;

            AddOrUpdate(entry, user);

            return Nothing;
        }
        private void AddOrUpdate(EntryRef entry, IUser user)
        {
            ParamIs.NotNull(() => entry);
            ParamIs.NotNull(() => user);

            lock (editors) {
                if (editors.ContainsKey(entry))
                {
                    editors[entry].Refresh(user);
                }
                else
                {
                    log.Debug("{0} starting to edit {1}", user, entry);
                    editors.Add(entry, CreateEntryEditData(user));
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Checks for concurrent edits.
        /// </summary>
        /// <param name="entry">Entry to be checked. Cannot be null.</param>
        /// <param name="user">User attempting to edit the entry. Cannot be null.</param>
        /// <returns>Edit data for the active editor. Cannot be null.</returns>
        public EntryEditData CheckConcurrentEditsInst(EntryRef entry, IUser user)
        {
            ParamIs.NotNull(() => entry);
            ParamIs.NotNull(() => user);

            ClearExpiredUsages();

            var editor = GetEditor(entry);

            if (editor.UserId != Nothing.UserId && editor.UserId != user.Id)
            {
                return(editor);
            }

            AddOrUpdate(entry, user);

            return(Nothing);
        }
 public void SetUp()
 {
     entryRef = new EntryRef(EntryType.Artist, 39);
     manager = new ConcurrentEntryEditManager();
     miku = new User("Miku", "3939", "*****@*****.**", 39) { Id = 1 };
 }
Exemplo n.º 16
0
 public static EntryEditData CheckConcurrentEdits(EntryRef entry, IUser user)
 {
     return(staticInstance.CheckConcurrentEditsInst(entry, user));
 }
		public static EntryEditData CheckConcurrentEdits(EntryRef entry, IUser user) {
			return staticInstance.CheckConcurrentEditsInst(entry, user);
		}
Exemplo n.º 18
0
 public EntryEditedEntry(User author, bool sticky, EntryRef entryRef, EntryEditEvent editEvent)
     : base(author, sticky)
 {
     EntryRef  = entryRef;
     EditEvent = editEvent;
 }
Exemplo n.º 19
0
 public EntryEditedEntry(User author, bool sticky, EntryRef entryRef, EntryEditEvent editEvent)
     : base(author, sticky)
 {
     EntryRef = entryRef;
     EditEvent = editEvent;
 }
Exemplo n.º 20
0
 public IEntryWithNames Load(EntryRef entryRef, IDatabaseContext ctx) => entryRef.EntryType switch
 {