|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using Iesi.Collections.Generic; |
| 7 | +using NHibernate.Util; |
| 8 | + |
| 9 | +namespace NHibernate.Bytecode |
| 10 | +{ |
| 11 | + /// <summary> |
| 12 | + /// Information about all of the bytecode lazy properties for an entity |
| 13 | + /// |
| 14 | + /// Author: Steve Ebersole |
| 15 | + /// </summary> |
| 16 | + [Serializable] |
| 17 | + public class LazyPropertiesMetadata |
| 18 | + { |
| 19 | + public static LazyPropertiesMetadata NonEnhanced(string entityName) |
| 20 | + { |
| 21 | + return new LazyPropertiesMetadata(entityName, null, null); |
| 22 | + } |
| 23 | + |
| 24 | + public static LazyPropertiesMetadata From( |
| 25 | + string entityName, |
| 26 | + IEnumerable<LazyPropertyDescriptor> lazyPropertyDescriptors, |
| 27 | + ISet<string> unwrapProxyPropertyNames) |
| 28 | + { |
| 29 | + // TODO: port lazy fetch groups |
| 30 | + return new LazyPropertiesMetadata( |
| 31 | + entityName, |
| 32 | + lazyPropertyDescriptors.ToDictionary(o => o.Name), |
| 33 | + unwrapProxyPropertyNames); |
| 34 | + } |
| 35 | + |
| 36 | + private readonly IDictionary<string, LazyPropertyDescriptor> _lazyPropertyDescriptors; |
| 37 | + |
| 38 | + public LazyPropertiesMetadata( |
| 39 | + string entityName, |
| 40 | + IDictionary<string, LazyPropertyDescriptor> lazyPropertyDescriptors, |
| 41 | + ISet<string> unwrapProxyPropertyNames) |
| 42 | + { |
| 43 | + EntityName = entityName; |
| 44 | + _lazyPropertyDescriptors = lazyPropertyDescriptors; |
| 45 | + HasLazyProperties = _lazyPropertyDescriptors?.Count > 0; |
| 46 | + LazyPropertyNames = HasLazyProperties |
| 47 | + ? new ReadOnlySet<string>(new HashSet<string>(_lazyPropertyDescriptors.Keys)) |
| 48 | + : CollectionHelper.EmptySet<string>(); |
| 49 | + HasUnwrapProxyProperties = unwrapProxyPropertyNames?.Count > 0; |
| 50 | + UnwrapProxyPropertyNames = HasUnwrapProxyProperties |
| 51 | + ? new ReadOnlySet<string>(unwrapProxyPropertyNames) |
| 52 | + : CollectionHelper.EmptySet<string>(); |
| 53 | + // TODO: port lazy fetch groups |
| 54 | + } |
| 55 | + |
| 56 | + public string EntityName { get; } |
| 57 | + |
| 58 | + public bool HasLazyProperties { get; } |
| 59 | + |
| 60 | + public bool HasUnwrapProxyProperties { get; } |
| 61 | + |
| 62 | + public ISet<string> LazyPropertyNames { get; } |
| 63 | + |
| 64 | + public ISet<string> UnwrapProxyPropertyNames { get; } |
| 65 | + |
| 66 | + public IEnumerable<LazyPropertyDescriptor> LazyPropertyDescriptors => |
| 67 | + _lazyPropertyDescriptors?.Values ?? Enumerable.Empty<LazyPropertyDescriptor>(); |
| 68 | + } |
| 69 | +} |
0 commit comments