コード例 #1
0
        /// <summary>
        /// Try to find the next age for a given age. Return false if there is no next age
        /// (in which case, the Hybrasyl year simply increments without end)
        /// </summary>
        /// <param name="age"></param>
        /// <param name="nextAge"></param>
        /// <returns></returns>
        public bool TryGetNextAge(HybrasylAge age, out HybrasylAge nextAge)
        {
            nextAge = null;
            if (Ages.Count == 1)
            {
                return(false);
            }
            // Find the age of the day after the start date. This (again) assumes the
            // user hasn't done something doltish like having non-contiguous ages
            var after = age.StartDate + new TimeSpan(1, 0, 0, 0);

            nextAge = Ages.FirstOrDefault(a => a.DateInAge(after));
            return(nextAge != null);
        }
コード例 #2
0
        /// <summary>
        /// Try to find the previous age for a given age. Return false if there is no previous age
        /// (in which case, a Hybrasyl date before the beginning of the age is simply a negative year)
        /// </summary>
        /// <param name="age"></param>
        /// <param name="previousAge"></param>
        /// <returns></returns>
        public bool TryGetPreviousAge(HybrasylAge age, out HybrasylAge previousAge)
        {
            previousAge = null;
            if (Ages.Count == 1)
            {
                return(false);
            }
            // Find the age of the day before the start date. This assumes the
            // user hasn't done something doltish like having non-contiguous ages
            var before = age.StartDate - new TimeSpan(1, 0, 0, 0);

            previousAge = Ages.FirstOrDefault(a => a.DateInAge(before));
            return(previousAge != null);
        }
コード例 #3
0
ファイル: HybrasylAge.cs プロジェクト: moseleyc/server
 /// <summary>
 /// Deserializes xml markup from file into an HybrasylAge object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output HybrasylAge object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out HybrasylAge obj, out Exception exception)
 {
     exception = null;
     obj       = default(HybrasylAge);
     try
     {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
コード例 #4
0
ファイル: HybrasylAge.cs プロジェクト: moseleyc/server
 /// <summary>
 /// Deserializes HybrasylAge object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output HybrasylAge object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out HybrasylAge obj, out Exception exception)
 {
     exception = null;
     obj       = default(HybrasylAge);
     try
     {
         obj = Deserialize(input);
         return(true);
     }
     catch (Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
コード例 #5
0
ファイル: HybrasylAge.cs プロジェクト: moseleyc/server
        public static bool LoadFromFile(string fileName, out HybrasylAge obj)
        {
            Exception exception = null;

            return(LoadFromFile(fileName, out obj, out exception));
        }
コード例 #6
0
ファイル: HybrasylAge.cs プロジェクト: moseleyc/server
        public static bool Deserialize(string input, out HybrasylAge obj)
        {
            Exception exception = null;

            return(Deserialize(input, out obj, out exception));
        }