U4-8410 - fix build

This commit is contained in:
Stephan
2016-06-22 13:33:52 +02:00
parent 3f285185d1
commit ab973fd4df
4 changed files with 35 additions and 52 deletions

View File

@@ -106,7 +106,7 @@ namespace Umbraco.Core.Models
throw new InvalidCompositionException(Alias, contentType.Alias, conflictingPropertyTypeAliases.ToArray());
_contentTypeComposition.Add(contentType);
OnPropertyChanged(ContentTypeCompositionSelector);
OnPropertyChanged(Ps.Value.ContentTypeCompositionSelector);
return true;
}
return false;
@@ -132,7 +132,7 @@ namespace Umbraco.Core.Models
if (compositionIdsToRemove.Any())
RemovedContentTypeKeyTracker.AddRange(compositionIdsToRemove);
OnPropertyChanged(ContentTypeCompositionSelector);
OnPropertyChanged(Ps.Value.ContentTypeCompositionSelector);
return _contentTypeComposition.Remove(contentTypeComposition);
}
return false;

View File

@@ -14,9 +14,14 @@ namespace Umbraco.Core.Models
CreateDateUtc = DateTime.UtcNow;
}
private static readonly PropertyInfo ContentIdSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, int>(x => x.ContentId);
private static readonly PropertyInfo CreateDateUtcSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, DateTime>(x => x.CreateDateUtc);
private static readonly PropertyInfo UrlSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, string>(x => x.Url);
private static readonly Lazy<PropertySelectors> Ps = new Lazy<PropertySelectors>();
private class PropertySelectors
{
public readonly PropertyInfo ContentIdSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, int>(x => x.ContentId);
public readonly PropertyInfo CreateDateUtcSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, DateTime>(x => x.CreateDateUtc);
public readonly PropertyInfo UrlSelector = ExpressionHelper.GetPropertyInfo<RedirectUrl, string>(x => x.Url);
}
private int _contentId;
private DateTime _createDateUtc;
@@ -27,10 +32,7 @@ namespace Umbraco.Core.Models
get { return _contentId; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
return _contentId = value;
}, _contentId, ContentIdSelector);
SetPropertyValueAndDetectChanges(value, ref _contentId, Ps.Value.ContentIdSelector);
}
}
@@ -39,10 +41,7 @@ namespace Umbraco.Core.Models
get { return _createDateUtc; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
return _createDateUtc = value;
}, _createDateUtc, CreateDateUtcSelector);
SetPropertyValueAndDetectChanges(value, ref _createDateUtc, Ps.Value.CreateDateUtcSelector);
}
}
@@ -51,10 +50,7 @@ namespace Umbraco.Core.Models
get { return _url; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
return _url = value;
}, _url, UrlSelector);
SetPropertyValueAndDetectChanges(value, ref _url, Ps.Value.UrlSelector);
}
}
}

View File

@@ -10,8 +10,8 @@ namespace Umbraco.Core.Persistence.Repositories
void DeleteAll();
void DeleteContentUrls(int contentId);
IRedirectUrl GetMostRecentUrl(string url);
IEnumerable<RedirectUrl> GetContentUrls(int contentId);
IEnumerable<RedirectUrl> GetAllUrls(long pageIndex, int pageSize, out long total);
IEnumerable<RedirectUrl> GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total);
IEnumerable<IRedirectUrl> GetContentUrls(int contentId);
IEnumerable<IRedirectUrl> GetAllUrls(long pageIndex, int pageSize, out long total);
IEnumerable<IRedirectUrl> GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total);
}
}

View File

@@ -103,13 +103,20 @@ namespace Umbraco.Core.Persistence.Repositories
{
if (dto == null) return null;
return new RedirectUrl
var url = new RedirectUrl();
try
{
Id = dto.Id,
ContentId = dto.ContentId,
CreateDateUtc = dto.CreateDateUtc,
Url = dto.Url
};
url.DisableChangeTracking();
url.Id = dto.Id;
url.ContentId = dto.ContentId;
url.CreateDateUtc = dto.CreateDateUtc;
url.Url = dto.Url;
return url;
}
finally
{
url.EnableChangeTracking();
}
}
public IRedirectUrl Get(string url, int contentId)
@@ -142,36 +149,22 @@ namespace Umbraco.Core.Persistence.Repositories
return dto == null ? null : Map(dto);
}
public IEnumerable<RedirectUrl> GetContentUrls(int contentId)
public IEnumerable<IRedirectUrl> GetContentUrls(int contentId)
{
var dtos = Database.Fetch<RedirectUrlDto>("SELECT * FROM umbracoRedirectUrl WHERE contentId=@id ORDER BY createDateUtc DESC;",
new { id = contentId });
return dtos.Select(x => new RedirectUrl
{
Id = x.Id,
ContentId = x.ContentId,
CreateDateUtc = x.CreateDateUtc,
Url = x.Url
});
return dtos.Select(Map);
}
public IEnumerable<RedirectUrl> GetAllUrls(long pageIndex, int pageSize, out long total)
public IEnumerable<IRedirectUrl> GetAllUrls(long pageIndex, int pageSize, out long total)
{
var sql = GetBaseQuery(false).OrderByDescending<RedirectUrlDto>(x => x.CreateDateUtc, SqlSyntax);
var result = Database.Page<RedirectUrlDto>(pageIndex + 1, pageSize, sql);
total = Convert.ToInt32(result.TotalItems);
var rules = result.Items.Select(x => new RedirectUrl
{
Id = x.Id,
ContentId = x.ContentId,
CreateDateUtc = x.CreateDateUtc,
Url = x.Url
});
return rules;
return result.Items.Select(Map);
}
public IEnumerable<RedirectUrl> GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total)
public IEnumerable<IRedirectUrl> GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total)
{
var sql = GetBaseQuery(false)
.InnerJoin<NodeDto>(SqlSyntax).On<NodeDto, RedirectUrlDto>(SqlSyntax, left => left.NodeId, right => right.ContentId)
@@ -180,13 +173,7 @@ namespace Umbraco.Core.Persistence.Repositories
var result = Database.Page<RedirectUrlDto>(pageIndex + 1, pageSize, sql);
total = Convert.ToInt32(result.TotalItems);
var rules = result.Items.Select(x => new RedirectUrl
{
Id = x.Id,
ContentId = x.ContentId,
CreateDateUtc = x.CreateDateUtc,
Url = x.Url
});
var rules = result.Items.Select(Map);
return rules;
}
}