Пример #1
0
        public Credential Clone(bool keepID)
        {
            Credential cloned = new Credential(keepID ? ID : Guid.NewGuid().ToString(),
                                               GlyphKey,
                                               GlyphColour,
                                               Name,
                                               Description,
                                               Website,
                                               CreatedAt,
                                               LastModifiedAt,
                                               PasswordLastModifiedAt,
                                               Username,
                                               Password,
                                               Tags.ToArray(),
                                               Notes,
                                               AuditLogEntries.ToArray());

            cloned._vault = Vault;
            return(cloned);
        }
Пример #2
0
        public int CompareTo(Vault other)
        {
            Int32 idCompare = ID.CompareTo(other.ID);

            if (idCompare != 0)
            {
                return(idCompare);
            }

            Int32 nameCompare = Name.CompareTo(other.Name);

            if (nameCompare != 0)
            {
                return(nameCompare);
            }

            Int32 descriptionCompare = Description.CompareTo(other.Description);

            if (descriptionCompare != 0)
            {
                return(descriptionCompare);
            }

            Int32 createdAtCompare = CreatedAt.CompareTo(other.CreatedAt);

            if (createdAtCompare != 0)
            {
                return(createdAtCompare);
            }

            Int32 lastUpdatedAtCompare = LastUpdatedAt.CompareTo(other.LastUpdatedAt);

            if (lastUpdatedAtCompare != 0)
            {
                return(lastUpdatedAtCompare);
            }

            if (Credentials.Count == other.Credentials.Count)
            {
                Credential[] a = Credentials.OrderBy(i => i).ToArray();
                Credential[] b = other.Credentials.OrderBy(i => i).ToArray();
                for (Int32 iCred = 0; iCred < a.Length; iCred++)
                {
                    Credential credA     = a[iCred];
                    Credential credB     = b[iCred];
                    Int32      compValue = credA.CompareTo(credB);
                    if (compValue != 0)
                    {
                        return(compValue);
                    }
                }
            }
            else
            {
                return(Credentials.Count.CompareTo(other.Credentials.Count));
            }

            if (AuditLogEntries.Count == other.AuditLogEntries.Count)
            {
                AuditLogEntry[] a = AuditLogEntries.OrderBy(i => i.DateTime).ToArray();
                AuditLogEntry[] b = other.AuditLogEntries.OrderBy(i => i.DateTime).ToArray();
                for (Int32 iEntry = 0; iEntry < a.Length; iEntry++)
                {
                    AuditLogEntry entryA    = a[iEntry];
                    AuditLogEntry entryB    = b[iEntry];
                    Int32         compValue = entryA.CompareTo(entryB);
                    if (compValue != 0)
                    {
                        return(compValue);
                    }
                }
            }
            else
            {
                return(AuditLogEntries.Count.CompareTo(other.AuditLogEntries.Count));
            }

            return(0);
        }
Пример #3
0
 public void ClearAuditEntries()
 {
     AuditLogEntries.Clear();
     Vault.MarkAsDirty();
 }
Пример #4
0
    public Roster(
        int season,
        int turn,
        int bitsMatchId,
        string team,
        string?teamLevel,
        string?location,
        string?opponent,
        DateTime date,
        bool isFourPlayer,
        OilPatternInformation oilPattern,
        List <AuditLogEntry>?auditLogEntries = null)
    {
        Season          = season;
        Turn            = turn;
        BitsMatchId     = bitsMatchId;
        Team            = team;
        TeamLevel       = teamLevel ?? Team.Substring(team.Length - 1);
        Location        = location;
        Opponent        = opponent;
        Date            = date;
        IsFourPlayer    = isFourPlayer;
        OilPattern      = oilPattern ?? new OilPatternInformation(string.Empty, string.Empty);
        AuditLogEntries = auditLogEntries ?? new List <AuditLogEntry>();

        // fixup the state
        if (AuditLogEntries.Any(x => x.Before.GetType() != typeof(RosterState)))
        {
            foreach (AuditLogEntry item in AuditLogEntries)
            {
                string[] playersBefore = Array.Empty <string>();
                try
                {
                    playersBefore = ((dynamic)item.Before).Players;
                }
                catch (Exception)
                {
                }

                string[] acceptedPlayersBefore = Array.Empty <string>();
                try
                {
                    acceptedPlayersBefore = ((dynamic)item.Before).AcceptedPlayers;
                }
                catch (Exception)
                {
                }

                RosterState before = new(playersBefore, acceptedPlayersBefore);
                item.SetBefore(before);

                string[] playersAfter = Array.Empty <string>();
                try
                {
                    playersAfter = ((dynamic)item.After).Players;
                }
                catch (Exception)
                {
                }

                string[] acceptedPlayersAfter = Array.Empty <string>();
                try
                {
                    acceptedPlayersAfter = ((dynamic)item.After).AcceptedPlayers;
                }
                catch (Exception)
                {
                }

                RosterState after = new(playersAfter, acceptedPlayersAfter);
                item.SetAfter(after);
            }
        }
    }