Publically available wrapper for logging
コード例 #1
0
ファイル: LiveCache.cs プロジェクト: Cloudxtreme/NetMud
        /// <summary>
        /// Gets one entity from the cache by its ID, only works for Singleton spawners
        /// </summary>
        /// <typeparam name="T">the underlying type of the entity</typeparam>
        /// <param name="id">the id</param>
        /// <param name="mainType">the primary type of the entity</param>
        /// <returns>the entity requested</returns>
        public static T Get <T>(long id, Type mainType) where T : IEntity
        {
            try
            {
                var allTheStuff = GetAll <T>(mainType);

                if (allTheStuff.Any(p => ((IEntity)p).DataTemplate.ID.Equals(id)))
                {
                    return(allTheStuff.First(p => ((IEntity)p).DataTemplate.ID.Equals(id)));
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(default(T));
        }
コード例 #2
0
        /// <summary>
        /// Verifies the existence of or creates a new directory, also creates the base directory if necessary
        /// </summary>
        /// <param name="directoryName">the directory to create</param>
        /// <param name="createIfMissing">creates the directory if it doesn't already exist</param>
        /// <returns>success</returns>
        private static bool VerifyDirectory(string directoryName)
        {
            string mappedName = directoryName;

            if (!mappedName.EndsWith("/"))
            {
                mappedName += "/";
            }

            try
            {
                return(Directory.Exists(HostingEnvironment.MapPath(mappedName)));
            }
            catch (Exception ex)
            {
                //Log any filesystem errors
                LoggingUtility.LogError(ex, false);
            }

            return(false);
        }