Skip to content

Commit c609653

Browse files
Conflicts: AlphaChiTech.Virtualization/PagedSourceProviderMakeAsync.cs AlphaChiTech.Virtualization/VirtualizingObservableCollection.cs AlphaChiTech.Virtualization/bin/Debug/AlphaChiTech.Virtualization.dll AlphaChiTech.Virtualization/bin/Debug/AlphaChiTech.Virtualization.pdb AlphaChiTech.Virtualization/bin/Release/AlphaChiTech.Virtualization.dll AlphaChiTech.Virtualization/bin/Release/AlphaChiTech.Virtualization.pdb AlphaChiTech.Virtualization/obj/Debug/AlphaChiTech.Virtualization.dll AlphaChiTech.Virtualization/obj/Debug/AlphaChiTech.Virtualization.pdb AlphaChiTech.Virtualization/obj/Release/AlphaChiTech.Virtualization.dll AlphaChiTech.Virtualization/obj/Release/AlphaChiTech.Virtualization.pdb
2 parents 413fa7e + 52c8d26 commit c609653

42 files changed

Lines changed: 1579 additions & 30 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/AlphaChiTech.Virtualization/bin
2+
/AlphaChiTech.Virtualization/obj
3+
/DataGridDemo/bin
4+
/DataGridDemo/obj
5+
/packages

.nuget/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.exe

1.59 MB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Enable the restore command to run before builds -->
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
8+
9+
<!-- Property that enables building a package from a project -->
10+
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11+
12+
<!-- Determines if package restore consent is required to restore packages -->
13+
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
14+
15+
<!-- Download NuGet.exe if it does not already exist -->
16+
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
17+
</PropertyGroup>
18+
19+
<ItemGroup Condition=" '$(PackageSources)' == '' ">
20+
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21+
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
22+
<!--
23+
<PackageSource Include="https://www.nuget.org/api/v2/" />
24+
<PackageSource Include="https://my-nuget-source/nuget/" />
25+
-->
26+
</ItemGroup>
27+
28+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
29+
<!-- Windows specific commands -->
30+
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
34+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
35+
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
36+
</PropertyGroup>
37+
38+
<PropertyGroup>
39+
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
40+
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
41+
</PropertyGroup>
42+
43+
<PropertyGroup>
44+
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
45+
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
46+
</PropertyGroup>
47+
48+
<PropertyGroup>
49+
<!-- NuGet command -->
50+
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
51+
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
52+
53+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
54+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
55+
56+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
57+
58+
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
59+
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
60+
61+
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
62+
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
63+
64+
<!-- Commands -->
65+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
66+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
67+
68+
<!-- We need to ensure packages are restored prior to assembly resolve -->
69+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
70+
RestorePackages;
71+
$(BuildDependsOn);
72+
</BuildDependsOn>
73+
74+
<!-- Make the build depend on restore packages -->
75+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
76+
$(BuildDependsOn);
77+
BuildPackage;
78+
</BuildDependsOn>
79+
</PropertyGroup>
80+
81+
<Target Name="CheckPrerequisites">
82+
<!-- Raise an error if we're unable to locate nuget.exe -->
83+
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
84+
<!--
85+
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
86+
This effectively acts as a lock that makes sure that the download operation will only happen once and all
87+
parallel builds will have to wait for it to complete.
88+
-->
89+
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
90+
</Target>
91+
92+
<Target Name="_DownloadNuGet">
93+
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
94+
</Target>
95+
96+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
97+
<Exec Command="$(RestoreCommand)"
98+
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
99+
100+
<Exec Command="$(RestoreCommand)"
101+
LogStandardErrorAsError="true"
102+
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
103+
</Target>
104+
105+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
106+
<Exec Command="$(BuildCommand)"
107+
Condition=" '$(OS)' != 'Windows_NT' " />
108+
109+
<Exec Command="$(BuildCommand)"
110+
LogStandardErrorAsError="true"
111+
Condition=" '$(OS)' == 'Windows_NT' " />
112+
</Target>
113+
114+
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
115+
<ParameterGroup>
116+
<OutputFilename ParameterType="System.String" Required="true" />
117+
</ParameterGroup>
118+
<Task>
119+
<Reference Include="System.Core" />
120+
<Using Namespace="System" />
121+
<Using Namespace="System.IO" />
122+
<Using Namespace="System.Net" />
123+
<Using Namespace="Microsoft.Build.Framework" />
124+
<Using Namespace="Microsoft.Build.Utilities" />
125+
<Code Type="Fragment" Language="cs">
126+
<![CDATA[
127+
try {
128+
OutputFilename = Path.GetFullPath(OutputFilename);
129+
130+
Log.LogMessage("Downloading latest version of NuGet.exe...");
131+
WebClient webClient = new WebClient();
132+
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
133+
134+
return true;
135+
}
136+
catch (Exception ex) {
137+
Log.LogErrorFromException(ex);
138+
return false;
139+
}
140+
]]>
141+
</Code>
142+
</Task>
143+
</UsingTask>
144+
</Project>

AlphaChiTech.Virtualization.sln

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30723.0
4+
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlphaChiTech.Virtualization", "AlphaChiTech.Virtualization\AlphaChiTech.Virtualization.csproj", "{5455EE53-36B9-48E8-B1F0-EB7C6ABB7A57}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGridAsyncDemo", "DataGridAsyncDemo\DataGridAsyncDemo.csproj", "{B1235F30-C8A9-4A18-B870-A7F23F214039}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{90A3E488-4EFC-4E8C-BE36-B03651A95625}"
11+
ProjectSection(SolutionItems) = preProject
12+
.nuget\NuGet.Config = .nuget\NuGet.Config
13+
.nuget\NuGet.exe = .nuget\NuGet.exe
14+
.nuget\NuGet.targets = .nuget\NuGet.targets
15+
EndProjectSection
16+
EndProject
817
Global
9-
GlobalSection(TeamFoundationVersionControl) = preSolution
10-
SccNumberOfProjects = 2
11-
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
12-
SccTeamFoundationServer = https://alphachitech.visualstudio.com/defaultcollection
13-
SccLocalPath0 = .
14-
SccProjectUniqueName1 = AlphaChiTech.Virtualization\\AlphaChiTech.Virtualization.csproj
15-
SccProjectName1 = AlphaChiTech.Virtualization
16-
SccLocalPath1 = AlphaChiTech.Virtualization
17-
EndGlobalSection
1818
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1919
Debug|Any CPU = Debug|Any CPU
2020
Release|Any CPU = Release|Any CPU
@@ -24,6 +24,10 @@ Global
2424
{5455EE53-36B9-48E8-B1F0-EB7C6ABB7A57}.Debug|Any CPU.Build.0 = Debug|Any CPU
2525
{5455EE53-36B9-48E8-B1F0-EB7C6ABB7A57}.Release|Any CPU.ActiveCfg = Release|Any CPU
2626
{5455EE53-36B9-48E8-B1F0-EB7C6ABB7A57}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{B1235F30-C8A9-4A18-B870-A7F23F214039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{B1235F30-C8A9-4A18-B870-A7F23F214039}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{B1235F30-C8A9-4A18-B870-A7F23F214039}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{B1235F30-C8A9-4A18-B870-A7F23F214039}.Release|Any CPU.Build.0 = Release|Any CPU
2731
EndGlobalSection
2832
GlobalSection(SolutionProperties) = preSolution
2933
HideSolutionNode = FALSE

AlphaChiTech.Virtualization/IPagedSourceProviderAsync.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ public interface IPagedSourceProviderAsync<T> : IPagedSourceProvider<T>
1414

1515
Task<int> GetCountAsync();
1616

17+
Task<int> IndexOfAsync( T item );
1718
}
1819
}

AlphaChiTech.Virtualization/PagedSourceProviderMakeAsync.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ namespace AlphaChiTech.Virtualization
88
{
99
public class PagedSourceProviderMakeAsync<T> : BasePagedSourceProvider<T>, IPagedSourceProviderAsync<T>, IProviderPreReset
1010
{
11-
public PagedSourceProviderMakeAsync()
11+
private Func<T, Task<int>> _FuncIndexOfAsync = null;
12+
private Func<int, int, int, T> _FuncGetPlaceHolder = null;
13+
14+
public PagedSourceProviderMakeAsync()
1215
{
1316
}
1417

1518
public PagedSourceProviderMakeAsync(
1619
Func<int, int, PagedSourceItemsPacket<T>> funcGetItemsAt = null,
1720
Func<int> funcGetCount = null,
18-
Func<T, int> funcIndexOf = null,
21+
Func<T, Task<int>> funcIndexOfAsync = null,
1922
Action<int> actionOnReset = null,
2023
Func<int, int, int, T> funcGetPlaceHolder = null,
2124
Action actionOnBeforeReset = null
2225
)
23-
: base(funcGetItemsAt, funcGetCount, funcIndexOf, actionOnReset)
26+
: base(funcGetItemsAt, funcGetCount, null, actionOnReset)
27+
//: base(funcGetItemsAt, funcGetCount, funcIndexOf, actionOnReset)
2428
{
2529
this.FuncGetPlaceHolder = funcGetPlaceHolder;
2630
this.ActionOnBeforeReset = actionOnBeforeReset;
31+
_FuncIndexOfAsync = funcIndexOfAsync;
2732
}
2833

2934
public virtual void OnBeforeReset()
@@ -42,14 +47,17 @@ public Action ActionOnBeforeReset
4247
set { _ActionOnBeforeReset = value; }
4348
}
4449

45-
private Func<int, int, int, T> _FuncGetPlaceHolder = null;
46-
4750
public Func<int, int, int, T> FuncGetPlaceHolder
4851
{
4952
get { return _FuncGetPlaceHolder; }
5053
set { _FuncGetPlaceHolder = value; }
5154
}
5255

56+
public Func<T, Task<int>> FuncIndexOfAsync
57+
{
58+
get { return _FuncIndexOfAsync; }
59+
set { _FuncIndexOfAsync = value; }
60+
}
5361

5462
public Task<PagedSourceItemsPacket<T>> GetItemsAtAsync(int pageoffset, int count, bool usePlaceholder)
5563
{
@@ -91,5 +99,15 @@ public Task<int> GetCountAsync()
9199

92100
return tcs.Task;
93101
}
102+
103+
public Task<int> IndexOfAsync( T item )
104+
{
105+
var ret = default( Task<int> );
106+
107+
if (_FuncIndexOfAsync != null)
108+
ret = _FuncIndexOfAsync.Invoke( item );
109+
110+
return ret;
111+
}
94112
}
95113
}

AlphaChiTech.Virtualization/PaginationManager.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ public int GetCount(bool asyncOK)
802802
{
803803
if (!asyncOK)
804804
{
805-
ret = this.ProviderAsync.Count;
805+
ret = this.ProviderAsync.GetCountAsync().Result;
806+
//ret = this.ProviderAsync.Count;
806807
_LocalCount = ret;
807808
}
808809
else
@@ -889,7 +890,8 @@ public int IndexOf(T item)
889890
}
890891
else
891892
{
892-
return this.ProviderAsync.IndexOf(item);
893+
return this.ProviderAsync.IndexOfAsync( item ).Result;
894+
//return this.ProviderAsync.IndexOf(item);
893895
}
894896
}
895897

@@ -899,12 +901,6 @@ public int IndexOf(T item)
899901
/// <param name="count">The count.</param>
900902
public void OnReset(int count)
901903
{
902-
if(count < 0)
903-
{
904-
_HasGotCount = false;
905-
return;
906-
}
907-
908904
CancelAllRequests();
909905

910906
lock (_PageLock)
@@ -913,7 +909,19 @@ public void OnReset(int count)
913909
}
914910

915911
ClearOptimizations();
916-
_HasGotCount = true;
912+
913+
if (count < 0)
914+
{
915+
_HasGotCount = false;
916+
}
917+
else
918+
{
919+
lock (this)
920+
{
921+
_LocalCount = count;
922+
_HasGotCount = true;
923+
}
924+
}
917925

918926
if (!IsAsync)
919927
{
@@ -925,6 +933,7 @@ public void OnReset(int count)
925933
}
926934

927935
RaiseCountChanged(true, count);
936+
928937
}
929938

930939
public void OnBeforeReset()

AlphaChiTech.Virtualization/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
// You can specify all the values or you can default the Build and Revision Numbers
2727
// by using the '*' as shown below:
2828
// [assembly: AssemblyVersion("1.0.*")]
29-
[assembly: AssemblyVersion("1.1.5.0")]
30-
[assembly: AssemblyFileVersion("1.1.5.0")]
29+
[assembly: AssemblyVersion("1.2.0.0")]
30+
[assembly: AssemblyFileVersion("1.2.0.0")]

AlphaChiTech.Virtualization/VirtualizationManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public void ProcessActions()
7171
switch (action.ThreadModel)
7272
{
7373
case VirtualActionThreadModelEnum.UseUIThread:
74+
if (UIThreadExcecuteAction == null) // PLV
75+
throw new Exception( "VirtualizationManager isn’t already initialized ! set the VirtualizationManager’s UIThreadExcecuteAction (VirtualizationManager.Instance.UIThreadExcecuteAction = a => Dispatcher.Invoke( a );)" );
7476
UIThreadExcecuteAction.Invoke(() => action.DoAction());
7577
break;
7678
case VirtualActionThreadModelEnum.Background:
@@ -115,6 +117,8 @@ public void AddAction(Action action)
115117

116118
public void RunOnUI(IVirtualizationAction action)
117119
{
120+
if (UIThreadExcecuteAction == null) // PLV
121+
throw new Exception( "VirtualizationManager isn’t already initialized ! set the VirtualizationManager’s UIThreadExcecuteAction (VirtualizationManager.Instance.UIThreadExcecuteAction = a => Dispatcher.Invoke( a );)" );
118122
UIThreadExcecuteAction.Invoke(() => action.DoAction());
119123
}
120124

0 commit comments

Comments
 (0)