示例#1
0
        /// <summary>
        /// Instantiates a new instance of the <see cref="CachedProfile"/> class
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="updatedOn"></param>
        public CachedProfile(NeoProfile profile, DateTime updatedOn)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            this.Profile = profile;
            this.Body = profile.GetOrderBody();
            this.UpdatedOn = updatedOn;
        }
示例#2
0
        /// <summary>
        /// Instantiates a new instance of the <see cref="CachedProfile"/> class
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="updatedOn"></param>
        public CachedProfile(NeoProfile profile, DateTime updatedOn)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            this.Profile   = profile;
            this.Body      = profile.GetOrderBody();
            this.UpdatedOn = updatedOn;
        }
        /// <summary>
        /// Returns a freshly loaded profile from disk
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public CachedProfile GetProfile(string path)
        {
            var normalizedPath = PathUtility.NormalizeFilePath(path);

            return new CachedProfile(NeoProfile.Load(normalizedPath), DateTime.Now);
        }
示例#4
0
 /// <summary>
 /// Returns the body of an order profile
 /// </summary>
 /// <param name="profile"></param>
 /// <returns></returns>
 public static List <ProfileBehavior> GetOrderBody(this NeoProfile profile)
 {
     return(profile.GetPrivateField <List <ProfileBehavior> >("Order"));
 }
示例#5
0
        /// <summary>
        /// Gets the profile behavior tree
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        public IEnumerable <Composite> GetProfileBehavior(NeoProfile profile)
        {
            var body = profile.GetPrivateField <List <ProfileBehavior> >("Order");

            return(this.GetProfileBehaviorCollectionBehavior(body));
        }
示例#6
0
        /// <summary>
        /// Gets the profile behavior tree
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        public IEnumerable<Composite> GetProfileBehavior(NeoProfile profile)
        {
            var body = profile.GetPrivateField<List<ProfileBehavior>>("Order");

            return this.GetProfileBehaviorCollectionBehavior(body);
        }
示例#7
0
        /// <summary>
        /// Gets a <see cref="NeoProfile"/> from the cache. If the cache
        /// object has not been instantiated, the specified file will
        /// be loaded.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public CachedProfile GetProfile(string path)
        {
            var normalizedPath = PathUtility.NormalizeFilePath(path);

            // Get an existing profile
            var existingProfile = ObjectCache <CachedProfile> .Instance[normalizedPath];

            // Get the last write time on the file
            var lastWrite = FileUtility.GetLastWriteTime(path);

            // Compare the update datetimes and load a fresh copy if it has been updated
            if (existingProfile != null && lastWrite <= existingProfile.UpdatedOn)
            {
                return(existingProfile);
            }

            return(ObjectCache <CachedProfile> .Instance[normalizedPath] = new CachedProfile(NeoProfile.Load(normalizedPath), lastWrite));
        }