/// <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)));
        }
        /// <summary>
        /// Gets a <see cref="System.ComponentModel.TypeConverter.StandardValuesCollection"/> containing the object references defined by the specified data object registry.
        /// </summary>
        /// <returns>The <see cref="System.ComponentModel.TypeConverter.StandardValuesCollection"/> which was created.</returns>
        private static StandardValuesCollection GetStandardValuesForRegistry()
        {
            var registry   = DataObjectRegistries.Get <T>();
            var keys       = registry.Select(x => String.Format("@{0}:{1}", registry.ReferenceResolutionName, x.Key));
            var references = (from k in keys
                              select(ResolvedDataObjectReference) ObjectResolver.FromString(k, typeof(ResolvedDataObjectReference))).ToList();

            references.Insert(0, ResolvedDataObjectReference.Invalid);

            return(new StandardValuesCollection(references));
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }