Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when disposing this instance.
        /// </summary>
        internal protected virtual void OnDispose()
        {
            try
            {
                if (_ElementInfo != null)
                {
                    _ElementInfo.Dispose();
                }
            }
            catch { }

            _Map            = null;
            _ElementInfo    = null;
            _CompleteMember = null;
            _Columns        = null;
            _LazyProperty   = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the list of virtual lazy properties associated to the type of the entities
        /// managed by the given map. The list is obtained from the collection of members that
        /// is currently defined for the map.
        /// </summary>
        static List <LazyProperty> GetLazyProperties <T>(DataMap <T> map) where T : class
        {
            // Assumes that members is validated and so they have ElementInfo properly set...
            var list = new List <LazyProperty>(); foreach (var member in map.Members)

            {
                if (!member.ElementInfo.IsProperty)
                {
                    continue;                                                 // Only properties can be virtual...
                }
                if (member.ElementInfo.IsMultipart)
                {
                    continue;                                                 // Multipart properties not supported...
                }
                if (member.CompleteMember == null)
                {
                    continue;                                                // If no delegate property is not considered lazy...
                }
                var lazy = new LazyProperty();
                lazy.OriginalProperty = member.ElementInfo.PropertyInfo;
                lazy.OriginalGetter   = lazy.OriginalProperty.GetGetMethod(nonPublic: true);
                lazy.OriginalSetter   = lazy.OriginalProperty.GetSetMethod(nonPublic: true);

                bool valid = false;
                if (lazy.OriginalGetter != null && lazy.OriginalGetter.IsVirtual && !lazy.OriginalGetter.IsPrivate)
                {
                    valid = true;
                }
                if (lazy.OriginalSetter != null && lazy.OriginalSetter.IsVirtual && !lazy.OriginalSetter.IsPrivate)
                {
                    valid = true;
                }

                if (valid)
                {
                    list.Add(lazy);
                }
            }

            list.Sort((a, b) => string.Compare(a.Name, b.Name));
            return(list);
        }