コード例 #1
0
        /// <summary>
        /// Resolves a value to an instance of <see cref="Lazy{T}"/>, where the lazily-loaded
        /// object is an instance of <see cref="DataObject"/>.
        /// </summary>
        private static Object ResolveLazilyLoadedDataObject <T>(String value) where T : DataObject
        {
            var registry  = DataObjectRegistries.Get <T>();
            var reference = DataObjectRegistries.ResolveReference(value);

            return(new Lazy <T>(() => registry.GetObject(reference)));
        }
コード例 #2
0
        /// <summary>
        /// Translates the specified local identifier in this translation table
        /// into the corresponding local identifier within the current process.
        /// </summary>
        /// <typeparam name="T">The type of data object being evaluated.</typeparam>
        /// <param name="localID">The local identifier to translate.</param>
        /// <returns>The translated local identifier.</returns>
        public UInt16 Translate <T>(UInt16 localID) where T : DataObject
        {
            Guid globalID;

            if (!TryGetValue(localID, out globalID))
            {
                return(0);
            }

            var registry = DataObjectRegistries.Get <T>();
            var obj      = registry.GetObject(globalID);

            return((obj == null) ? (ushort)0 : obj.LocalID);
        }
コード例 #3
0
        /// <summary>
        /// Gets a value indicating whether the specified local identifier in this translation
        /// table translates to an object that is valid within the current process.
        /// </summary>
        /// <typeparam name="T">The type of data object being evaluated.</typeparam>
        /// <param name="localID">The local identifier of the entry within the translation table to validate.</param>
        /// <returns><see langword="true"/> if the entry is valid; otherwise, <see langword="false"/>.</returns>
        public Boolean IsValid <T>(UInt16 localID) where T : DataObject
        {
            Guid globalID;

            if (!TryGetValue(localID, out globalID))
            {
                return(false);
            }

            var registry = DataObjectRegistries.Get <T>();
            var obj      = registry.GetObject(globalID);

            return(obj != null);
        }