Amoeba.BoxUtils.GetCreationTime C# (CSharp) Method

GetCreationTime() public static method

public static GetCreationTime ( Box box ) : System.DateTime
box Box
return System.DateTime
        public static DateTime GetCreationTime(Box box)
        {
            var seedList = new List<Seed>();
            {
                var boxList = new List<Box>();
                boxList.Add(box);

                for (int i = 0; i < boxList.Count; i++)
                {
                    boxList.AddRange(boxList[i].Boxes);
                    seedList.AddRange(boxList[i].Seeds);
                }
            }

            if (seedList.Count == 0) return DateTime.MinValue;
            else return seedList.Max(n => n.CreationTime);
        }

Usage Example

Example #1
0
        public static string ToInfoMessage(Box box)
        {
            if (box == null)
            {
                throw new ArgumentNullException(nameof(box));
            }

            try
            {
                var builder = new StringBuilder();

                if (!string.IsNullOrWhiteSpace(box.Name))
                {
                    builder.AppendLine(string.Format("{0}: {1}", LanguagesManager.Instance.Box_Name, box.Name));
                }
                builder.AppendLine(string.Format("{0}: {1} UTC", LanguagesManager.Instance.Box_CreationTime, BoxUtils.GetCreationTime(box).ToUniversalTime().ToString(LanguagesManager.Instance.DateTime_StringFormat, System.Globalization.DateTimeFormatInfo.InvariantInfo)));

                if (builder.Length != 0)
                {
                    return(builder.ToString().Remove(builder.Length - 2));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                throw new ArgumentException("ArgumentException", e);
            }
        }