예제 #1
0
        private static void SaveItem <TEntity>(Item item, Map <TEntity> map, TEntity entity) where TEntity : ISitecoreDomainEntity
        {
            item.Editing.BeginEdit();

            DomainEntityPropertyResolver.ResolveItem(item, map, entity);

            item.Editing.EndEdit();
        }
예제 #2
0
        private TEntity SaveItem <TEntity>(Item item, Map <TEntity> map, TEntity entity) where TEntity : ISitecoreDomainEntity
        {
            item.Editing.BeginEdit();

            DomainEntityPropertyResolver.ResolveItem(item, map, entity);

            item.Editing.EndEdit();

            return((TEntity)m_resolver.ResolveEntity(item, map));
        }
예제 #3
0
        public static void UpdateProperty <TEntity, TProperty>(TEntity entity, Expression <Func <TEntity, TProperty> > propertyExpression) where TEntity : ISitecoreDomainEntity
        {
            Guard.ParameterNotNull(entity);
            Guard.ParameterNotNull(propertyExpression);

            IMap   entityMap    = MapFinder.FindMap <TEntity>() as IMap;
            string propertyName = propertyExpression.GetPropertyName();

            Logger.LogDebugMessage(String.Format("Updating property '{0}' of '{1}' for item {2}", propertyName, typeof(TEntity), entity.Id));

            MapEntry mapEntry = entityMap.Mappings.First(mapping => mapping.MappedProperty.Name == propertyName);


            using (new SecurityDisabler())
            {
                Item item = GetItem(entity.Id);

                item.Editing.BeginEdit();
                PropertyInfo mappedProperty = mapEntry.MappedProperty;
                object       resolvedValue  = DomainEntityPropertyResolver.ResolveItemFieldValue(mappedProperty, mappedProperty.GetValue(entity, null));
                item.Fields[mapEntry.MappedTo].Value = resolvedValue.ToString();
                item.Editing.EndEdit();
            }
        }
예제 #4
0
 public CrudRepository()
 {
     m_resolver = new DomainEntityPropertyResolver();
 }
예제 #5
0
 public Repository()
 {
     m_resolver = new DomainEntityPropertyResolver();
     m_resolver.ConcreteTypeNeeded += Resolver_ConcreteTypeNeeded;
 }