Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Provide deep merge ability #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,4 @@ __pycache__/
*.odx.cs
*.xsd.cs
/FluentPrismRegionAdapter/phirSOFT.FluentPrismAdapter.Samples
/phirSOFT.FluentPrismAdapter.Samples
5 changes: 5 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
branches: {}
ignore:
sha: []
28 changes: 15 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
version: 0.0.{build}
branches:
only:
- master
skip_non_tags: true
skip_tags: true
image: Visual Studio 2017
configuration: Release
skip_commits:
Expand All @@ -11,14 +7,6 @@ skip_commits:
- '**/*.html'
- '**/*.md'
- appveyor.yml
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
before_build:
- cmd: nuget restore
build:
publish_nuget: true
publish_nuget_symbols: true
Expand All @@ -35,3 +23,17 @@ deploy:
secure: I0crkaDLJwNba1txPPCrj0pKaFMbzxKHPIZ7hNYP1Wy6yVJ7s3napz/nEv38L/3/
on:
branch: master
install:
- choco install gitversion.portable -pre -y

assembly_info:
patch: false

before_build:
- nuget restore
- ps: gitversion /l console /output buildserver /updateAssemblyInfo

#after_build:
# - cmd: ECHO nuget pack <Project>\<NuSpec>.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
# - cmd: nuget pack <Project>\<NuSpec>.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
# - cmd: appveyor PushArtifact "<NuSpec>.%GitVersion_NuGetVersion%.nupkg"
39 changes: 39 additions & 0 deletions phirSOFT.FluentPrismAdapters/ApplicationMenuRegionAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fluent;
using Prism.Regions;
using phirSOFT.TopologicalComparison;

namespace phirSOFT.FluentPrismAdapters
{
/// <summary>
/// Provides a region adadpter dor an application menu.
/// </summary>
public class ApplicationMenuRegionAdapter : TopologicalSortedRegionAdapterBase<ApplicationMenu>
{
public ApplicationMenuRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory)
{
}

protected override IList GetItemCollection(ApplicationMenu container)
{
return container.Items;
}

public static void DeepMerge(ApplicationMenu target, ApplicationMenu source)
{
var comparer = GetComparer(target);
foreach (var sourceItem in source.Items)
{
if (comparer != null)
target.Items.Insert(sourceItem, comparer);
else
target.Items.Add(sourceItem);
}
}
}
}
16 changes: 16 additions & 0 deletions phirSOFT.FluentPrismAdapters/IUiElementMerger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace phirSOFT.FluentPrismAdapters
{
interface IUiElementMerger<in T> where T : UIElement
{
void Merge(T target, T other);

void Split(T target, T other);
}
}
12 changes: 12 additions & 0 deletions phirSOFT.FluentPrismAdapters/RibbonRegionAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Windows;
using Fluent;
using phirSOFT.TopologicalComparison;
using Prism.Regions;

namespace phirSOFT.FluentPrismAdapters
Expand All @@ -27,10 +29,20 @@ protected override IList GetItemCollection(Ribbon container, DependencyObject it
return container.QuickAccessItems;
case RibbonContextualTabGroup _:
return container.ContextualGroups;
case Ribbon ribbon:
DeepMerge(container, ribbon);
break;
case BackstageTabItem _:
return ((container.Menu as Backstage)?.Content as BackstageTabControl)?.Items;
case UIElement _:
return container.ToolBarItems;
}
return null;
}

private static void DeepMerge(Ribbon target, Ribbon source)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ protected virtual void UpdateRegion(object sender, NotifyCollectionChangedEventA
var list = GetItemCollection(regionTarget, item);
var comparer = GetComparer(regionTarget);
if (comparer != null)
list.Insert(item, comparer);
list?.Insert(item, comparer);
else
list.Add(item);
list?.Add(item);
}

break;
case NotifyCollectionChangedAction.Remove:
foreach (DependencyObject item in args.NewItems)
{
var list = GetItemCollection(regionTarget, item);
list.Remove(item);
list?.Remove(item);
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Wpf.7.0.0.336-pre\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -126,8 +127,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AfterAttribute.cs" />
<Compile Include="ApplicationMenuRegionAdapter.cs" />
<Compile Include="BackstageTabControlRegionAdapter.cs" />
<Compile Include="BeforeAttribute.cs" />
<Compile Include="IUiElementMerger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelativePositionContraint.cs" />
<Compile Include="RibbonMenuRegionAdapter.cs" />
Expand All @@ -138,7 +141,7 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="phirSOFT.FluentPrismRegionAdapters.nuspec" />
<None Include="phirSOFT.FluentPrismAdapters.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<metadata>
<id>phirSOFT.FluentPrismAdapters</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<title>phirSOFT.FluentPrismAdapters</title>
<authors>phirSOFT</authors>
<owners>phirSOFT</owners>
<projectUrl>https://github.com/phirSOFT/FluentPrismAdapters</projectUrl>
<licenseUrl>https://github.com/phirSOFT/FluentPrismAdapters/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down