Example #1
0
        /// <summary>
        /// Attempts to find the entity that matches the specified name in a registry. Returns `null` if none was found.
        /// </summary>
        public static IEntityRecord Find(string name, IEntityRecordCollection registry)
        {
            IEntityRecord record = new EntityRecord(name, registry);

            if (!registry.Contains(record))
            {
                record = null;
            }

            return(record);
        }
Example #2
0
        /// <summary>
        /// Ensures that the entity is registered to its registry.
        /// </summary>
        public void Synchronize()
        {
            if (Name == null)
            {
                throw new InvalidOperationException();
            }

            if (_registry != null)
            {
                if (!_registry.Contains(this))
                {
                    _registry.Enter(this);
                }
            }
        }