Skip to content

Commit

Permalink
Merge pull request #22 from nicbell/develop
Browse files Browse the repository at this point in the history
Potential fix for #21
  • Loading branch information
nicbell authored Jul 17, 2019
2 parents ba131c4 + bb56b9a commit b78d82a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions NicBell.UCreate.Test/DocumentTypes/BaseFromPoco.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using NicBell.UCreate.Attributes;
using NicBell.UCreate.Constants;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NicBell.UCreate.Test.DocumentTypes
{
[DocType(Name = "BaseFromPoco")]
public class BaseFromPoco : Foo
{
[Property(Alias = nameof(Title), Name = "Title", TypeName = PropertyTypes.Textstring)]
public string Title { get; set; }
}

public class Foo {
public string Hello { get; set; }
}
}
2 changes: 2 additions & 0 deletions NicBell.UCreate.Test/NicBell.UCreate.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<UseGlobalApplicationHostFile />
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -302,6 +303,7 @@
<Compile Include="DataTypes\BlogPostPicker.cs" />
<Compile Include="DataTypes\Things.cs" />
<Compile Include="DocumentTypes\Base.cs" />
<Compile Include="DocumentTypes\BaseFromPoco.cs" />
<Compile Include="DocumentTypes\BlogIndex.cs" />
<Compile Include="DocumentTypes\BlogItem.cs" />
<Compile Include="DocumentTypes\Home.cs" />
Expand Down
11 changes: 10 additions & 1 deletion NicBell.UCreate/Sync/BaseTreeContentTypeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ public abstract class BaseTreeContentTypeSync<T> : BaseContentTypeSync<T> where
/// </summary>
public override void SyncAll()
{
var firstLevelTypes = TypesToSync.Where(x => x.BaseType == null || x.BaseType == typeof(object) || x.BaseType == typeof(PublishedContentModel));
// Get first level types to sync as a tree:
// they could be types that don't inherit from anything,
// inherit directly from PublishedContentModel,
// inherit from some other POCO that is's a content type
Func<Type, bool> isFirstLevelType = x => x.BaseType == null
|| x.BaseType == typeof(object)
|| x.BaseType == typeof(PublishedContentModel)
|| !x.BaseType.GetCustomAttributes().Any(at => at is BaseContentTypeAttribute);

var firstLevelTypes = TypesToSync.Where(isFirstLevelType);

foreach (var itemType in firstLevelTypes)
{
Expand Down

0 comments on commit b78d82a

Please sign in to comment.