Ejemplo n.º 1
0
 public RecentChangeViewModel CreateRecentChange(RecentChangesEntry model, WikiSiteViewModel wikiSite)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     return(new RecentChangeViewModel(this, wikiSite, model));
 }
Ejemplo n.º 2
0
        internal RecentChangeViewModel(IViewModelFactory viewModelFactory,
                                       WikiSiteViewModel wikiSite, RecentChangesEntry model)
        {
            if (viewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(viewModelFactory));
            }
            if (wikiSite == null)
            {
                throw new ArgumentNullException(nameof(wikiSite));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            _ViewModelFactory = viewModelFactory;
            WikiSite          = wikiSite;
            RawEntry          = model;
            TimeStamp         = model.TimeStamp.ToLocalTime();
            NeedPatrol        = RawEntry.PatrolStatus == PatrolStatus.Unpatrolled;
            if (model.OldRevisionId > 0 && model.RevisionId > 0)
            {
                DiffRevisionIds = Tuple.Create(model.OldRevisionId, model.RevisionId);
            }
            var sb = new StringBuilder();

            switch (model.Type)
            {
            case RecentChangesType.Create:
            case RecentChangesType.Edit:
            case RecentChangesType.Move:
                break;

            case RecentChangesType.Log:
                sb.Append(Tx.SafeText("logactions:" + model.LogAction));
                sb.Append(" ");
                break;

            case RecentChangesType.Categorize:
                sb.Append("Categorize");
                sb.Append(" ");
                break;

            case RecentChangesType.External:
                sb.Append(Tx.T("rctypes:external"));
                sb.Append(" ");
                break;

            default:
                break;
            }
            if (model.Comment != null)
            {
                sb.Append(model.Comment);
            }
            Summary = sb.ToString();
        }