Example #1
0
        public virtual void SetupListProperties(object obj)
        {
            ListValueTemplate template = (ListValueTemplate)listValueTemplateCache[obj.GetType()];

            if (template == null)
            {
                template = BuildListValueTemplate(obj);
            }

            IObjectManager om = this.Context.ObjectManager;

            foreach (PropertyMap propertyMap in template.PropertyMaps)
            {
                om.SetPropertyValue(obj, propertyMap.Name, CreateList(obj, propertyMap));
            }
        }
        public virtual ListValueTemplate BuildListValueTemplate(object obj)
        {
            ListValueTemplate template = new ListValueTemplate();
            IClassMap classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());
            IList value;
            IObjectManager om = this.Context.ObjectManager;
            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                if (propertyMap.IsCollection)
                {
                    value = (IList) om.GetPropertyValue(obj, propertyMap.Name);
                    if (value == null)
                    {
                        template.PropertyMaps.Add(propertyMap);
                        //om.SetPropertyValue(obj, propertyMap.Name, CreateList(obj, propertyMap));
                        //list should /not/ have original value or it will not be considered NotLoaded
                        //om.SetOriginalPropertyValue(obj, propertyMap.Name, CreateList(obj, propertyMap));
                    }
                }

            }
            listValueTemplateCache[obj.GetType()] = template;
            return template;
        }
Example #3
0
        public virtual ListValueTemplate BuildListValueTemplate(object obj)
        {
            ListValueTemplate template = new ListValueTemplate();
            IClassMap         classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());
            IList             value;
            IObjectManager    om = this.Context.ObjectManager;

            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                if (propertyMap.IsCollection)
                {
                    value = (IList)om.GetPropertyValue(obj, propertyMap.Name);
                    if (value == null)
                    {
                        template.PropertyMaps.Add(propertyMap);
                        //om.SetPropertyValue(obj, propertyMap.Name, CreateList(obj, propertyMap));
                        //list should /not/ have original value or it will not be considered NotLoaded
                        //om.SetOriginalPropertyValue(obj, propertyMap.Name, CreateList(obj, propertyMap));
                    }
                }
            }
            listValueTemplateCache[obj.GetType()] = template;
            return(template);
        }