@@ -1,92 +1,109 | |||||
1 | <?xml version="1.0" encoding="utf-8"?> |
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | <PropertyGroup> |
|
3 | <PropertyGroup> | |
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | <ProductVersion>8.0.30703</ProductVersion> |
|
6 | <ProductVersion>8.0.30703</ProductVersion> | |
7 | <SchemaVersion>2.0</SchemaVersion> |
|
7 | <SchemaVersion>2.0</SchemaVersion> | |
8 | <ProjectGuid>{2F31E405-E267-4195-A05D-574093C21209}</ProjectGuid> |
|
8 | <ProjectGuid>{2F31E405-E267-4195-A05D-574093C21209}</ProjectGuid> | |
9 | <OutputType>Library</OutputType> |
|
9 | <OutputType>Library</OutputType> | |
10 | <AppDesignerFolder>Properties</AppDesignerFolder> |
|
10 | <AppDesignerFolder>Properties</AppDesignerFolder> | |
11 | <RootNamespace>Implab.Fx.Test</RootNamespace> |
|
11 | <RootNamespace>Implab.Fx.Test</RootNamespace> | |
12 | <AssemblyName>Implab.Fx.Test</AssemblyName> |
|
12 | <AssemblyName>Implab.Fx.Test</AssemblyName> | |
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
14 | <FileAlignment>512</FileAlignment> |
|
14 | <FileAlignment>512</FileAlignment> | |
15 | <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|
15 | <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |
16 | </PropertyGroup> |
|
16 | </PropertyGroup> | |
17 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
17 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
18 | <DebugSymbols>true</DebugSymbols> |
|
18 | <DebugSymbols>true</DebugSymbols> | |
19 | <DebugType>full</DebugType> |
|
19 | <DebugType>full</DebugType> | |
20 | <Optimize>false</Optimize> |
|
20 | <Optimize>false</Optimize> | |
21 | <OutputPath>bin\Debug\</OutputPath> |
|
21 | <OutputPath>bin\Debug\</OutputPath> | |
22 | <DefineConstants>DEBUG;TRACE</DefineConstants> |
|
22 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |
23 | <ErrorReport>prompt</ErrorReport> |
|
23 | <ErrorReport>prompt</ErrorReport> | |
24 | <WarningLevel>4</WarningLevel> |
|
24 | <WarningLevel>4</WarningLevel> | |
25 | </PropertyGroup> |
|
25 | </PropertyGroup> | |
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
27 | <DebugType>pdbonly</DebugType> |
|
27 | <DebugType>pdbonly</DebugType> | |
28 | <Optimize>true</Optimize> |
|
28 | <Optimize>true</Optimize> | |
29 | <OutputPath>bin\Release\</OutputPath> |
|
29 | <OutputPath>bin\Release\</OutputPath> | |
30 | <DefineConstants>TRACE</DefineConstants> |
|
30 | <DefineConstants>TRACE</DefineConstants> | |
31 | <ErrorReport>prompt</ErrorReport> |
|
31 | <ErrorReport>prompt</ErrorReport> | |
32 | <WarningLevel>4</WarningLevel> |
|
32 | <WarningLevel>4</WarningLevel> | |
33 | </PropertyGroup> |
|
33 | </PropertyGroup> | |
|
34 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |||
|
35 | <DebugSymbols>true</DebugSymbols> | |||
|
36 | <DebugType>full</DebugType> | |||
|
37 | <Optimize>false</Optimize> | |||
|
38 | <OutputPath>bin\Debug\</OutputPath> | |||
|
39 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
|
40 | <ErrorReport>prompt</ErrorReport> | |||
|
41 | <WarningLevel>4</WarningLevel> | |||
|
42 | </PropertyGroup> | |||
|
43 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |||
|
44 | <DebugType>pdbonly</DebugType> | |||
|
45 | <Optimize>true</Optimize> | |||
|
46 | <OutputPath>bin\Release\</OutputPath> | |||
|
47 | <DefineConstants>TRACE</DefineConstants> | |||
|
48 | <ErrorReport>prompt</ErrorReport> | |||
|
49 | <WarningLevel>4</WarningLevel> | |||
|
50 | </PropertyGroup> | |||
34 | <ItemGroup> |
|
51 | <ItemGroup> | |
35 | <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
|
52 | <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | |
36 | <Reference Include="System" /> |
|
53 | <Reference Include="System" /> | |
37 | <Reference Include="System.Core"> |
|
54 | <Reference Include="System.Core"> | |
38 | <RequiredTargetFramework>3.5</RequiredTargetFramework> |
|
55 | <RequiredTargetFramework>3.5</RequiredTargetFramework> | |
39 | </Reference> |
|
56 | </Reference> | |
40 | <Reference Include="System.Data" /> |
|
57 | <Reference Include="System.Data" /> | |
41 | <Reference Include="System.Drawing" /> |
|
58 | <Reference Include="System.Drawing" /> | |
42 | <Reference Include="System.Windows.Forms" /> |
|
59 | <Reference Include="System.Windows.Forms" /> | |
43 | <Reference Include="System.Xml" /> |
|
60 | <Reference Include="System.Xml" /> | |
44 | <Reference Include="WindowsBase" /> |
|
61 | <Reference Include="WindowsBase" /> | |
45 | </ItemGroup> |
|
62 | </ItemGroup> | |
46 | <ItemGroup> |
|
63 | <ItemGroup> | |
47 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
64 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
48 | <Compile Include="OverlayTest.cs" /> |
|
65 | <Compile Include="OverlayTest.cs" /> | |
49 | <Compile Include="Sample\MainForm.cs"> |
|
66 | <Compile Include="Sample\MainForm.cs"> | |
50 | <SubType>Form</SubType> |
|
67 | <SubType>Form</SubType> | |
51 | </Compile> |
|
68 | </Compile> | |
52 | <Compile Include="Sample\MainForm.Designer.cs"> |
|
69 | <Compile Include="Sample\MainForm.Designer.cs"> | |
53 | <DependentUpon>MainForm.cs</DependentUpon> |
|
70 | <DependentUpon>MainForm.cs</DependentUpon> | |
54 | </Compile> |
|
71 | </Compile> | |
55 | <Compile Include="Sample\OverlayForm.cs"> |
|
72 | <Compile Include="Sample\OverlayForm.cs"> | |
56 | <SubType>Form</SubType> |
|
73 | <SubType>Form</SubType> | |
57 | </Compile> |
|
74 | </Compile> | |
58 | <Compile Include="Sample\OverlayForm.Designer.cs"> |
|
75 | <Compile Include="Sample\OverlayForm.Designer.cs"> | |
59 | <DependentUpon>OverlayForm.cs</DependentUpon> |
|
76 | <DependentUpon>OverlayForm.cs</DependentUpon> | |
60 | </Compile> |
|
77 | </Compile> | |
61 | </ItemGroup> |
|
78 | </ItemGroup> | |
62 | <ItemGroup> |
|
79 | <ItemGroup> | |
63 | <EmbeddedResource Include="Sample\MainForm.resx"> |
|
80 | <EmbeddedResource Include="Sample\MainForm.resx"> | |
64 | <DependentUpon>MainForm.cs</DependentUpon> |
|
81 | <DependentUpon>MainForm.cs</DependentUpon> | |
65 | <LogicalName> |
|
82 | <LogicalName> | |
66 | </LogicalName> |
|
83 | </LogicalName> | |
67 | </EmbeddedResource> |
|
84 | </EmbeddedResource> | |
68 | <EmbeddedResource Include="Sample\OverlayForm.resx"> |
|
85 | <EmbeddedResource Include="Sample\OverlayForm.resx"> | |
69 | <DependentUpon>OverlayForm.cs</DependentUpon> |
|
86 | <DependentUpon>OverlayForm.cs</DependentUpon> | |
70 | <LogicalName> |
|
87 | <LogicalName> | |
71 | </LogicalName> |
|
88 | </LogicalName> | |
72 | </EmbeddedResource> |
|
89 | </EmbeddedResource> | |
73 | </ItemGroup> |
|
90 | </ItemGroup> | |
74 | <ItemGroup> |
|
91 | <ItemGroup> | |
75 | <ProjectReference Include="..\Implab.Fx\Implab.Fx.csproj"> |
|
92 | <ProjectReference Include="..\Implab.Fx\Implab.Fx.csproj"> | |
76 | <Project>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</Project> |
|
93 | <Project>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</Project> | |
77 | <Name>Implab.Fx</Name> |
|
94 | <Name>Implab.Fx</Name> | |
78 | </ProjectReference> |
|
95 | </ProjectReference> | |
79 | <ProjectReference Include="..\Implab\Implab.csproj"> |
|
96 | <ProjectReference Include="..\Implab\Implab.csproj"> | |
80 | <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project> |
|
97 | <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project> | |
81 | <Name>Implab</Name> |
|
98 | <Name>Implab</Name> | |
82 | </ProjectReference> |
|
99 | </ProjectReference> | |
83 | </ItemGroup> |
|
100 | </ItemGroup> | |
84 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
101 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
85 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|
102 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |
86 | Other similar extension points exist, see Microsoft.Common.targets. |
|
103 | Other similar extension points exist, see Microsoft.Common.targets. | |
87 | <Target Name="BeforeBuild"> |
|
104 | <Target Name="BeforeBuild"> | |
88 | </Target> |
|
105 | </Target> | |
89 | <Target Name="AfterBuild"> |
|
106 | <Target Name="AfterBuild"> | |
90 | </Target> |
|
107 | </Target> | |
91 | --> |
|
108 | --> | |
92 | </Project> No newline at end of file |
|
109 | </Project> |
@@ -1,65 +1,82 | |||||
1 | <?xml version="1.0" encoding="utf-8"?> |
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | <PropertyGroup> |
|
3 | <PropertyGroup> | |
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | <ProductVersion>8.0.30703</ProductVersion> |
|
6 | <ProductVersion>8.0.30703</ProductVersion> | |
7 | <SchemaVersion>2.0</SchemaVersion> |
|
7 | <SchemaVersion>2.0</SchemaVersion> | |
8 | <ProjectGuid>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</ProjectGuid> |
|
8 | <ProjectGuid>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</ProjectGuid> | |
9 | <OutputType>Library</OutputType> |
|
9 | <OutputType>Library</OutputType> | |
10 | <AppDesignerFolder>Properties</AppDesignerFolder> |
|
10 | <AppDesignerFolder>Properties</AppDesignerFolder> | |
11 | <RootNamespace>Implab.Fx</RootNamespace> |
|
11 | <RootNamespace>Implab.Fx</RootNamespace> | |
12 | <AssemblyName>Implab.Fx</AssemblyName> |
|
12 | <AssemblyName>Implab.Fx</AssemblyName> | |
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
14 | <FileAlignment>512</FileAlignment> |
|
14 | <FileAlignment>512</FileAlignment> | |
15 | </PropertyGroup> |
|
15 | </PropertyGroup> | |
16 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
16 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
17 | <DebugSymbols>true</DebugSymbols> |
|
17 | <DebugSymbols>true</DebugSymbols> | |
18 | <DebugType>full</DebugType> |
|
18 | <DebugType>full</DebugType> | |
19 | <Optimize>false</Optimize> |
|
19 | <Optimize>false</Optimize> | |
20 | <OutputPath>bin\Debug\</OutputPath> |
|
20 | <OutputPath>bin\Debug\</OutputPath> | |
21 | <DefineConstants>DEBUG;TRACE</DefineConstants> |
|
21 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |
22 | <ErrorReport>prompt</ErrorReport> |
|
22 | <ErrorReport>prompt</ErrorReport> | |
23 | <WarningLevel>4</WarningLevel> |
|
23 | <WarningLevel>4</WarningLevel> | |
24 | </PropertyGroup> |
|
24 | </PropertyGroup> | |
25 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
25 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
26 | <DebugType>pdbonly</DebugType> |
|
26 | <DebugType>pdbonly</DebugType> | |
27 | <Optimize>true</Optimize> |
|
27 | <Optimize>true</Optimize> | |
28 | <OutputPath>bin\Release\</OutputPath> |
|
28 | <OutputPath>bin\Release\</OutputPath> | |
29 | <DefineConstants>TRACE</DefineConstants> |
|
29 | <DefineConstants>TRACE</DefineConstants> | |
30 | <ErrorReport>prompt</ErrorReport> |
|
30 | <ErrorReport>prompt</ErrorReport> | |
31 | <WarningLevel>4</WarningLevel> |
|
31 | <WarningLevel>4</WarningLevel> | |
32 | </PropertyGroup> |
|
32 | </PropertyGroup> | |
|
33 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |||
|
34 | <DebugSymbols>true</DebugSymbols> | |||
|
35 | <DebugType>full</DebugType> | |||
|
36 | <Optimize>false</Optimize> | |||
|
37 | <OutputPath>bin\Debug\</OutputPath> | |||
|
38 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
|
39 | <ErrorReport>prompt</ErrorReport> | |||
|
40 | <WarningLevel>4</WarningLevel> | |||
|
41 | </PropertyGroup> | |||
|
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |||
|
43 | <DebugType>pdbonly</DebugType> | |||
|
44 | <Optimize>true</Optimize> | |||
|
45 | <OutputPath>bin\Release\</OutputPath> | |||
|
46 | <DefineConstants>TRACE</DefineConstants> | |||
|
47 | <ErrorReport>prompt</ErrorReport> | |||
|
48 | <WarningLevel>4</WarningLevel> | |||
|
49 | </PropertyGroup> | |||
33 | <ItemGroup> |
|
50 | <ItemGroup> | |
34 | <Reference Include="System" /> |
|
51 | <Reference Include="System" /> | |
35 | <Reference Include="System.Core" /> |
|
52 | <Reference Include="System.Core" /> | |
36 | <Reference Include="System.Drawing" /> |
|
53 | <Reference Include="System.Drawing" /> | |
37 | <Reference Include="System.Windows.Forms" /> |
|
54 | <Reference Include="System.Windows.Forms" /> | |
38 | <Reference Include="System.Xml.Linq" /> |
|
55 | <Reference Include="System.Xml.Linq" /> | |
39 | <Reference Include="System.Data.DataSetExtensions" /> |
|
56 | <Reference Include="System.Data.DataSetExtensions" /> | |
40 | <Reference Include="Microsoft.CSharp" /> |
|
57 | <Reference Include="Microsoft.CSharp" /> | |
41 | <Reference Include="System.Data" /> |
|
58 | <Reference Include="System.Data" /> | |
42 | <Reference Include="System.Xml" /> |
|
59 | <Reference Include="System.Xml" /> | |
43 | </ItemGroup> |
|
60 | </ItemGroup> | |
44 | <ItemGroup> |
|
61 | <ItemGroup> | |
45 | <Compile Include="Animation.cs" /> |
|
62 | <Compile Include="Animation.cs" /> | |
46 | <Compile Include="AnimationHelpers.cs" /> |
|
63 | <Compile Include="AnimationHelpers.cs" /> | |
47 | <Compile Include="PromiseHelpers.cs" /> |
|
64 | <Compile Include="PromiseHelpers.cs" /> | |
48 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
65 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
49 | <Compile Include="ControlBoundPromise.cs" /> |
|
66 | <Compile Include="ControlBoundPromise.cs" /> | |
50 | </ItemGroup> |
|
67 | </ItemGroup> | |
51 | <ItemGroup> |
|
68 | <ItemGroup> | |
52 | <ProjectReference Include="..\Implab\Implab.csproj"> |
|
69 | <ProjectReference Include="..\Implab\Implab.csproj"> | |
53 | <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project> |
|
70 | <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project> | |
54 | <Name>Implab</Name> |
|
71 | <Name>Implab</Name> | |
55 | </ProjectReference> |
|
72 | </ProjectReference> | |
56 | </ItemGroup> |
|
73 | </ItemGroup> | |
57 | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|
74 | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |
58 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|
75 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |
59 | Other similar extension points exist, see Microsoft.Common.targets. |
|
76 | Other similar extension points exist, see Microsoft.Common.targets. | |
60 | <Target Name="BeforeBuild"> |
|
77 | <Target Name="BeforeBuild"> | |
61 | </Target> |
|
78 | </Target> | |
62 | <Target Name="AfterBuild"> |
|
79 | <Target Name="AfterBuild"> | |
63 | </Target> |
|
80 | </Target> | |
64 | --> |
|
81 | --> | |
65 | </Project> No newline at end of file |
|
82 | </Project> |
@@ -1,60 +1,77 | |||||
1 | <?xml version="1.0" encoding="utf-8"?> |
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | <PropertyGroup> |
|
3 | <PropertyGroup> | |
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | <ProductVersion>8.0.30703</ProductVersion> |
|
6 | <ProductVersion>8.0.30703</ProductVersion> | |
7 | <SchemaVersion>2.0</SchemaVersion> |
|
7 | <SchemaVersion>2.0</SchemaVersion> | |
8 | <ProjectGuid>{63F92C0C-61BF-48C0-A377-8D67C3C661D0}</ProjectGuid> |
|
8 | <ProjectGuid>{63F92C0C-61BF-48C0-A377-8D67C3C661D0}</ProjectGuid> | |
9 | <OutputType>Library</OutputType> |
|
9 | <OutputType>Library</OutputType> | |
10 | <AppDesignerFolder>Properties</AppDesignerFolder> |
|
10 | <AppDesignerFolder>Properties</AppDesignerFolder> | |
11 | <RootNamespace>Implab.Test</RootNamespace> |
|
11 | <RootNamespace>Implab.Test</RootNamespace> | |
12 | <AssemblyName>Implab.Test</AssemblyName> |
|
12 | <AssemblyName>Implab.Test</AssemblyName> | |
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
13 | <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
14 | <FileAlignment>512</FileAlignment> |
|
14 | <FileAlignment>512</FileAlignment> | |
15 | <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|
15 | <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |
16 | </PropertyGroup> |
|
16 | </PropertyGroup> | |
17 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
17 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
18 | <DebugSymbols>true</DebugSymbols> |
|
18 | <DebugSymbols>true</DebugSymbols> | |
19 | <DebugType>full</DebugType> |
|
19 | <DebugType>full</DebugType> | |
20 | <Optimize>false</Optimize> |
|
20 | <Optimize>false</Optimize> | |
21 | <OutputPath>bin\Debug\</OutputPath> |
|
21 | <OutputPath>bin\Debug\</OutputPath> | |
22 | <DefineConstants>DEBUG;TRACE</DefineConstants> |
|
22 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |
23 | <ErrorReport>prompt</ErrorReport> |
|
23 | <ErrorReport>prompt</ErrorReport> | |
24 | <WarningLevel>4</WarningLevel> |
|
24 | <WarningLevel>4</WarningLevel> | |
25 | </PropertyGroup> |
|
25 | </PropertyGroup> | |
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
27 | <DebugType>pdbonly</DebugType> |
|
27 | <DebugType>pdbonly</DebugType> | |
28 | <Optimize>true</Optimize> |
|
28 | <Optimize>true</Optimize> | |
29 | <OutputPath>bin\Release\</OutputPath> |
|
29 | <OutputPath>bin\Release\</OutputPath> | |
30 | <DefineConstants>TRACE</DefineConstants> |
|
30 | <DefineConstants>TRACE</DefineConstants> | |
31 | <ErrorReport>prompt</ErrorReport> |
|
31 | <ErrorReport>prompt</ErrorReport> | |
32 | <WarningLevel>4</WarningLevel> |
|
32 | <WarningLevel>4</WarningLevel> | |
33 | </PropertyGroup> |
|
33 | </PropertyGroup> | |
|
34 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |||
|
35 | <DebugSymbols>true</DebugSymbols> | |||
|
36 | <DebugType>full</DebugType> | |||
|
37 | <Optimize>false</Optimize> | |||
|
38 | <OutputPath>bin\Debug\</OutputPath> | |||
|
39 | <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
|
40 | <ErrorReport>prompt</ErrorReport> | |||
|
41 | <WarningLevel>4</WarningLevel> | |||
|
42 | </PropertyGroup> | |||
|
43 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |||
|
44 | <DebugType>pdbonly</DebugType> | |||
|
45 | <Optimize>true</Optimize> | |||
|
46 | <OutputPath>bin\Release\</OutputPath> | |||
|
47 | <DefineConstants>TRACE</DefineConstants> | |||
|
48 | <ErrorReport>prompt</ErrorReport> | |||
|
49 | <WarningLevel>4</WarningLevel> | |||
|
50 | </PropertyGroup> | |||
34 | <ItemGroup> |
|
51 | <ItemGroup> | |
35 | <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
|
52 | <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | |
36 | <Reference Include="System" /> |
|
53 | <Reference Include="System" /> | |
37 | <Reference Include="System.Core"> |
|
54 | <Reference Include="System.Core"> | |
38 | <RequiredTargetFramework>3.5</RequiredTargetFramework> |
|
55 | <RequiredTargetFramework>3.5</RequiredTargetFramework> | |
39 | </Reference> |
|
56 | </Reference> | |
40 | </ItemGroup> |
|
57 | </ItemGroup> | |
41 | <ItemGroup> |
|
58 | <ItemGroup> | |
42 | <Compile Include="AsyncTests.cs" /> |
|
59 | <Compile Include="AsyncTests.cs" /> | |
43 | <Compile Include="PromiseHelper.cs" /> |
|
60 | <Compile Include="PromiseHelper.cs" /> | |
44 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
61 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
45 | </ItemGroup> |
|
62 | </ItemGroup> | |
46 | <ItemGroup> |
|
63 | <ItemGroup> | |
47 | <ProjectReference Include="..\Implab\Implab.csproj"> |
|
64 | <ProjectReference Include="..\Implab\Implab.csproj"> | |
48 | <Project>{99B95D0D-9CF9-4F70-8ADF-F4D0AA5CB0D9}</Project> |
|
65 | <Project>{99B95D0D-9CF9-4F70-8ADF-F4D0AA5CB0D9}</Project> | |
49 | <Name>Implab</Name> |
|
66 | <Name>Implab</Name> | |
50 | </ProjectReference> |
|
67 | </ProjectReference> | |
51 | </ItemGroup> |
|
68 | </ItemGroup> | |
52 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
69 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
53 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|
70 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |
54 | Other similar extension points exist, see Microsoft.Common.targets. |
|
71 | Other similar extension points exist, see Microsoft.Common.targets. | |
55 | <Target Name="BeforeBuild"> |
|
72 | <Target Name="BeforeBuild"> | |
56 | </Target> |
|
73 | </Target> | |
57 | <Target Name="AfterBuild"> |
|
74 | <Target Name="AfterBuild"> | |
58 | </Target> |
|
75 | </Target> | |
59 | --> |
|
76 | --> | |
60 | </Project> No newline at end of file |
|
77 | </Project> |
@@ -1,252 +1,270 | |||||
1 | |
|
1 | | |
2 | Microsoft Visual Studio Solution File, Format Version 11.00 |
|
2 | Microsoft Visual Studio Solution File, Format Version 11.00 | |
3 | # Visual Studio 2010 |
|
3 | # Visual Studio 2010 | |
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab", "Implab\Implab.csproj", "{F550F1F8-8746-4AD0-9614-855F4C4B7F05}" |
|
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab", "Implab\Implab.csproj", "{F550F1F8-8746-4AD0-9614-855F4C4B7F05}" | |
5 | EndProject |
|
5 | EndProject | |
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE8D8D18-437A-445C-B662-4C2CE79A76F6}" |
|
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE8D8D18-437A-445C-B662-4C2CE79A76F6}" | |
7 | ProjectSection(SolutionItems) = preProject |
|
7 | ProjectSection(SolutionItems) = preProject | |
8 | Implab.vsmdi = Implab.vsmdi |
|
8 | Implab.vsmdi = Implab.vsmdi | |
9 | Local.testsettings = Local.testsettings |
|
9 | Local.testsettings = Local.testsettings | |
10 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings |
|
10 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings | |
11 | EndProjectSection |
|
11 | EndProjectSection | |
12 | EndProject |
|
12 | EndProject | |
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Test", "Implab.Test\Implab.Test.csproj", "{63F92C0C-61BF-48C0-A377-8D67C3C661D0}" |
|
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Test", "Implab.Test\Implab.Test.csproj", "{63F92C0C-61BF-48C0-A377-8D67C3C661D0}" | |
14 | EndProject |
|
14 | EndProject | |
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}" |
|
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}" | |
16 | EndProject |
|
16 | EndProject | |
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx.Test", "Implab.Fx.Test\Implab.Fx.Test.csproj", "{2F31E405-E267-4195-A05D-574093C21209}" |
|
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx.Test", "Implab.Fx.Test\Implab.Fx.Test.csproj", "{2F31E405-E267-4195-A05D-574093C21209}" | |
18 | EndProject |
|
18 | EndProject | |
19 | Global |
|
19 | Global | |
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
21 | Debug|Any CPU = Debug|Any CPU |
|
21 | Debug|Any CPU = Debug|Any CPU | |
22 | Release|Any CPU = Release|Any CPU |
|
22 | Release|Any CPU = Release|Any CPU | |
|
23 | Debug 4.5|Any CPU = Debug 4.5|Any CPU | |||
|
24 | Release 4.5|Any CPU = Release 4.5|Any CPU | |||
23 | EndGlobalSection |
|
25 | EndGlobalSection | |
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
|
27 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU | |||
|
28 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU | |||
25 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
29 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
26 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
30 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
|
31 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU | |||
|
32 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU | |||
27 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
33 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
28 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU |
|
34 | {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU | |
|
35 | {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU | |||
|
36 | {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU | |||
29 | {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
37 | {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
30 | {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
38 | {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
|
39 | {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU | |||
|
40 | {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU | |||
31 | {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
41 | {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
32 | {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU |
|
42 | {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU | |
|
43 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU | |||
|
44 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU | |||
33 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
45 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
34 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
46 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
|
47 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU | |||
|
48 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU | |||
35 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
49 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
36 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.Build.0 = Release|Any CPU |
|
50 | {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.Build.0 = Release|Any CPU | |
|
51 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU | |||
|
52 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU | |||
37 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
53 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
38 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
54 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
|
55 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU | |||
|
56 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU | |||
39 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
57 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
40 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.Build.0 = Release|Any CPU |
|
58 | {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.Build.0 = Release|Any CPU | |
41 | EndGlobalSection |
|
59 | EndGlobalSection | |
42 | GlobalSection(NestedProjects) = preSolution |
|
60 | GlobalSection(NestedProjects) = preSolution | |
43 | EndGlobalSection |
|
61 | EndGlobalSection | |
44 | GlobalSection(MonoDevelopProperties) = preSolution |
|
62 | GlobalSection(MonoDevelopProperties) = preSolution | |
45 | StartupItem = Implab\Implab.csproj |
|
63 | StartupItem = Implab\Implab.csproj | |
46 | Policies = $0 |
|
64 | Policies = $0 | |
47 | $0.CSharpFormattingPolicy = $1 |
|
65 | $0.CSharpFormattingPolicy = $1 | |
48 | $1.IndentSwitchBody = True |
|
66 | $1.IndentSwitchBody = True | |
49 | $1.NamespaceBraceStyle = EndOfLine |
|
67 | $1.NamespaceBraceStyle = EndOfLine | |
50 | $1.ClassBraceStyle = EndOfLine |
|
68 | $1.ClassBraceStyle = EndOfLine | |
51 | $1.InterfaceBraceStyle = EndOfLine |
|
69 | $1.InterfaceBraceStyle = EndOfLine | |
52 | $1.StructBraceStyle = EndOfLine |
|
70 | $1.StructBraceStyle = EndOfLine | |
53 | $1.EnumBraceStyle = EndOfLine |
|
71 | $1.EnumBraceStyle = EndOfLine | |
54 | $1.MethodBraceStyle = EndOfLine |
|
72 | $1.MethodBraceStyle = EndOfLine | |
55 | $1.ConstructorBraceStyle = EndOfLine |
|
73 | $1.ConstructorBraceStyle = EndOfLine | |
56 | $1.DestructorBraceStyle = EndOfLine |
|
74 | $1.DestructorBraceStyle = EndOfLine | |
57 | $1.BeforeMethodDeclarationParentheses = False |
|
75 | $1.BeforeMethodDeclarationParentheses = False | |
58 | $1.BeforeMethodCallParentheses = False |
|
76 | $1.BeforeMethodCallParentheses = False | |
59 | $1.BeforeConstructorDeclarationParentheses = False |
|
77 | $1.BeforeConstructorDeclarationParentheses = False | |
60 | $1.NewLineBeforeConstructorInitializerColon = NewLine |
|
78 | $1.NewLineBeforeConstructorInitializerColon = NewLine | |
61 | $1.NewLineAfterConstructorInitializerColon = SameLine |
|
79 | $1.NewLineAfterConstructorInitializerColon = SameLine | |
62 | $1.BeforeIndexerDeclarationBracket = False |
|
80 | $1.BeforeIndexerDeclarationBracket = False | |
63 | $1.BeforeDelegateDeclarationParentheses = False |
|
81 | $1.BeforeDelegateDeclarationParentheses = False | |
64 | $1.NewParentheses = False |
|
82 | $1.NewParentheses = False | |
65 | $1.SpacesBeforeBrackets = False |
|
83 | $1.SpacesBeforeBrackets = False | |
66 | $1.inheritsSet = Mono |
|
84 | $1.inheritsSet = Mono | |
67 | $1.inheritsScope = text/x-csharp |
|
85 | $1.inheritsScope = text/x-csharp | |
68 | $1.scope = text/x-csharp |
|
86 | $1.scope = text/x-csharp | |
69 | $0.TextStylePolicy = $2 |
|
87 | $0.TextStylePolicy = $2 | |
70 | $2.FileWidth = 120 |
|
88 | $2.FileWidth = 120 | |
71 | $2.EolMarker = Unix |
|
89 | $2.EolMarker = Unix | |
72 | $2.inheritsSet = VisualStudio |
|
90 | $2.inheritsSet = VisualStudio | |
73 | $2.inheritsScope = text/plain |
|
91 | $2.inheritsScope = text/plain | |
74 | $2.scope = text/x-csharp |
|
92 | $2.scope = text/x-csharp | |
75 | $0.DotNetNamingPolicy = $3 |
|
93 | $0.DotNetNamingPolicy = $3 | |
76 | $3.DirectoryNamespaceAssociation = PrefixedHierarchical |
|
94 | $3.DirectoryNamespaceAssociation = PrefixedHierarchical | |
77 | $3.ResourceNamePolicy = MSBuild |
|
95 | $3.ResourceNamePolicy = MSBuild | |
78 | $0.TextStylePolicy = $4 |
|
96 | $0.TextStylePolicy = $4 | |
79 | $4.FileWidth = 120 |
|
97 | $4.FileWidth = 120 | |
80 | $4.TabsToSpaces = False |
|
98 | $4.TabsToSpaces = False | |
81 | $4.inheritsSet = VisualStudio |
|
99 | $4.inheritsSet = VisualStudio | |
82 | $4.inheritsScope = text/plain |
|
100 | $4.inheritsScope = text/plain | |
83 | $4.scope = application/xml |
|
101 | $4.scope = application/xml | |
84 | $0.XmlFormattingPolicy = $5 |
|
102 | $0.XmlFormattingPolicy = $5 | |
85 | $5.inheritsSet = Mono |
|
103 | $5.inheritsSet = Mono | |
86 | $5.inheritsScope = application/xml |
|
104 | $5.inheritsScope = application/xml | |
87 | $5.scope = application/xml |
|
105 | $5.scope = application/xml | |
88 | $0.TextStylePolicy = $6 |
|
106 | $0.TextStylePolicy = $6 | |
89 | $6.FileWidth = 120 |
|
107 | $6.FileWidth = 120 | |
90 | $6.TabsToSpaces = False |
|
108 | $6.TabsToSpaces = False | |
91 | $6.inheritsSet = VisualStudio |
|
109 | $6.inheritsSet = VisualStudio | |
92 | $6.inheritsScope = text/plain |
|
110 | $6.inheritsScope = text/plain | |
93 | $6.scope = text/plain |
|
111 | $6.scope = text/plain | |
94 | $0.NameConventionPolicy = $7 |
|
112 | $0.NameConventionPolicy = $7 | |
95 | $7.Rules = $8 |
|
113 | $7.Rules = $8 | |
96 | $8.NamingRule = $9 |
|
114 | $8.NamingRule = $9 | |
97 | $9.Name = Namespaces |
|
115 | $9.Name = Namespaces | |
98 | $9.AffectedEntity = Namespace |
|
116 | $9.AffectedEntity = Namespace | |
99 | $9.VisibilityMask = VisibilityMask |
|
117 | $9.VisibilityMask = VisibilityMask | |
100 | $9.NamingStyle = PascalCase |
|
118 | $9.NamingStyle = PascalCase | |
101 | $9.IncludeInstanceMembers = True |
|
119 | $9.IncludeInstanceMembers = True | |
102 | $9.IncludeStaticEntities = True |
|
120 | $9.IncludeStaticEntities = True | |
103 | $8.NamingRule = $10 |
|
121 | $8.NamingRule = $10 | |
104 | $10.Name = Types |
|
122 | $10.Name = Types | |
105 | $10.AffectedEntity = Class, Struct, Enum, Delegate |
|
123 | $10.AffectedEntity = Class, Struct, Enum, Delegate | |
106 | $10.VisibilityMask = VisibilityMask |
|
124 | $10.VisibilityMask = VisibilityMask | |
107 | $10.NamingStyle = PascalCase |
|
125 | $10.NamingStyle = PascalCase | |
108 | $10.IncludeInstanceMembers = True |
|
126 | $10.IncludeInstanceMembers = True | |
109 | $10.IncludeStaticEntities = True |
|
127 | $10.IncludeStaticEntities = True | |
110 | $8.NamingRule = $11 |
|
128 | $8.NamingRule = $11 | |
111 | $11.Name = Interfaces |
|
129 | $11.Name = Interfaces | |
112 | $11.RequiredPrefixes = $12 |
|
130 | $11.RequiredPrefixes = $12 | |
113 | $12.String = I |
|
131 | $12.String = I | |
114 | $11.AffectedEntity = Interface |
|
132 | $11.AffectedEntity = Interface | |
115 | $11.VisibilityMask = VisibilityMask |
|
133 | $11.VisibilityMask = VisibilityMask | |
116 | $11.NamingStyle = PascalCase |
|
134 | $11.NamingStyle = PascalCase | |
117 | $11.IncludeInstanceMembers = True |
|
135 | $11.IncludeInstanceMembers = True | |
118 | $11.IncludeStaticEntities = True |
|
136 | $11.IncludeStaticEntities = True | |
119 | $8.NamingRule = $13 |
|
137 | $8.NamingRule = $13 | |
120 | $13.Name = Attributes |
|
138 | $13.Name = Attributes | |
121 | $13.RequiredSuffixes = $14 |
|
139 | $13.RequiredSuffixes = $14 | |
122 | $14.String = Attribute |
|
140 | $14.String = Attribute | |
123 | $13.AffectedEntity = CustomAttributes |
|
141 | $13.AffectedEntity = CustomAttributes | |
124 | $13.VisibilityMask = VisibilityMask |
|
142 | $13.VisibilityMask = VisibilityMask | |
125 | $13.NamingStyle = PascalCase |
|
143 | $13.NamingStyle = PascalCase | |
126 | $13.IncludeInstanceMembers = True |
|
144 | $13.IncludeInstanceMembers = True | |
127 | $13.IncludeStaticEntities = True |
|
145 | $13.IncludeStaticEntities = True | |
128 | $8.NamingRule = $15 |
|
146 | $8.NamingRule = $15 | |
129 | $15.Name = Event Arguments |
|
147 | $15.Name = Event Arguments | |
130 | $15.RequiredSuffixes = $16 |
|
148 | $15.RequiredSuffixes = $16 | |
131 | $16.String = EventArgs |
|
149 | $16.String = EventArgs | |
132 | $15.AffectedEntity = CustomEventArgs |
|
150 | $15.AffectedEntity = CustomEventArgs | |
133 | $15.VisibilityMask = VisibilityMask |
|
151 | $15.VisibilityMask = VisibilityMask | |
134 | $15.NamingStyle = PascalCase |
|
152 | $15.NamingStyle = PascalCase | |
135 | $15.IncludeInstanceMembers = True |
|
153 | $15.IncludeInstanceMembers = True | |
136 | $15.IncludeStaticEntities = True |
|
154 | $15.IncludeStaticEntities = True | |
137 | $8.NamingRule = $17 |
|
155 | $8.NamingRule = $17 | |
138 | $17.Name = Exceptions |
|
156 | $17.Name = Exceptions | |
139 | $17.RequiredSuffixes = $18 |
|
157 | $17.RequiredSuffixes = $18 | |
140 | $18.String = Exception |
|
158 | $18.String = Exception | |
141 | $17.AffectedEntity = CustomExceptions |
|
159 | $17.AffectedEntity = CustomExceptions | |
142 | $17.VisibilityMask = VisibilityMask |
|
160 | $17.VisibilityMask = VisibilityMask | |
143 | $17.NamingStyle = PascalCase |
|
161 | $17.NamingStyle = PascalCase | |
144 | $17.IncludeInstanceMembers = True |
|
162 | $17.IncludeInstanceMembers = True | |
145 | $17.IncludeStaticEntities = True |
|
163 | $17.IncludeStaticEntities = True | |
146 | $8.NamingRule = $19 |
|
164 | $8.NamingRule = $19 | |
147 | $19.Name = Methods |
|
165 | $19.Name = Methods | |
148 | $19.AffectedEntity = Methods |
|
166 | $19.AffectedEntity = Methods | |
149 | $19.VisibilityMask = VisibilityMask |
|
167 | $19.VisibilityMask = VisibilityMask | |
150 | $19.NamingStyle = PascalCase |
|
168 | $19.NamingStyle = PascalCase | |
151 | $19.IncludeInstanceMembers = True |
|
169 | $19.IncludeInstanceMembers = True | |
152 | $19.IncludeStaticEntities = True |
|
170 | $19.IncludeStaticEntities = True | |
153 | $8.NamingRule = $20 |
|
171 | $8.NamingRule = $20 | |
154 | $20.Name = Static Readonly Fields |
|
172 | $20.Name = Static Readonly Fields | |
155 | $20.AffectedEntity = ReadonlyField |
|
173 | $20.AffectedEntity = ReadonlyField | |
156 | $20.VisibilityMask = Internal, Protected, Public |
|
174 | $20.VisibilityMask = Internal, Protected, Public | |
157 | $20.NamingStyle = CamelCase |
|
175 | $20.NamingStyle = CamelCase | |
158 | $20.IncludeInstanceMembers = False |
|
176 | $20.IncludeInstanceMembers = False | |
159 | $20.IncludeStaticEntities = True |
|
177 | $20.IncludeStaticEntities = True | |
160 | $8.NamingRule = $21 |
|
178 | $8.NamingRule = $21 | |
161 | $21.Name = Fields (Non Private) |
|
179 | $21.Name = Fields (Non Private) | |
162 | $21.AffectedEntity = Field |
|
180 | $21.AffectedEntity = Field | |
163 | $21.VisibilityMask = Internal, Public |
|
181 | $21.VisibilityMask = Internal, Public | |
164 | $21.NamingStyle = CamelCase |
|
182 | $21.NamingStyle = CamelCase | |
165 | $21.IncludeInstanceMembers = True |
|
183 | $21.IncludeInstanceMembers = True | |
166 | $21.IncludeStaticEntities = True |
|
184 | $21.IncludeStaticEntities = True | |
167 | $8.NamingRule = $22 |
|
185 | $8.NamingRule = $22 | |
168 | $22.Name = ReadOnly Fields (Non Private) |
|
186 | $22.Name = ReadOnly Fields (Non Private) | |
169 | $22.AffectedEntity = ReadonlyField |
|
187 | $22.AffectedEntity = ReadonlyField | |
170 | $22.VisibilityMask = Internal, Public |
|
188 | $22.VisibilityMask = Internal, Public | |
171 | $22.NamingStyle = CamelCase |
|
189 | $22.NamingStyle = CamelCase | |
172 | $22.IncludeInstanceMembers = True |
|
190 | $22.IncludeInstanceMembers = True | |
173 | $22.IncludeStaticEntities = False |
|
191 | $22.IncludeStaticEntities = False | |
174 | $8.NamingRule = $23 |
|
192 | $8.NamingRule = $23 | |
175 | $23.Name = Fields (Private) |
|
193 | $23.Name = Fields (Private) | |
176 | $23.RequiredPrefixes = $24 |
|
194 | $23.RequiredPrefixes = $24 | |
177 | $24.String = m_ |
|
195 | $24.String = m_ | |
178 | $23.AffectedEntity = Field, ReadonlyField |
|
196 | $23.AffectedEntity = Field, ReadonlyField | |
179 | $23.VisibilityMask = Private, Protected |
|
197 | $23.VisibilityMask = Private, Protected | |
180 | $23.NamingStyle = CamelCase |
|
198 | $23.NamingStyle = CamelCase | |
181 | $23.IncludeInstanceMembers = True |
|
199 | $23.IncludeInstanceMembers = True | |
182 | $23.IncludeStaticEntities = False |
|
200 | $23.IncludeStaticEntities = False | |
183 | $8.NamingRule = $25 |
|
201 | $8.NamingRule = $25 | |
184 | $25.Name = Static Fields (Private) |
|
202 | $25.Name = Static Fields (Private) | |
185 | $25.RequiredPrefixes = $26 |
|
203 | $25.RequiredPrefixes = $26 | |
186 | $26.String = _ |
|
204 | $26.String = _ | |
187 | $25.AffectedEntity = Field |
|
205 | $25.AffectedEntity = Field | |
188 | $25.VisibilityMask = Private |
|
206 | $25.VisibilityMask = Private | |
189 | $25.NamingStyle = CamelCase |
|
207 | $25.NamingStyle = CamelCase | |
190 | $25.IncludeInstanceMembers = False |
|
208 | $25.IncludeInstanceMembers = False | |
191 | $25.IncludeStaticEntities = True |
|
209 | $25.IncludeStaticEntities = True | |
192 | $8.NamingRule = $27 |
|
210 | $8.NamingRule = $27 | |
193 | $27.Name = ReadOnly Fields (Private) |
|
211 | $27.Name = ReadOnly Fields (Private) | |
194 | $27.RequiredPrefixes = $28 |
|
212 | $27.RequiredPrefixes = $28 | |
195 | $28.String = m_ |
|
213 | $28.String = m_ | |
196 | $27.AffectedEntity = ReadonlyField |
|
214 | $27.AffectedEntity = ReadonlyField | |
197 | $27.VisibilityMask = Private, Protected |
|
215 | $27.VisibilityMask = Private, Protected | |
198 | $27.NamingStyle = CamelCase |
|
216 | $27.NamingStyle = CamelCase | |
199 | $27.IncludeInstanceMembers = True |
|
217 | $27.IncludeInstanceMembers = True | |
200 | $27.IncludeStaticEntities = False |
|
218 | $27.IncludeStaticEntities = False | |
201 | $8.NamingRule = $29 |
|
219 | $8.NamingRule = $29 | |
202 | $29.Name = Constant Fields |
|
220 | $29.Name = Constant Fields | |
203 | $29.AffectedEntity = ConstantField |
|
221 | $29.AffectedEntity = ConstantField | |
204 | $29.VisibilityMask = VisibilityMask |
|
222 | $29.VisibilityMask = VisibilityMask | |
205 | $29.NamingStyle = AllUpper |
|
223 | $29.NamingStyle = AllUpper | |
206 | $29.IncludeInstanceMembers = True |
|
224 | $29.IncludeInstanceMembers = True | |
207 | $29.IncludeStaticEntities = True |
|
225 | $29.IncludeStaticEntities = True | |
208 | $8.NamingRule = $30 |
|
226 | $8.NamingRule = $30 | |
209 | $30.Name = Properties |
|
227 | $30.Name = Properties | |
210 | $30.AffectedEntity = Property |
|
228 | $30.AffectedEntity = Property | |
211 | $30.VisibilityMask = VisibilityMask |
|
229 | $30.VisibilityMask = VisibilityMask | |
212 | $30.NamingStyle = PascalCase |
|
230 | $30.NamingStyle = PascalCase | |
213 | $30.IncludeInstanceMembers = True |
|
231 | $30.IncludeInstanceMembers = True | |
214 | $30.IncludeStaticEntities = True |
|
232 | $30.IncludeStaticEntities = True | |
215 | $8.NamingRule = $31 |
|
233 | $8.NamingRule = $31 | |
216 | $31.Name = Events |
|
234 | $31.Name = Events | |
217 | $31.AffectedEntity = Event |
|
235 | $31.AffectedEntity = Event | |
218 | $31.VisibilityMask = VisibilityMask |
|
236 | $31.VisibilityMask = VisibilityMask | |
219 | $31.NamingStyle = PascalCase |
|
237 | $31.NamingStyle = PascalCase | |
220 | $31.IncludeInstanceMembers = True |
|
238 | $31.IncludeInstanceMembers = True | |
221 | $31.IncludeStaticEntities = True |
|
239 | $31.IncludeStaticEntities = True | |
222 | $8.NamingRule = $32 |
|
240 | $8.NamingRule = $32 | |
223 | $32.Name = Enum Members |
|
241 | $32.Name = Enum Members | |
224 | $32.AffectedEntity = EnumMember |
|
242 | $32.AffectedEntity = EnumMember | |
225 | $32.VisibilityMask = VisibilityMask |
|
243 | $32.VisibilityMask = VisibilityMask | |
226 | $32.NamingStyle = PascalCase |
|
244 | $32.NamingStyle = PascalCase | |
227 | $32.IncludeInstanceMembers = True |
|
245 | $32.IncludeInstanceMembers = True | |
228 | $32.IncludeStaticEntities = True |
|
246 | $32.IncludeStaticEntities = True | |
229 | $8.NamingRule = $33 |
|
247 | $8.NamingRule = $33 | |
230 | $33.Name = Parameters |
|
248 | $33.Name = Parameters | |
231 | $33.AffectedEntity = Parameter, LocalVariable |
|
249 | $33.AffectedEntity = Parameter, LocalVariable | |
232 | $33.VisibilityMask = VisibilityMask |
|
250 | $33.VisibilityMask = VisibilityMask | |
233 | $33.NamingStyle = CamelCase |
|
251 | $33.NamingStyle = CamelCase | |
234 | $33.IncludeInstanceMembers = True |
|
252 | $33.IncludeInstanceMembers = True | |
235 | $33.IncludeStaticEntities = True |
|
253 | $33.IncludeStaticEntities = True | |
236 | $8.NamingRule = $34 |
|
254 | $8.NamingRule = $34 | |
237 | $34.Name = Type Parameters |
|
255 | $34.Name = Type Parameters | |
238 | $34.RequiredPrefixes = $35 |
|
256 | $34.RequiredPrefixes = $35 | |
239 | $35.String = T |
|
257 | $35.String = T | |
240 | $34.AffectedEntity = TypeParameter |
|
258 | $34.AffectedEntity = TypeParameter | |
241 | $34.VisibilityMask = VisibilityMask |
|
259 | $34.VisibilityMask = VisibilityMask | |
242 | $34.NamingStyle = PascalCase |
|
260 | $34.NamingStyle = PascalCase | |
243 | $34.IncludeInstanceMembers = True |
|
261 | $34.IncludeInstanceMembers = True | |
244 | $34.IncludeStaticEntities = True |
|
262 | $34.IncludeStaticEntities = True | |
245 | EndGlobalSection |
|
263 | EndGlobalSection | |
246 | GlobalSection(TestCaseManagementSettings) = postSolution |
|
264 | GlobalSection(TestCaseManagementSettings) = postSolution | |
247 | CategoryFile = Implab.vsmdi |
|
265 | CategoryFile = Implab.vsmdi | |
248 | EndGlobalSection |
|
266 | EndGlobalSection | |
249 | GlobalSection(SolutionProperties) = preSolution |
|
267 | GlobalSection(SolutionProperties) = preSolution | |
250 | HideSolutionNode = FALSE |
|
268 | HideSolutionNode = FALSE | |
251 | EndGlobalSection |
|
269 | EndGlobalSection | |
252 | EndGlobal |
|
270 | EndGlobal |
@@ -1,72 +1,82 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 | using System.Text; |
|
4 | using System.Text; | |
5 |
|
5 | |||
6 | namespace Implab { |
|
6 | namespace Implab { | |
7 | public interface IPromise: ICancellable { |
|
7 | public interface IPromise: ICancellable { | |
8 | /// <summary> |
|
8 | /// <summary> | |
9 | /// Check whereather the promise has no more than one dependent promise. |
|
9 | /// Check whereather the promise has no more than one dependent promise. | |
10 | /// </summary> |
|
10 | /// </summary> | |
11 | bool IsExclusive { |
|
11 | bool IsExclusive { | |
12 | get; |
|
12 | get; | |
13 | } |
|
13 | } | |
14 |
|
14 | |||
15 | /// <summary> |
|
15 | /// <summary> | |
16 | /// Тип результата, получаемого через данное обещание. |
|
16 | /// Тип результата, получаемого через данное обещание. | |
17 | /// </summary> |
|
17 | /// </summary> | |
18 | Type PromiseType { get; } |
|
18 | Type PromiseType { get; } | |
19 |
|
19 | |||
20 | /// <summary> |
|
20 | /// <summary> | |
21 | /// Обещание является выполненым, либо успешно, либо с ошибкой. |
|
21 | /// Обещание является выполненым, либо успешно, либо с ошибкой. | |
22 | /// </summary> |
|
22 | /// </summary> | |
23 | bool IsResolved { get; } |
|
23 | bool IsResolved { get; } | |
24 |
|
24 | |||
25 | /// <summary> |
|
25 | /// <summary> | |
26 | /// Обещание было отменено. |
|
26 | /// Обещание было отменено. | |
27 | /// </summary> |
|
27 | /// </summary> | |
28 | bool IsCancelled { get; } |
|
28 | bool IsCancelled { get; } | |
29 |
|
29 | |||
30 | IPromise Then(Action success,ErrorHandler error); |
|
30 | IPromise Then(Action success, ErrorHandler error, Action cancel); | |
|
31 | IPromise Then(Action success, ErrorHandler error); | |||
31 | IPromise Then(Action success); |
|
32 | IPromise Then(Action success); | |
|
33 | ||||
|
34 | /// <summary> | |||
|
35 | /// Добавляет последнй обработчик в цепочку обещаний, не создает промежуточных обещаний. | |||
|
36 | /// </summary> | |||
|
37 | /// <param name="success">Success.</param> | |||
|
38 | /// <param name="error">Error.</param> | |||
|
39 | /// <param name="cancel">Cancel.</param> | |||
|
40 | void Last(Action success, ErrorHandler error, Action cancel); | |||
|
41 | void Last(Action success, ErrorHandler error); | |||
|
42 | void Last(Action success); | |||
|
43 | ||||
32 | IPromise Error(ErrorHandler error); |
|
44 | IPromise Error(ErrorHandler error); | |
33 | /// <summary> |
|
45 | /// <summary> | |
34 | /// Обрабатывает либо ошибку, либо результат. Событие отмены не обрабатывается. |
|
46 | /// Обрабатывает либо ошибку, либо результат. Событие отмены не обрабатывается. | |
35 | /// </summary> |
|
47 | /// </summary> | |
36 | /// <param name="handler">Обработчик.</param> |
|
48 | /// <param name="handler">Обработчик.</param> | |
37 | /// <remarks>После обработке ошибки, она передается дальше.</remarks> |
|
49 | /// <remarks>После обработке ошибки, она передается дальше.</remarks> | |
38 | IPromise Anyway(Action handler); |
|
|||
39 |
|
||||
40 | /// <summary> |
|
50 | /// <summary> | |
41 | /// Обрабатывает либо ошибку, либо результат, либо отмену обещания. |
|
51 | /// Обрабатывает либо ошибку, либо результат, либо отмену обещания. | |
42 | /// </summary> |
|
52 | /// </summary> | |
43 | /// <param name="handler">Обработчик.</param> |
|
53 | /// <param name="handler">Обработчик.</param> | |
44 | /// <remarks>После обработке ошибки, она передается дальше.</remarks> |
|
54 | /// <remarks>После обработке ошибки, она передается дальше.</remarks> | |
45 | IPromise Finally(Action handler); |
|
55 | IPromise Finally(Action handler); | |
46 | /// <summary> |
|
56 | /// <summary> | |
47 | /// Обработчик для регистрации отмены обещания, событие отмены не может быть подавлено. |
|
57 | /// Обработчик для регистрации отмены обещания, событие отмены не может быть подавлено. | |
48 | /// </summary> |
|
58 | /// </summary> | |
49 | /// <returns>Новое обещание, связанное с текущим.</returns> |
|
59 | /// <returns>Новое обещание, связанное с текущим.</returns> | |
50 | /// <param name="handler">Обработчик события.</param> |
|
60 | /// <param name="handler">Обработчик события.</param> | |
51 | /// <remarks>Если обработчик вызывает исключение, то оно передается обработчику ошибки, результат работы |
|
61 | /// <remarks>Если обработчик вызывает исключение, то оно передается обработчику ошибки, результат работы | |
52 | /// которого будет передан связанному обещанию</remarks> |
|
62 | /// которого будет передан связанному обещанию</remarks> | |
53 | IPromise Cancelled(Action handler); |
|
63 | IPromise Cancelled(Action handler); | |
54 |
|
64 | |||
55 | /// <summary> |
|
65 | /// <summary> | |
56 | /// Преобразует результат обещания к заданному типу и возвращает новое обещание. |
|
66 | /// Преобразует результат обещания к заданному типу и возвращает новое обещание. | |
57 | /// </summary> |
|
67 | /// </summary> | |
58 | IPromise<T> Cast<T>(); |
|
68 | IPromise<T> Cast<T>(); | |
59 |
|
69 | |||
60 | /// <summary> |
|
70 | /// <summary> | |
61 | /// Синхронизирует текущий поток с обещанием. |
|
71 | /// Синхронизирует текущий поток с обещанием. | |
62 | /// </summary> |
|
72 | /// </summary> | |
63 | void Join(); |
|
73 | void Join(); | |
64 | /// <summary> |
|
74 | /// <summary> | |
65 | /// Синхронизирует текущий поток с обещанием. |
|
75 | /// Синхронизирует текущий поток с обещанием. | |
66 | /// </summary> |
|
76 | /// </summary> | |
67 | /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> |
|
77 | /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> | |
68 | /// <exception cref="TimeoutException">Превышено время ожидания.</exception> |
|
78 | /// <exception cref="TimeoutException">Превышено время ожидания.</exception> | |
69 | void Join(int timeout); |
|
79 | void Join(int timeout); | |
70 |
|
80 | |||
71 | } |
|
81 | } | |
72 | } |
|
82 | } |
@@ -1,29 +1,37 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 | using System.Text; |
|
4 | using System.Text; | |
5 |
|
5 | |||
6 | namespace Implab |
|
6 | namespace Implab { | |
7 | { |
|
7 | public interface IPromise<T>: IPromise { | |
8 | public interface IPromise<T>: IPromise |
|
|||
9 | { |
|
|||
10 |
|
8 | |||
11 | new T Join(); |
|
9 | new T Join(); | |
|
10 | ||||
12 | new T Join(int timeout); |
|
11 | new T Join(int timeout); | |
13 |
|
12 | |||
|
13 | IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error, Action cancel); | |||
|
14 | ||||
14 | IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error); |
|
15 | IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error); | |
|
16 | ||||
15 | IPromise<T> Then(ResultHandler<T> success); |
|
17 | IPromise<T> Then(ResultHandler<T> success); | |
|
18 | ||||
|
19 | void Last(ResultHandler<T> success, ErrorHandler error, Action cancel); | |||
|
20 | void Last(ResultHandler<T> success, ErrorHandler error); | |||
|
21 | void Last(ResultHandler<T> success); | |||
|
22 | ||||
16 | IPromise<T> Error(ErrorHandler<T> error); |
|
23 | IPromise<T> Error(ErrorHandler<T> error); | |
17 |
|
24 | |||
18 |
IPromise<T2> |
|
25 | IPromise<T2> Then<T2>(ResultMapper<T,T2> mapper, ErrorHandler<T> error); | |
19 | IPromise<T2> Map<T2>(ResultMapper<T, T2> mapper); |
|
26 | ||
|
27 | IPromise<T2> Then<T2>(ResultMapper<T,T2> mapper); | |||
20 |
|
28 | |||
21 |
IPromise<T2> |
|
29 | IPromise<T2> Then<T2>(ChainedOperation<T, T2> chained, ErrorHandler<T> error); | |
22 | IPromise<T2> Chain<T2>(ChainedOperation<T, T2> chained); |
|
30 | ||
|
31 | IPromise<T2> Then<T2>(ChainedOperation<T, T2> chained); | |||
23 |
|
32 | |||
24 | new IPromise<T> Cancelled(Action handler); |
|
33 | new IPromise<T> Cancelled(Action handler); | |
|
34 | ||||
25 | new IPromise<T> Finally(Action handler); |
|
35 | new IPromise<T> Finally(Action handler); | |
26 | new IPromise<T> Anyway(Action handler); |
|
|||
27 |
|
||||
28 | } |
|
36 | } | |
29 | } |
|
37 | } |
@@ -1,179 +1,198 | |||||
1 | <?xml version="1.0" encoding="utf-8"?> |
|
1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | <PropertyGroup> |
|
3 | <PropertyGroup> | |
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> |
|
6 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> | |
7 | <OutputType>Library</OutputType> |
|
7 | <OutputType>Library</OutputType> | |
8 | <RootNamespace>Implab</RootNamespace> |
|
8 | <RootNamespace>Implab</RootNamespace> | |
9 | <AssemblyName>Implab</AssemblyName> |
|
9 | <AssemblyName>Implab</AssemblyName> | |
10 | <ProductVersion>8.0.30703</ProductVersion> |
|
10 | <ProductVersion>8.0.30703</ProductVersion> | |
11 | <SchemaVersion>2.0</SchemaVersion> |
|
11 | <SchemaVersion>2.0</SchemaVersion> | |
12 | </PropertyGroup> |
|
12 | </PropertyGroup> | |
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
14 | <DebugSymbols>true</DebugSymbols> |
|
14 | <DebugSymbols>true</DebugSymbols> | |
15 | <DebugType>full</DebugType> |
|
15 | <DebugType>full</DebugType> | |
16 | <Optimize>false</Optimize> |
|
16 | <Optimize>false</Optimize> | |
17 | <OutputPath>bin\Debug</OutputPath> |
|
17 | <OutputPath>bin\Debug</OutputPath> | |
18 | <DefineConstants>TRACE;DEBUG;</DefineConstants> |
|
18 | <DefineConstants>TRACE;DEBUG;</DefineConstants> | |
19 | <ErrorReport>prompt</ErrorReport> |
|
19 | <ErrorReport>prompt</ErrorReport> | |
20 | <WarningLevel>4</WarningLevel> |
|
20 | <WarningLevel>4</WarningLevel> | |
21 | <ConsolePause>false</ConsolePause> |
|
21 | <ConsolePause>false</ConsolePause> | |
22 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
22 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
23 | </PropertyGroup> |
|
23 | </PropertyGroup> | |
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
25 | <DebugType>full</DebugType> |
|
25 | <DebugType>full</DebugType> | |
26 | <Optimize>true</Optimize> |
|
26 | <Optimize>true</Optimize> | |
27 | <OutputPath>bin\Release</OutputPath> |
|
27 | <OutputPath>bin\Release</OutputPath> | |
28 | <ErrorReport>prompt</ErrorReport> |
|
28 | <ErrorReport>prompt</ErrorReport> | |
29 | <WarningLevel>4</WarningLevel> |
|
29 | <WarningLevel>4</WarningLevel> | |
30 | <ConsolePause>false</ConsolePause> |
|
30 | <ConsolePause>false</ConsolePause> | |
31 | </PropertyGroup> |
|
31 | </PropertyGroup> | |
|
32 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |||
|
33 | <DebugSymbols>true</DebugSymbols> | |||
|
34 | <DebugType>full</DebugType> | |||
|
35 | <Optimize>false</Optimize> | |||
|
36 | <OutputPath>bin\Debug</OutputPath> | |||
|
37 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> | |||
|
38 | <ErrorReport>prompt</ErrorReport> | |||
|
39 | <WarningLevel>4</WarningLevel> | |||
|
40 | <RunCodeAnalysis>true</RunCodeAnalysis> | |||
|
41 | <ConsolePause>false</ConsolePause> | |||
|
42 | </PropertyGroup> | |||
|
43 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |||
|
44 | <Optimize>true</Optimize> | |||
|
45 | <OutputPath>bin\Release</OutputPath> | |||
|
46 | <ErrorReport>prompt</ErrorReport> | |||
|
47 | <WarningLevel>4</WarningLevel> | |||
|
48 | <ConsolePause>false</ConsolePause> | |||
|
49 | <DefineConstants>NET_4_5</DefineConstants> | |||
|
50 | </PropertyGroup> | |||
32 | <ItemGroup> |
|
51 | <ItemGroup> | |
33 | <Reference Include="System" /> |
|
52 | <Reference Include="System" /> | |
34 | <Reference Include="System.Xml" /> |
|
53 | <Reference Include="System.Xml" /> | |
35 | </ItemGroup> |
|
54 | </ItemGroup> | |
36 | <ItemGroup> |
|
55 | <ItemGroup> | |
37 | <Compile Include="Component.cs" /> |
|
56 | <Compile Include="Component.cs" /> | |
38 | <Compile Include="CustomEqualityComparer.cs" /> |
|
57 | <Compile Include="CustomEqualityComparer.cs" /> | |
39 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> |
|
58 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> | |
40 | <Compile Include="Diagnostics\EventText.cs" /> |
|
59 | <Compile Include="Diagnostics\EventText.cs" /> | |
41 | <Compile Include="Diagnostics\IEventTextFormatter.cs" /> |
|
60 | <Compile Include="Diagnostics\IEventTextFormatter.cs" /> | |
42 | <Compile Include="Diagnostics\LogChannel.cs" /> |
|
61 | <Compile Include="Diagnostics\LogChannel.cs" /> | |
43 | <Compile Include="Diagnostics\LogicalOperation.cs" /> |
|
62 | <Compile Include="Diagnostics\LogicalOperation.cs" /> | |
44 | <Compile Include="Diagnostics\TextFileListener.cs" /> |
|
63 | <Compile Include="Diagnostics\TextFileListener.cs" /> | |
45 | <Compile Include="Diagnostics\TextListenerBase.cs" /> |
|
64 | <Compile Include="Diagnostics\TextListenerBase.cs" /> | |
46 | <Compile Include="Diagnostics\TraceLog.cs" /> |
|
65 | <Compile Include="Diagnostics\TraceLog.cs" /> | |
47 | <Compile Include="Diagnostics\TraceContext.cs" /> |
|
66 | <Compile Include="Diagnostics\TraceContext.cs" /> | |
48 | <Compile Include="Diagnostics\TraceEvent.cs" /> |
|
67 | <Compile Include="Diagnostics\TraceEvent.cs" /> | |
49 | <Compile Include="Diagnostics\TraceEventType.cs" /> |
|
68 | <Compile Include="Diagnostics\TraceEventType.cs" /> | |
50 | <Compile Include="Disposable.cs" /> |
|
69 | <Compile Include="Disposable.cs" /> | |
51 | <Compile Include="ICancellable.cs" /> |
|
70 | <Compile Include="ICancellable.cs" /> | |
52 | <Compile Include="IProgressHandler.cs" /> |
|
71 | <Compile Include="IProgressHandler.cs" /> | |
53 | <Compile Include="IProgressNotifier.cs" /> |
|
72 | <Compile Include="IProgressNotifier.cs" /> | |
54 | <Compile Include="IPromiseT.cs" /> |
|
73 | <Compile Include="IPromiseT.cs" /> | |
55 | <Compile Include="IPromise.cs" /> |
|
74 | <Compile Include="IPromise.cs" /> | |
56 | <Compile Include="IServiceLocator.cs" /> |
|
75 | <Compile Include="IServiceLocator.cs" /> | |
57 | <Compile Include="ITaskController.cs" /> |
|
76 | <Compile Include="ITaskController.cs" /> | |
58 | <Compile Include="JSON\JSONElementContext.cs" /> |
|
77 | <Compile Include="JSON\JSONElementContext.cs" /> | |
59 | <Compile Include="JSON\JSONElementType.cs" /> |
|
78 | <Compile Include="JSON\JSONElementType.cs" /> | |
60 | <Compile Include="JSON\JSONGrammar.cs" /> |
|
79 | <Compile Include="JSON\JSONGrammar.cs" /> | |
61 | <Compile Include="JSON\JSONParser.cs" /> |
|
80 | <Compile Include="JSON\JSONParser.cs" /> | |
62 | <Compile Include="JSON\JSONScanner.cs" /> |
|
81 | <Compile Include="JSON\JSONScanner.cs" /> | |
63 | <Compile Include="JSON\JsonTokenType.cs" /> |
|
82 | <Compile Include="JSON\JsonTokenType.cs" /> | |
64 | <Compile Include="JSON\JSONWriter.cs" /> |
|
83 | <Compile Include="JSON\JSONWriter.cs" /> | |
65 | <Compile Include="JSON\JSONXmlReader.cs" /> |
|
84 | <Compile Include="JSON\JSONXmlReader.cs" /> | |
66 | <Compile Include="JSON\JSONXmlReaderOptions.cs" /> |
|
85 | <Compile Include="JSON\JSONXmlReaderOptions.cs" /> | |
67 | <Compile Include="JSON\StringTranslator.cs" /> |
|
86 | <Compile Include="JSON\StringTranslator.cs" /> | |
68 | <Compile Include="Parallels\DispatchPool.cs" /> |
|
87 | <Compile Include="Parallels\DispatchPool.cs" /> | |
69 | <Compile Include="Parallels\ArrayTraits.cs" /> |
|
88 | <Compile Include="Parallels\ArrayTraits.cs" /> | |
70 | <Compile Include="Parallels\MTQueue.cs" /> |
|
89 | <Compile Include="Parallels\MTQueue.cs" /> | |
71 | <Compile Include="Parallels\WorkerPool.cs" /> |
|
90 | <Compile Include="Parallels\WorkerPool.cs" /> | |
72 | <Compile Include="Parsing\Alphabet.cs" /> |
|
91 | <Compile Include="Parsing\Alphabet.cs" /> | |
73 | <Compile Include="Parsing\AlphabetBase.cs" /> |
|
92 | <Compile Include="Parsing\AlphabetBase.cs" /> | |
74 | <Compile Include="Parsing\AltToken.cs" /> |
|
93 | <Compile Include="Parsing\AltToken.cs" /> | |
75 | <Compile Include="Parsing\BinaryToken.cs" /> |
|
94 | <Compile Include="Parsing\BinaryToken.cs" /> | |
76 | <Compile Include="Parsing\CatToken.cs" /> |
|
95 | <Compile Include="Parsing\CatToken.cs" /> | |
77 | <Compile Include="Parsing\CDFADefinition.cs" /> |
|
96 | <Compile Include="Parsing\CDFADefinition.cs" /> | |
78 | <Compile Include="Parsing\DFABuilder.cs" /> |
|
97 | <Compile Include="Parsing\DFABuilder.cs" /> | |
79 | <Compile Include="Parsing\DFADefinitionBase.cs" /> |
|
98 | <Compile Include="Parsing\DFADefinitionBase.cs" /> | |
80 | <Compile Include="Parsing\DFAStateDescriptor.cs" /> |
|
99 | <Compile Include="Parsing\DFAStateDescriptor.cs" /> | |
81 | <Compile Include="Parsing\DFAutomaton.cs" /> |
|
100 | <Compile Include="Parsing\DFAutomaton.cs" /> | |
82 | <Compile Include="Parsing\EDFADefinition.cs" /> |
|
101 | <Compile Include="Parsing\EDFADefinition.cs" /> | |
83 | <Compile Include="Parsing\EmptyToken.cs" /> |
|
102 | <Compile Include="Parsing\EmptyToken.cs" /> | |
84 | <Compile Include="Parsing\EndToken.cs" /> |
|
103 | <Compile Include="Parsing\EndToken.cs" /> | |
85 | <Compile Include="Parsing\EnumAlphabet.cs" /> |
|
104 | <Compile Include="Parsing\EnumAlphabet.cs" /> | |
86 | <Compile Include="Parsing\Grammar.cs" /> |
|
105 | <Compile Include="Parsing\Grammar.cs" /> | |
87 | <Compile Include="Parsing\IAlphabet.cs" /> |
|
106 | <Compile Include="Parsing\IAlphabet.cs" /> | |
88 | <Compile Include="Parsing\IDFADefinition.cs" /> |
|
107 | <Compile Include="Parsing\IDFADefinition.cs" /> | |
89 | <Compile Include="Parsing\IVisitor.cs" /> |
|
108 | <Compile Include="Parsing\IVisitor.cs" /> | |
90 | <Compile Include="Parsing\ParserException.cs" /> |
|
109 | <Compile Include="Parsing\ParserException.cs" /> | |
91 | <Compile Include="Parsing\Scanner.cs" /> |
|
110 | <Compile Include="Parsing\Scanner.cs" /> | |
92 | <Compile Include="Parsing\StarToken.cs" /> |
|
111 | <Compile Include="Parsing\StarToken.cs" /> | |
93 | <Compile Include="Parsing\SymbolToken.cs" /> |
|
112 | <Compile Include="Parsing\SymbolToken.cs" /> | |
94 | <Compile Include="Parsing\Token.cs" /> |
|
113 | <Compile Include="Parsing\Token.cs" /> | |
95 | <Compile Include="SafePool.cs" /> |
|
114 | <Compile Include="SafePool.cs" /> | |
96 | <Compile Include="ServiceLocator.cs" /> |
|
115 | <Compile Include="ServiceLocator.cs" /> | |
97 | <Compile Include="TaskController.cs" /> |
|
116 | <Compile Include="TaskController.cs" /> | |
98 | <Compile Include="ProgressInitEventArgs.cs" /> |
|
117 | <Compile Include="ProgressInitEventArgs.cs" /> | |
99 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
118 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
100 | <Compile Include="Promise.cs" /> |
|
119 | <Compile Include="Promise.cs" /> | |
101 | <Compile Include="Parallels\AsyncPool.cs" /> |
|
120 | <Compile Include="Parallels\AsyncPool.cs" /> | |
102 | <Compile Include="Safe.cs" /> |
|
121 | <Compile Include="Safe.cs" /> | |
103 | <Compile Include="ValueEventArgs.cs" /> |
|
122 | <Compile Include="ValueEventArgs.cs" /> | |
104 | <Compile Include="PromiseExtensions.cs" /> |
|
123 | <Compile Include="PromiseExtensions.cs" /> | |
105 | <Compile Include="TransientPromiseException.cs" /> |
|
124 | <Compile Include="TransientPromiseException.cs" /> | |
106 | <Compile Include="SyncContextPromise.cs" /> |
|
125 | <Compile Include="SyncContextPromise.cs" /> | |
107 | </ItemGroup> |
|
126 | </ItemGroup> | |
108 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
127 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
109 | <ItemGroup /> |
|
128 | <ItemGroup /> | |
110 | <ProjectExtensions> |
|
129 | <ProjectExtensions> | |
111 | <MonoDevelop> |
|
130 | <MonoDevelop> | |
112 | <Properties> |
|
131 | <Properties> | |
113 | <Policies> |
|
132 | <Policies> | |
114 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> |
|
133 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> | |
115 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> |
|
134 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> | |
116 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> |
|
135 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> | |
117 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> |
|
136 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> | |
118 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> |
|
137 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> | |
119 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> |
|
138 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> | |
120 | <NameConventionPolicy> |
|
139 | <NameConventionPolicy> | |
121 | <Rules> |
|
140 | <Rules> | |
122 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
141 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
123 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
142 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
124 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
143 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
125 | <RequiredPrefixes> |
|
144 | <RequiredPrefixes> | |
126 | <String>I</String> |
|
145 | <String>I</String> | |
127 | </RequiredPrefixes> |
|
146 | </RequiredPrefixes> | |
128 | </NamingRule> |
|
147 | </NamingRule> | |
129 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
148 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
130 | <RequiredSuffixes> |
|
149 | <RequiredSuffixes> | |
131 | <String>Attribute</String> |
|
150 | <String>Attribute</String> | |
132 | </RequiredSuffixes> |
|
151 | </RequiredSuffixes> | |
133 | </NamingRule> |
|
152 | </NamingRule> | |
134 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
153 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
135 | <RequiredSuffixes> |
|
154 | <RequiredSuffixes> | |
136 | <String>EventArgs</String> |
|
155 | <String>EventArgs</String> | |
137 | </RequiredSuffixes> |
|
156 | </RequiredSuffixes> | |
138 | </NamingRule> |
|
157 | </NamingRule> | |
139 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
158 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
140 | <RequiredSuffixes> |
|
159 | <RequiredSuffixes> | |
141 | <String>Exception</String> |
|
160 | <String>Exception</String> | |
142 | </RequiredSuffixes> |
|
161 | </RequiredSuffixes> | |
143 | </NamingRule> |
|
162 | </NamingRule> | |
144 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
163 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
145 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> |
|
164 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> | |
146 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
165 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
147 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> |
|
166 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> | |
148 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
167 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
149 | <RequiredPrefixes> |
|
168 | <RequiredPrefixes> | |
150 | <String>m_</String> |
|
169 | <String>m_</String> | |
151 | </RequiredPrefixes> |
|
170 | </RequiredPrefixes> | |
152 | </NamingRule> |
|
171 | </NamingRule> | |
153 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> |
|
172 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> | |
154 | <RequiredPrefixes> |
|
173 | <RequiredPrefixes> | |
155 | <String>_</String> |
|
174 | <String>_</String> | |
156 | </RequiredPrefixes> |
|
175 | </RequiredPrefixes> | |
157 | </NamingRule> |
|
176 | </NamingRule> | |
158 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
177 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
159 | <RequiredPrefixes> |
|
178 | <RequiredPrefixes> | |
160 | <String>m_</String> |
|
179 | <String>m_</String> | |
161 | </RequiredPrefixes> |
|
180 | </RequiredPrefixes> | |
162 | </NamingRule> |
|
181 | </NamingRule> | |
163 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
182 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
164 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
183 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
165 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
184 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
166 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
185 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
167 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
186 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
168 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
187 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
169 | <RequiredPrefixes> |
|
188 | <RequiredPrefixes> | |
170 | <String>T</String> |
|
189 | <String>T</String> | |
171 | </RequiredPrefixes> |
|
190 | </RequiredPrefixes> | |
172 | </NamingRule> |
|
191 | </NamingRule> | |
173 | </Rules> |
|
192 | </Rules> | |
174 | </NameConventionPolicy> |
|
193 | </NameConventionPolicy> | |
175 | </Policies> |
|
194 | </Policies> | |
176 | </Properties> |
|
195 | </Properties> | |
177 | </MonoDevelop> |
|
196 | </MonoDevelop> | |
178 | </ProjectExtensions> |
|
197 | </ProjectExtensions> | |
179 | </Project> No newline at end of file |
|
198 | </Project> |
@@ -1,194 +1,193 | |||||
1 | using Implab.Diagnostics; |
|
1 | using Implab.Diagnostics; | |
2 | using System; |
|
2 | using System; | |
3 | using System.Collections.Generic; |
|
3 | using System.Collections.Generic; | |
4 | using System.Diagnostics; |
|
4 | using System.Diagnostics; | |
5 | using System.Linq; |
|
5 | using System.Linq; | |
6 | using System.Text; |
|
6 | using System.Text; | |
7 | using System.Threading; |
|
7 | using System.Threading; | |
8 |
|
8 | |||
9 | namespace Implab.Parallels { |
|
9 | namespace Implab.Parallels { | |
10 | public static class ArrayTraits { |
|
10 | public static class ArrayTraits { | |
11 | class ArrayIterator<TSrc> : DispatchPool<int> { |
|
11 | class ArrayIterator<TSrc> : DispatchPool<int> { | |
12 | readonly Action<TSrc> m_action; |
|
12 | readonly Action<TSrc> m_action; | |
13 | readonly TSrc[] m_source; |
|
13 | readonly TSrc[] m_source; | |
14 | readonly Promise<int> m_promise = new Promise<int>(); |
|
14 | readonly Promise<int> m_promise = new Promise<int>(); | |
15 | readonly TraceContext m_traceContext; |
|
15 | readonly TraceContext m_traceContext; | |
16 |
|
16 | |||
17 | int m_pending; |
|
17 | int m_pending; | |
18 | int m_next; |
|
18 | int m_next; | |
19 |
|
19 | |||
20 | public ArrayIterator(TSrc[] source, Action<TSrc> action, int threads) |
|
20 | public ArrayIterator(TSrc[] source, Action<TSrc> action, int threads) | |
21 | : base(threads) { |
|
21 | : base(threads) { | |
22 |
|
22 | |||
23 | Debug.Assert(source != null); |
|
23 | Debug.Assert(source != null); | |
24 | Debug.Assert(action != null); |
|
24 | Debug.Assert(action != null); | |
25 |
|
25 | |||
26 | m_traceContext = TraceContext.Snapshot(); |
|
26 | m_traceContext = TraceContext.Snapshot(); | |
27 | m_next = 0; |
|
27 | m_next = 0; | |
28 | m_source = source; |
|
28 | m_source = source; | |
29 | m_pending = source.Length; |
|
29 | m_pending = source.Length; | |
30 | m_action = action; |
|
30 | m_action = action; | |
31 |
|
31 | |||
32 |
m_promise. |
|
32 | m_promise.Finally(Dispose); | |
33 | m_promise.Cancelled(() => Dispose()); |
|
|||
34 |
|
33 | |||
35 | InitPool(); |
|
34 | InitPool(); | |
36 | } |
|
35 | } | |
37 |
|
36 | |||
38 | public Promise<int> Promise { |
|
37 | public Promise<int> Promise { | |
39 | get { |
|
38 | get { | |
40 | return m_promise; |
|
39 | return m_promise; | |
41 | } |
|
40 | } | |
42 | } |
|
41 | } | |
43 |
|
42 | |||
44 | protected override void Worker() { |
|
43 | protected override void Worker() { | |
45 | TraceContext.Fork(m_traceContext); |
|
44 | TraceContext.Fork(m_traceContext); | |
46 | base.Worker(); |
|
45 | base.Worker(); | |
47 | } |
|
46 | } | |
48 |
|
47 | |||
49 | protected override bool TryDequeue(out int unit) { |
|
48 | protected override bool TryDequeue(out int unit) { | |
50 | unit = Interlocked.Increment(ref m_next) - 1; |
|
49 | unit = Interlocked.Increment(ref m_next) - 1; | |
51 |
return unit |
|
50 | return unit < m_source.Length; | |
52 | } |
|
51 | } | |
53 |
|
52 | |||
54 | protected override void InvokeUnit(int unit) { |
|
53 | protected override void InvokeUnit(int unit) { | |
55 | try { |
|
54 | try { | |
56 | m_action(m_source[unit]); |
|
55 | m_action(m_source[unit]); | |
57 | var pending = Interlocked.Decrement(ref m_pending); |
|
56 | var pending = Interlocked.Decrement(ref m_pending); | |
58 | if (pending == 0) |
|
57 | if (pending == 0) | |
59 | m_promise.Resolve(m_source.Length); |
|
58 | m_promise.Resolve(m_source.Length); | |
60 | } catch (Exception e) { |
|
59 | } catch (Exception e) { | |
61 | m_promise.Reject(e); |
|
60 | m_promise.Reject(e); | |
62 | } |
|
61 | } | |
63 | } |
|
62 | } | |
64 | } |
|
63 | } | |
65 |
|
64 | |||
66 | class ArrayMapper<TSrc, TDst>: DispatchPool<int> { |
|
65 | class ArrayMapper<TSrc, TDst>: DispatchPool<int> { | |
67 | readonly Func<TSrc, TDst> m_transform; |
|
66 | readonly Func<TSrc, TDst> m_transform; | |
68 | readonly TSrc[] m_source; |
|
67 | readonly TSrc[] m_source; | |
69 | readonly TDst[] m_dest; |
|
68 | readonly TDst[] m_dest; | |
70 | readonly Promise<TDst[]> m_promise = new Promise<TDst[]>(); |
|
69 | readonly Promise<TDst[]> m_promise = new Promise<TDst[]>(); | |
71 | readonly TraceContext m_traceContext; |
|
70 | readonly TraceContext m_traceContext; | |
72 |
|
71 | |||
73 | int m_pending; |
|
72 | int m_pending; | |
74 | int m_next; |
|
73 | int m_next; | |
75 |
|
74 | |||
76 | public ArrayMapper(TSrc[] source, Func<TSrc, TDst> transform, int threads) |
|
75 | public ArrayMapper(TSrc[] source, Func<TSrc, TDst> transform, int threads) | |
77 | : base(threads) { |
|
76 | : base(threads) { | |
78 |
|
77 | |||
79 | Debug.Assert (source != null); |
|
78 | Debug.Assert (source != null); | |
80 | Debug.Assert( transform != null); |
|
79 | Debug.Assert( transform != null); | |
81 |
|
80 | |||
82 | m_next = 0; |
|
81 | m_next = 0; | |
83 | m_source = source; |
|
82 | m_source = source; | |
84 | m_dest = new TDst[source.Length]; |
|
83 | m_dest = new TDst[source.Length]; | |
85 | m_pending = source.Length; |
|
84 | m_pending = source.Length; | |
86 | m_transform = transform; |
|
85 | m_transform = transform; | |
87 | m_traceContext = TraceContext.Snapshot(); |
|
86 | m_traceContext = TraceContext.Snapshot(); | |
88 |
|
87 | |||
89 |
m_promise. |
|
88 | m_promise.Finally(Dispose); | |
90 | m_promise.Cancelled(() => Dispose()); |
|
|||
91 |
|
89 | |||
92 | InitPool(); |
|
90 | InitPool(); | |
93 | } |
|
91 | } | |
94 |
|
92 | |||
95 | public Promise<TDst[]> Promise { |
|
93 | public Promise<TDst[]> Promise { | |
96 | get { |
|
94 | get { | |
97 | return m_promise; |
|
95 | return m_promise; | |
98 | } |
|
96 | } | |
99 | } |
|
97 | } | |
100 |
|
98 | |||
101 | protected override void Worker() { |
|
99 | protected override void Worker() { | |
102 | TraceContext.Fork(m_traceContext); |
|
100 | TraceContext.Fork(m_traceContext); | |
103 | base.Worker(); |
|
101 | base.Worker(); | |
104 | } |
|
102 | } | |
105 |
|
103 | |||
106 | protected override bool TryDequeue(out int unit) { |
|
104 | protected override bool TryDequeue(out int unit) { | |
107 | unit = Interlocked.Increment(ref m_next) - 1; |
|
105 | unit = Interlocked.Increment(ref m_next) - 1; | |
108 | return unit >= m_source.Length ? false : true; |
|
106 | return unit >= m_source.Length ? false : true; | |
109 | } |
|
107 | } | |
110 |
|
108 | |||
111 | protected override void InvokeUnit(int unit) { |
|
109 | protected override void InvokeUnit(int unit) { | |
112 | try { |
|
110 | try { | |
113 | m_dest[unit] = m_transform(m_source[unit]); |
|
111 | m_dest[unit] = m_transform(m_source[unit]); | |
114 | var pending = Interlocked.Decrement(ref m_pending); |
|
112 | var pending = Interlocked.Decrement(ref m_pending); | |
115 | if (pending == 0) |
|
113 | if (pending == 0) | |
116 | m_promise.Resolve(m_dest); |
|
114 | m_promise.Resolve(m_dest); | |
117 | } catch (Exception e) { |
|
115 | } catch (Exception e) { | |
118 | m_promise.Reject(e); |
|
116 | m_promise.Reject(e); | |
119 | } |
|
117 | } | |
120 | } |
|
118 | } | |
121 | } |
|
119 | } | |
122 |
|
120 | |||
123 | public static IPromise<TDst[]> ParallelMap<TSrc, TDst> (this TSrc[] source, Func<TSrc,TDst> transform, int threads) { |
|
121 | public static IPromise<TDst[]> ParallelMap<TSrc, TDst> (this TSrc[] source, Func<TSrc,TDst> transform, int threads) { | |
124 | if (source == null) |
|
122 | if (source == null) | |
125 | throw new ArgumentNullException("source"); |
|
123 | throw new ArgumentNullException("source"); | |
126 | if (transform == null) |
|
124 | if (transform == null) | |
127 | throw new ArgumentNullException("transform"); |
|
125 | throw new ArgumentNullException("transform"); | |
128 |
|
126 | |||
129 | var mapper = new ArrayMapper<TSrc, TDst>(source, transform, threads); |
|
127 | var mapper = new ArrayMapper<TSrc, TDst>(source, transform, threads); | |
130 | return mapper.Promise; |
|
128 | return mapper.Promise; | |
131 | } |
|
129 | } | |
132 |
|
130 | |||
133 | public static IPromise<int> ParallelForEach<TSrc>(this TSrc[] source, Action<TSrc> action, int threads) { |
|
131 | public static IPromise<int> ParallelForEach<TSrc>(this TSrc[] source, Action<TSrc> action, int threads) { | |
134 | if (source == null) |
|
132 | if (source == null) | |
135 | throw new ArgumentNullException("source"); |
|
133 | throw new ArgumentNullException("source"); | |
136 | if (action == null) |
|
134 | if (action == null) | |
137 | throw new ArgumentNullException("action"); |
|
135 | throw new ArgumentNullException("action"); | |
138 |
|
136 | |||
139 | var iter = new ArrayIterator<TSrc>(source, action, threads); |
|
137 | var iter = new ArrayIterator<TSrc>(source, action, threads); | |
140 | return iter.Promise; |
|
138 | return iter.Promise; | |
141 | } |
|
139 | } | |
142 |
|
140 | |||
143 | public static IPromise<TDst[]> ChainedMap<TSrc, TDst>(this TSrc[] source, ChainedOperation<TSrc, TDst> transform, int threads) { |
|
141 | public static IPromise<TDst[]> ChainedMap<TSrc, TDst>(this TSrc[] source, ChainedOperation<TSrc, TDst> transform, int threads) { | |
144 | if (source == null) |
|
142 | if (source == null) | |
145 | throw new ArgumentNullException("source"); |
|
143 | throw new ArgumentNullException("source"); | |
146 | if (transform == null) |
|
144 | if (transform == null) | |
147 | throw new ArgumentNullException("transform"); |
|
145 | throw new ArgumentNullException("transform"); | |
148 | if (threads <= 0) |
|
146 | if (threads <= 0) | |
149 | throw new ArgumentOutOfRangeException("Threads number must be greater then zero"); |
|
147 | throw new ArgumentOutOfRangeException("Threads number must be greater then zero"); | |
150 |
|
148 | |||
151 | if (source.Length == 0) |
|
149 | if (source.Length == 0) | |
152 | return Promise<TDst[]>.ResultToPromise(new TDst[0]); |
|
150 | return Promise<TDst[]>.ResultToPromise(new TDst[0]); | |
153 |
|
151 | |||
154 | var promise = new Promise<TDst[]>(); |
|
152 | var promise = new Promise<TDst[]>(); | |
155 | var res = new TDst[source.Length]; |
|
153 | var res = new TDst[source.Length]; | |
156 | var pending = source.Length; |
|
154 | var pending = source.Length; | |
157 |
|
155 | |||
158 | var semaphore = new Semaphore(threads, threads); |
|
156 | var semaphore = new Semaphore(threads, threads); | |
159 |
|
157 | |||
|
158 | // Analysis disable AccessToDisposedClosure | |||
160 | AsyncPool.InvokeNewThread(() => { |
|
159 | AsyncPool.InvokeNewThread(() => { | |
161 | for (int i = 0; i < source.Length; i++) { |
|
160 | for (int i = 0; i < source.Length; i++) { | |
162 | if(promise.IsResolved) |
|
161 | if(promise.IsResolved) | |
163 | break; // stop processing in case of error or cancellation |
|
162 | break; // stop processing in case of error or cancellation | |
164 | var idx = i; |
|
163 | var idx = i; | |
|
164 | ||||
165 | semaphore.WaitOne(); |
|
165 | semaphore.WaitOne(); | |
166 | try { |
|
166 | try { | |
167 | var p1 = transform(source[i]); |
|
167 | var p1 = transform(source[i]); | |
168 |
p1. |
|
168 | p1.Finally(() => semaphore.Release()); | |
169 | p1.Cancelled(() => semaphore.Release()); |
|
|||
170 | p1.Then( |
|
169 | p1.Then( | |
171 | x => { |
|
170 | x => { | |
172 | res[idx] = x; |
|
171 | res[idx] = x; | |
173 | var left = Interlocked.Decrement(ref pending); |
|
172 | var left = Interlocked.Decrement(ref pending); | |
174 | if (left == 0) |
|
173 | if (left == 0) | |
175 | promise.Resolve(res); |
|
174 | promise.Resolve(res); | |
176 | }, |
|
175 | }, | |
177 | e => { |
|
176 | e => { | |
178 | promise.Reject(e); |
|
177 | promise.Reject(e); | |
179 | throw new TransientPromiseException(e); |
|
178 | throw new TransientPromiseException(e); | |
180 | } |
|
179 | } | |
181 | ); |
|
180 | ); | |
182 |
|
181 | |||
183 | } catch (Exception e) { |
|
182 | } catch (Exception e) { | |
184 | promise.Reject(e); |
|
183 | promise.Reject(e); | |
185 | } |
|
184 | } | |
186 | } |
|
185 | } | |
187 | return 0; |
|
186 | return 0; | |
188 | }); |
|
187 | }); | |
189 |
|
188 | |||
190 |
return promise. |
|
189 | return promise.Finally(semaphore.Dispose); | |
191 | } |
|
190 | } | |
192 |
|
191 | |||
193 | } |
|
192 | } | |
194 | } |
|
193 | } |
@@ -1,732 +1,764 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Reflection; |
|
3 | using System.Reflection; | |
4 | using System.Diagnostics; |
|
4 | using System.Diagnostics; | |
5 | using System.Threading; |
|
5 | using System.Threading; | |
6 | using Implab.Parallels; |
|
6 | using Implab.Parallels; | |
7 |
|
7 | |||
8 | namespace Implab { |
|
8 | namespace Implab { | |
9 |
|
9 | |||
10 | public delegate void ErrorHandler(Exception e); |
|
10 | public delegate void ErrorHandler(Exception e); | |
11 | public delegate T ErrorHandler<out T>(Exception e); |
|
11 | public delegate T ErrorHandler<out T>(Exception e); | |
12 | public delegate void ResultHandler<in T>(T result); |
|
12 | public delegate void ResultHandler<in T>(T result); | |
13 | public delegate TNew ResultMapper<in TSrc,out TNew>(TSrc result); |
|
13 | public delegate TNew ResultMapper<in TSrc,out TNew>(TSrc result); | |
14 | public delegate IPromise<TNew> ChainedOperation<in TSrc,TNew>(TSrc result); |
|
14 | public delegate IPromise<TNew> ChainedOperation<in TSrc,TNew>(TSrc result); | |
15 |
|
15 | |||
16 | /// <summary> |
|
16 | /// <summary> | |
17 | /// Класс для асинхронного получения результатов. Так называемое "обещание". |
|
17 | /// Класс для асинхронного получения результатов. Так называемое "обещание". | |
18 | /// </summary> |
|
18 | /// </summary> | |
19 | /// <typeparam name="T">Тип получаемого результата</typeparam> |
|
19 | /// <typeparam name="T">Тип получаемого результата</typeparam> | |
20 | /// <remarks> |
|
20 | /// <remarks> | |
21 | /// <para>Сервис при обращении к его методу дает обещаиние о выполнении операции, |
|
21 | /// <para>Сервис при обращении к его методу дает обещаиние о выполнении операции, | |
22 | /// клиент получив такое обещание может установить ряд обратных вызово для получения |
|
22 | /// клиент получив такое обещание может установить ряд обратных вызово для получения | |
23 | /// событий выполнения обещания, тоесть завершения операции и предоставлении результатов.</para> |
|
23 | /// событий выполнения обещания, тоесть завершения операции и предоставлении результатов.</para> | |
24 | /// <para> |
|
24 | /// <para> | |
25 | /// Обещение может быть как выполнено, так и выполнено с ошибкой. Для подписки на |
|
25 | /// Обещение может быть как выполнено, так и выполнено с ошибкой. Для подписки на | |
26 | /// данные события клиент должен использовать методы <c>Then</c>. |
|
26 | /// данные события клиент должен использовать методы <c>Then</c>. | |
27 | /// </para> |
|
27 | /// </para> | |
28 | /// <para> |
|
28 | /// <para> | |
29 | /// Сервис, в свою очередь, по окончанию выполнения операции (возможно с ошибкой), |
|
29 | /// Сервис, в свою очередь, по окончанию выполнения операции (возможно с ошибкой), | |
30 | /// использует методы <c>Resolve</c> либо <c>Reject</c> для оповещения клиетна о |
|
30 | /// использует методы <c>Resolve</c> либо <c>Reject</c> для оповещения клиетна о | |
31 | /// выполнении обещания. |
|
31 | /// выполнении обещания. | |
32 | /// </para> |
|
32 | /// </para> | |
33 | /// <para> |
|
33 | /// <para> | |
34 | /// Если сервер успел выполнить обещание еще до того, как клиент на него подписался, |
|
34 | /// Если сервер успел выполнить обещание еще до того, как клиент на него подписался, | |
35 | /// то в момент подписки клиента будут вызваны соответсвующие события в синхронном |
|
35 | /// то в момент подписки клиента будут вызваны соответсвующие события в синхронном | |
36 | /// режиме и клиент будет оповещен в любом случае. Иначе, обработчики добавляются в |
|
36 | /// режиме и клиент будет оповещен в любом случае. Иначе, обработчики добавляются в | |
37 | /// список в порядке подписания и в этом же порядке они будут вызваны при выполнении |
|
37 | /// список в порядке подписания и в этом же порядке они будут вызваны при выполнении | |
38 | /// обещания. |
|
38 | /// обещания. | |
39 | /// </para> |
|
39 | /// </para> | |
40 | /// <para> |
|
40 | /// <para> | |
41 | /// Обрабатывая результаты обещания можно преобразовывать результаты либо инициировать |
|
41 | /// Обрабатывая результаты обещания можно преобразовывать результаты либо инициировать | |
42 | /// связанные асинхронные операции, которые также возвращают обещания. Для этого следует |
|
42 | /// связанные асинхронные операции, которые также возвращают обещания. Для этого следует | |
43 | /// использовать соответствующую форму методе <c>Then</c>. |
|
43 | /// использовать соответствующую форму методе <c>Then</c>. | |
44 | /// </para> |
|
44 | /// </para> | |
45 | /// <para> |
|
45 | /// <para> | |
46 | /// Также хорошим правилом является то, что <c>Resolve</c> и <c>Reject</c> должен вызывать |
|
46 | /// Также хорошим правилом является то, что <c>Resolve</c> и <c>Reject</c> должен вызывать | |
47 | /// только инициатор обещания иначе могут возникнуть противоречия. |
|
47 | /// только инициатор обещания иначе могут возникнуть противоречия. | |
48 | /// </para> |
|
48 | /// </para> | |
49 | /// </remarks> |
|
49 | /// </remarks> | |
50 | public class Promise<T> : IPromise<T> { |
|
50 | public class Promise<T> : IPromise<T> { | |
51 |
|
51 | |||
52 | protected struct HandlerDescriptor { |
|
52 | protected struct HandlerDescriptor { | |
53 | public ResultHandler<T> resultHandler; |
|
53 | public ResultHandler<T> resultHandler; | |
54 | public ErrorHandler<T> errorHandler; |
|
54 | public ErrorHandler<T> errorHandler; | |
55 | public Action cancellHandler; |
|
55 | public Action cancellHandler; | |
56 | public Promise<T> medium; |
|
56 | public Promise<T> medium; | |
57 |
|
57 | |||
58 | public void Resolve(T result) { |
|
58 | public void Resolve(T result) { | |
59 | if (resultHandler != null) { |
|
59 | if (resultHandler != null) { | |
60 | try { |
|
60 | try { | |
61 | resultHandler(result); |
|
61 | resultHandler(result); | |
62 | } catch (Exception e) { |
|
62 | } catch (Exception e) { | |
63 | Reject(e); |
|
63 | Reject(e); | |
64 | return; |
|
64 | return; | |
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 | if (medium != null) |
|
67 | if (medium != null) | |
68 | medium.Resolve(result); |
|
68 | medium.Resolve(result); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | public void Reject(Exception err) { |
|
71 | public void Reject(Exception err) { | |
72 | if (errorHandler != null) { |
|
72 | if (errorHandler != null) { | |
73 | try { |
|
73 | try { | |
74 | var res = errorHandler(err); |
|
74 | var res = errorHandler(err); | |
75 | if (medium != null) |
|
75 | if (medium != null) | |
76 | medium.Resolve(res); |
|
76 | medium.Resolve(res); | |
77 | } catch (TransientPromiseException err2) { |
|
77 | } catch (TransientPromiseException err2) { | |
78 | if (medium != null) |
|
78 | if (medium != null) | |
79 | medium.Reject(err2.InnerException); |
|
79 | medium.Reject(err2.InnerException); | |
80 | } catch (Exception err2) { |
|
80 | } catch (Exception err2) { | |
81 | if (medium != null) |
|
81 | if (medium != null) | |
82 | medium.Reject(err2); |
|
82 | medium.Reject(err2); | |
83 | } |
|
83 | } | |
84 | } else if (medium != null) |
|
84 | } else if (medium != null) | |
85 | medium.Reject(err); |
|
85 | medium.Reject(err); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | public void Cancel() { |
|
88 | public void Cancel() { | |
89 | if (cancellHandler != null) { |
|
89 | if (cancellHandler != null) { | |
90 | try { |
|
90 | try { | |
91 | cancellHandler(); |
|
91 | cancellHandler(); | |
92 | } catch (Exception err) { |
|
92 | } catch (Exception err) { | |
93 | Reject(err); |
|
93 | Reject(err); | |
94 | return; |
|
94 | return; | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } | |
97 | if (medium != null) |
|
97 | if (medium != null) | |
98 | medium.Cancel(); |
|
98 | medium.Cancel(); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | const int UNRESOLVED_SATE = 0; |
|
102 | const int UNRESOLVED_SATE = 0; | |
103 | const int TRANSITIONAL_STATE = 1; |
|
103 | const int TRANSITIONAL_STATE = 1; | |
104 | const int SUCCEEDED_STATE = 2; |
|
104 | const int SUCCEEDED_STATE = 2; | |
105 | const int REJECTED_STATE = 3; |
|
105 | const int REJECTED_STATE = 3; | |
106 | const int CANCELLED_STATE = 4; |
|
106 | const int CANCELLED_STATE = 4; | |
107 |
|
107 | |||
108 | readonly bool m_cancellable; |
|
108 | readonly bool m_cancellable; | |
109 |
|
109 | |||
110 | int m_childrenCount = 0; |
|
110 | int m_childrenCount = 0; | |
111 | int m_state; |
|
111 | int m_state; | |
112 | T m_result; |
|
112 | T m_result; | |
113 | Exception m_error; |
|
113 | Exception m_error; | |
114 |
|
114 | |||
115 | readonly MTQueue<HandlerDescriptor> m_handlers = new MTQueue<HandlerDescriptor>(); |
|
115 | readonly MTQueue<HandlerDescriptor> m_handlers = new MTQueue<HandlerDescriptor>(); | |
116 |
|
116 | |||
117 | public Promise() { |
|
117 | public Promise() { | |
118 | m_cancellable = true; |
|
118 | m_cancellable = true; | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | public Promise(IPromise parent, bool cancellable) { |
|
121 | public Promise(IPromise parent, bool cancellable) { | |
122 | m_cancellable = cancellable; |
|
122 | m_cancellable = cancellable; | |
123 | if (parent != null) |
|
123 | if (parent != null) | |
124 | Cancelled(() => { |
|
124 | Cancelled(() => { | |
125 | if (parent.IsExclusive) |
|
125 | if (parent.IsExclusive) | |
126 | parent.Cancel(); |
|
126 | parent.Cancel(); | |
127 | }); |
|
127 | }); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | bool BeginTransit() { |
|
130 | bool BeginTransit() { | |
131 | return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE); |
|
131 | return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE); | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | void CompleteTransit(int state) { |
|
134 | void CompleteTransit(int state) { | |
135 | if (TRANSITIONAL_STATE != Interlocked.CompareExchange(ref m_state, state, TRANSITIONAL_STATE)) |
|
135 | if (TRANSITIONAL_STATE != Interlocked.CompareExchange(ref m_state, state, TRANSITIONAL_STATE)) | |
136 | throw new InvalidOperationException("Can't complete transition when the object isn't in the transitional state"); |
|
136 | throw new InvalidOperationException("Can't complete transition when the object isn't in the transitional state"); | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | void WaitTransition() { |
|
139 | void WaitTransition() { | |
140 | while (m_state == TRANSITIONAL_STATE) { |
|
140 | while (m_state == TRANSITIONAL_STATE) { | |
141 | /* noop */ |
|
141 | /* noop */ | |
142 | } |
|
142 | } | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | public bool IsResolved { |
|
145 | public bool IsResolved { | |
146 | get { |
|
146 | get { | |
147 | return m_state > 1; |
|
147 | return m_state > 1; | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | public bool IsCancelled { |
|
151 | public bool IsCancelled { | |
152 | get { |
|
152 | get { | |
153 | return m_state == CANCELLED_STATE; |
|
153 | return m_state == CANCELLED_STATE; | |
154 | } |
|
154 | } | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | public Type PromiseType { |
|
157 | public Type PromiseType { | |
158 | get { return typeof(T); } |
|
158 | get { return typeof(T); } | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | /// <summary> |
|
161 | /// <summary> | |
162 | /// Выполняет обещание, сообщая об успешном выполнении. |
|
162 | /// Выполняет обещание, сообщая об успешном выполнении. | |
163 | /// </summary> |
|
163 | /// </summary> | |
164 | /// <param name="result">Результат выполнения.</param> |
|
164 | /// <param name="result">Результат выполнения.</param> | |
165 | /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception> |
|
165 | /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception> | |
166 | public void Resolve(T result) { |
|
166 | public void Resolve(T result) { | |
167 | if (BeginTransit()) { |
|
167 | if (BeginTransit()) { | |
168 | m_result = result; |
|
168 | m_result = result; | |
169 | CompleteTransit(SUCCEEDED_STATE); |
|
169 | CompleteTransit(SUCCEEDED_STATE); | |
170 | OnStateChanged(); |
|
170 | OnStateChanged(); | |
171 | } else { |
|
171 | } else { | |
172 | WaitTransition(); |
|
172 | WaitTransition(); | |
173 | if (m_state != CANCELLED_STATE) |
|
173 | if (m_state != CANCELLED_STATE) | |
174 | throw new InvalidOperationException("The promise is already resolved"); |
|
174 | throw new InvalidOperationException("The promise is already resolved"); | |
175 | } |
|
175 | } | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | /// <summary> |
|
178 | /// <summary> | |
179 | /// Выполняет обещание, сообщая об успешном выполнении. Результатом выполнения будет пустое значения. |
|
179 | /// Выполняет обещание, сообщая об успешном выполнении. Результатом выполнения будет пустое значения. | |
180 | /// </summary> |
|
180 | /// </summary> | |
181 | /// <remarks> |
|
181 | /// <remarks> | |
182 | /// Данный вариант удобен в случаях, когда интересен факт выполнения операции, нежели полученное значение. |
|
182 | /// Данный вариант удобен в случаях, когда интересен факт выполнения операции, нежели полученное значение. | |
183 | /// </remarks> |
|
183 | /// </remarks> | |
184 | public void Resolve() { |
|
184 | public void Resolve() { | |
185 | Resolve(default(T)); |
|
185 | Resolve(default(T)); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | /// <summary> |
|
188 | /// <summary> | |
189 | /// Выполняет обещание, сообщая об ошибке |
|
189 | /// Выполняет обещание, сообщая об ошибке | |
190 | /// </summary> |
|
190 | /// </summary> | |
191 | /// <remarks> |
|
191 | /// <remarks> | |
192 | /// Поскольку обещание должно работать в многопточной среде, при его выполнении сразу несколько потоков |
|
192 | /// Поскольку обещание должно работать в многопточной среде, при его выполнении сразу несколько потоков | |
193 | /// могу вернуть ошибку, при этом только первая будет использована в качестве результата, остальные |
|
193 | /// могу вернуть ошибку, при этом только первая будет использована в качестве результата, остальные | |
194 | /// будут проигнорированы. |
|
194 | /// будут проигнорированы. | |
195 | /// </remarks> |
|
195 | /// </remarks> | |
196 | /// <param name="error">Исключение возникшее при выполнении операции</param> |
|
196 | /// <param name="error">Исключение возникшее при выполнении операции</param> | |
197 | /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception> |
|
197 | /// <exception cref="InvalidOperationException">Данное обещание уже выполнено</exception> | |
198 | public void Reject(Exception error) { |
|
198 | public void Reject(Exception error) { | |
199 | if (BeginTransit()) { |
|
199 | if (BeginTransit()) { | |
200 | m_error = error; |
|
200 | m_error = error; | |
201 | CompleteTransit(REJECTED_STATE); |
|
201 | CompleteTransit(REJECTED_STATE); | |
202 | OnStateChanged(); |
|
202 | OnStateChanged(); | |
203 | } else { |
|
203 | } else { | |
204 | WaitTransition(); |
|
204 | WaitTransition(); | |
205 | if (m_state == SUCCEEDED_STATE) |
|
205 | if (m_state == SUCCEEDED_STATE) | |
206 | throw new InvalidOperationException("The promise is already resolved"); |
|
206 | throw new InvalidOperationException("The promise is already resolved"); | |
207 | } |
|
207 | } | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | /// <summary> |
|
210 | /// <summary> | |
211 | /// Отменяет операцию, если это возможно. |
|
211 | /// Отменяет операцию, если это возможно. | |
212 | /// </summary> |
|
212 | /// </summary> | |
213 | /// <returns><c>true</c> Операция была отменена, обработчики не будут вызваны.<c>false</c> отмена не возможна, поскольку обещание уже выполнено и обработчики отработали.</returns> |
|
213 | /// <returns><c>true</c> Операция была отменена, обработчики не будут вызваны.<c>false</c> отмена не возможна, поскольку обещание уже выполнено и обработчики отработали.</returns> | |
214 | public bool Cancel() { |
|
214 | public bool Cancel() { | |
215 | if (m_cancellable && BeginTransit()) { |
|
215 | if (m_cancellable && BeginTransit()) { | |
216 | CompleteTransit(CANCELLED_STATE); |
|
216 | CompleteTransit(CANCELLED_STATE); | |
217 | OnStateChanged(); |
|
217 | OnStateChanged(); | |
218 | return true; |
|
218 | return true; | |
219 | } |
|
219 | } | |
220 | return false; |
|
220 | return false; | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | // сделано для возвращаемого типа void |
|
223 | // сделано для возвращаемого типа void | |
224 | protected void InternalCancel() { |
|
224 | protected void InternalCancel() { | |
225 | Cancel(); |
|
225 | Cancel(); | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
|
228 | ||||
|
229 | public IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error, Action cancel) { | |||
|
230 | if (success == null && error == null && cancel == null) | |||
|
231 | return this; | |||
|
232 | ||||
|
233 | var medium = new Promise<T>(this, true); | |||
|
234 | ||||
|
235 | AddHandler(success, error, cancel, medium); | |||
|
236 | ||||
|
237 | return medium; | |||
|
238 | } | |||
|
239 | ||||
228 | /// <summary> |
|
240 | /// <summary> | |
229 | /// Adds new handlers to this promise. |
|
241 | /// Adds new handlers to this promise. | |
230 | /// </summary> |
|
242 | /// </summary> | |
231 | /// <param name="success">The handler of the successfully completed operation. |
|
243 | /// <param name="success">The handler of the successfully completed operation. | |
232 | /// This handler will recieve an operation result as a parameter.</param> |
|
244 | /// This handler will recieve an operation result as a parameter.</param> | |
233 | /// <param name="error">Handles an exception that may occur during the operation and returns the value which will be used as the result of the operation.</param> |
|
245 | /// <param name="error">Handles an exception that may occur during the operation and returns the value which will be used as the result of the operation.</param> | |
234 | /// <returns>The new promise chained to this one.</returns> |
|
246 | /// <returns>The new promise chained to this one.</returns> | |
235 | public IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error) { |
|
247 | public IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error) { | |
236 | if (success == null && error == null) |
|
248 | if (success == null && error == null) | |
237 | return this; |
|
249 | return this; | |
238 |
|
250 | |||
239 | var medium = new Promise<T>(this, true); |
|
251 | var medium = new Promise<T>(this, true); | |
240 |
|
252 | |||
241 | AddHandler(success, error, null, medium); |
|
253 | AddHandler(success, error, null, medium); | |
242 |
|
254 | |||
243 | return medium; |
|
255 | return medium; | |
244 | } |
|
256 | } | |
245 |
|
257 | |||
|
258 | public IPromise Then(Action success, ErrorHandler error, Action cancel) { | |||
|
259 | return Then( | |||
|
260 | x => success(), | |||
|
261 | e => { | |||
|
262 | error(e); | |||
|
263 | return default(T); | |||
|
264 | }, | |||
|
265 | cancel | |||
|
266 | ); | |||
|
267 | } | |||
|
268 | ||||
246 | public IPromise Then(Action success, ErrorHandler error) { |
|
269 | public IPromise Then(Action success, ErrorHandler error) { | |
247 | return Then( |
|
270 | return Then( | |
248 | x => success(), |
|
271 | x => success(), | |
249 | e => { |
|
272 | e => { | |
250 | error(e); |
|
273 | error(e); | |
251 | return default(T); |
|
274 | return default(T); | |
252 | } |
|
275 | } | |
253 | ); |
|
276 | ); | |
254 | } |
|
277 | } | |
255 |
|
278 | |||
256 | public IPromise Then(Action success) { |
|
279 | public IPromise Then(Action success) { | |
257 | return Then(x => success()); |
|
280 | return Then(x => success()); | |
258 | } |
|
281 | } | |
259 |
|
282 | |||
260 |
|
283 | |||
261 | public IPromise<T> Then(ResultHandler<T> success) { |
|
284 | public IPromise<T> Then(ResultHandler<T> success) { | |
262 | if (success == null) |
|
285 | if (success == null) | |
263 | return this; |
|
286 | return this; | |
264 |
|
287 | |||
265 | var medium = new Promise<T>(this, true); |
|
288 | var medium = new Promise<T>(this, true); | |
266 |
|
289 | |||
267 | AddHandler(success, null, null, medium); |
|
290 | AddHandler(success, null, null, medium); | |
268 |
|
291 | |||
269 | return medium; |
|
292 | return medium; | |
270 | } |
|
293 | } | |
271 |
|
294 | |||
|
295 | public void Last(ResultHandler<T> success, ErrorHandler error, Action cancel) { | |||
|
296 | if (success == null && error == null && cancel == null) | |||
|
297 | return; | |||
|
298 | ||||
|
299 | ErrorHandler<T> errorHandler = null; | |||
|
300 | if (error != null) | |||
|
301 | errorHandler = err => { | |||
|
302 | error(err); | |||
|
303 | return default(T); | |||
|
304 | }; | |||
|
305 | AddHandler(success, errorHandler, cancel, null); | |||
|
306 | } | |||
|
307 | ||||
|
308 | public void Last(ResultHandler<T> success, ErrorHandler error) { | |||
|
309 | Last(success, error, null); | |||
|
310 | } | |||
|
311 | ||||
|
312 | public void Last(ResultHandler<T> success) { | |||
|
313 | Last(success, null, null); | |||
|
314 | } | |||
|
315 | ||||
|
316 | public void Last(Action success,ErrorHandler error, Action cancel) { | |||
|
317 | Last(x => success(), error, cancel); | |||
|
318 | } | |||
|
319 | ||||
|
320 | public void Last(Action success,ErrorHandler error) { | |||
|
321 | Last(x => success(), error, null); | |||
|
322 | } | |||
|
323 | ||||
|
324 | public void Last(Action success) { | |||
|
325 | Last(x => success(), null, null); | |||
|
326 | } | |||
|
327 | ||||
272 | public IPromise Error(ErrorHandler error) { |
|
328 | public IPromise Error(ErrorHandler error) { | |
273 | if (error == null) |
|
329 | if (error == null) | |
274 | return this; |
|
330 | return this; | |
275 |
|
331 | |||
276 | var medium = new Promise<T>(this, true); |
|
332 | var medium = new Promise<T>(this, true); | |
277 |
|
333 | |||
278 | AddHandler( |
|
334 | AddHandler( | |
279 | null, |
|
335 | null, | |
280 | e => { |
|
336 | e => { | |
281 | error(e); |
|
337 | error(e); | |
282 | return default(T); |
|
338 | return default(T); | |
283 | }, |
|
339 | }, | |
284 | null, |
|
340 | null, | |
285 | medium |
|
341 | medium | |
286 | ); |
|
342 | ); | |
287 |
|
343 | |||
288 | return medium; |
|
344 | return medium; | |
289 | } |
|
345 | } | |
290 |
|
346 | |||
291 | /// <summary> |
|
347 | /// <summary> | |
292 | /// Handles error and allows to keep the promise. |
|
348 | /// Handles error and allows to keep the promise. | |
293 | /// </summary> |
|
349 | /// </summary> | |
294 | /// <remarks> |
|
350 | /// <remarks> | |
295 | /// If the specified handler throws an exception, this exception will be used to reject the promise. |
|
351 | /// If the specified handler throws an exception, this exception will be used to reject the promise. | |
296 | /// </remarks> |
|
352 | /// </remarks> | |
297 | /// <param name="handler">The error handler which returns the result of the promise.</param> |
|
353 | /// <param name="handler">The error handler which returns the result of the promise.</param> | |
298 | /// <returns>New promise.</returns> |
|
354 | /// <returns>New promise.</returns> | |
299 | public IPromise<T> Error(ErrorHandler<T> handler) { |
|
355 | public IPromise<T> Error(ErrorHandler<T> handler) { | |
300 | if (handler == null) |
|
356 | if (handler == null) | |
301 | return this; |
|
357 | return this; | |
302 |
|
358 | |||
303 | var medium = new Promise<T>(this, true); |
|
359 | var medium = new Promise<T>(this, true); | |
304 |
|
360 | |||
305 | AddHandler(null, handler, null, medium); |
|
361 | AddHandler(null, handler, null, medium); | |
306 |
|
362 | |||
307 | return medium; |
|
363 | return medium; | |
308 | } |
|
364 | } | |
309 |
|
365 | |||
310 | public IPromise<T> Anyway(Action handler) { |
|
|||
311 | if (handler == null) |
|
|||
312 | return this; |
|
|||
313 |
|
||||
314 | var medium = new Promise<T>(this, true); |
|
|||
315 |
|
||||
316 | AddHandler( |
|
|||
317 | x => handler(), |
|
|||
318 | e => { |
|
|||
319 | handler(); |
|
|||
320 | throw new TransientPromiseException(e); |
|
|||
321 | }, |
|
|||
322 | null, |
|
|||
323 | medium |
|
|||
324 | ); |
|
|||
325 |
|
||||
326 | return medium; |
|
|||
327 | } |
|
|||
328 |
|
||||
329 | /// <summary> |
|
366 | /// <summary> | |
330 | /// Позволяет преобразовать результат выполения операции к новому типу. |
|
367 | /// Позволяет преобразовать результат выполения операции к новому типу. | |
331 | /// </summary> |
|
368 | /// </summary> | |
332 | /// <typeparam name="TNew">Новый тип результата.</typeparam> |
|
369 | /// <typeparam name="TNew">Новый тип результата.</typeparam> | |
333 | /// <param name="mapper">Преобразование результата к новому типу.</param> |
|
370 | /// <param name="mapper">Преобразование результата к новому типу.</param> | |
334 | /// <param name="error">Обработчик ошибки. Данный обработчик получит |
|
371 | /// <param name="error">Обработчик ошибки. Данный обработчик получит | |
335 | /// исключение возникшее при выполнении операции.</param> |
|
372 | /// исключение возникшее при выполнении операции.</param> | |
336 | /// <returns>Новое обещание, которое будет выполнено при выполнении исходного обещания.</returns> |
|
373 | /// <returns>Новое обещание, которое будет выполнено при выполнении исходного обещания.</returns> | |
337 |
public IPromise<TNew> |
|
374 | public IPromise<TNew> Then<TNew>(ResultMapper<T, TNew> mapper, ErrorHandler<T> error) { | |
338 | if (mapper == null) |
|
375 | if (mapper == null) | |
339 | throw new ArgumentNullException("mapper"); |
|
376 | throw new ArgumentNullException("mapper"); | |
340 |
|
377 | |||
341 | // создаем прицепленное обещание |
|
378 | // создаем прицепленное обещание | |
342 | var chained = new Promise<TNew>(this, true); |
|
379 | var chained = new Promise<TNew>(this, true); | |
343 |
|
380 | |||
344 | ResultHandler<T> resultHandler = result => chained.Resolve(mapper(result)); |
|
381 | ResultHandler<T> resultHandler = result => chained.Resolve(mapper(result)); | |
345 | ErrorHandler<T> errorHandler; |
|
382 | ErrorHandler<T> errorHandler; | |
346 | if (error != null) |
|
383 | if (error != null) | |
347 | errorHandler = e => { |
|
384 | errorHandler = e => { | |
348 | try { |
|
385 | try { | |
349 | return error(e); |
|
386 | return error(e); | |
350 | } catch (Exception e2) { |
|
387 | } catch (Exception e2) { | |
351 | // в случае ошибки нужно передать исключение дальше по цепочке |
|
388 | // в случае ошибки нужно передать исключение дальше по цепочке | |
352 | chained.Reject(e2); |
|
389 | chained.Reject(e2); | |
353 | } |
|
390 | } | |
354 | return default(T); |
|
391 | return default(T); | |
355 | }; |
|
392 | }; | |
356 | else |
|
393 | else | |
357 | errorHandler = e => { |
|
394 | errorHandler = e => { | |
358 | chained.Reject(e); |
|
395 | chained.Reject(e); | |
359 | return default(T); |
|
396 | return default(T); | |
360 | }; |
|
397 | }; | |
361 |
|
398 | |||
362 |
|
399 | |||
363 | AddHandler( |
|
400 | AddHandler( | |
364 | resultHandler, |
|
401 | resultHandler, | |
365 | errorHandler, |
|
402 | errorHandler, | |
366 | chained.InternalCancel, |
|
403 | chained.InternalCancel, | |
367 | null |
|
404 | null | |
368 | ); |
|
405 | ); | |
369 |
|
406 | |||
370 | return chained; |
|
407 | return chained; | |
371 | } |
|
408 | } | |
372 |
|
409 | |||
373 |
public IPromise<TNew> |
|
410 | public IPromise<TNew> Then<TNew>(ResultMapper<T, TNew> mapper) { | |
374 |
return |
|
411 | return Then(mapper, null); | |
375 | } |
|
412 | } | |
376 |
|
413 | |||
377 | /// <summary> |
|
414 | /// <summary> | |
378 | /// Сцепляет несколько аснхронных операций. Указанная асинхронная операция будет вызвана после |
|
415 | /// Сцепляет несколько аснхронных операций. Указанная асинхронная операция будет вызвана после | |
379 | /// выполнения текущей, а результат текущей операции может быть использован для инициализации |
|
416 | /// выполнения текущей, а результат текущей операции может быть использован для инициализации | |
380 | /// новой операции. |
|
417 | /// новой операции. | |
381 | /// </summary> |
|
418 | /// </summary> | |
382 | /// <typeparam name="TNew">Тип результата указанной асинхронной операции.</typeparam> |
|
419 | /// <typeparam name="TNew">Тип результата указанной асинхронной операции.</typeparam> | |
383 | /// <param name="chained">Асинхронная операция, которая должна будет начаться после выполнения текущей.</param> |
|
420 | /// <param name="chained">Асинхронная операция, которая должна будет начаться после выполнения текущей.</param> | |
384 | /// <param name="error">Обработчик ошибки. Данный обработчик получит |
|
421 | /// <param name="error">Обработчик ошибки. Данный обработчик получит | |
385 | /// исключение возникшее при выполнении текуещй операции.</param> |
|
422 | /// исключение возникшее при выполнении текуещй операции.</param> | |
386 | /// <returns>Новое обещание, которое будет выполнено по окончанию указанной аснхронной операции.</returns> |
|
423 | /// <returns>Новое обещание, которое будет выполнено по окончанию указанной аснхронной операции.</returns> | |
387 |
public IPromise<TNew> |
|
424 | public IPromise<TNew> Then<TNew>(ChainedOperation<T, TNew> chained, ErrorHandler<T> error) { | |
388 |
|
425 | |||
389 | // проблема в том, что на момент связывания еще не начата асинхронная операция, поэтому нужно |
|
426 | // проблема в том, что на момент связывания еще не начата асинхронная операция, поэтому нужно | |
390 | // создать посредника, к которому будут подвызяваться следующие обработчики. |
|
427 | // создать посредника, к которому будут подвызяваться следующие обработчики. | |
391 | // когда будет выполнена реальная асинхронная операция, она обратиться к посреднику, чтобы |
|
428 | // когда будет выполнена реальная асинхронная операция, она обратиться к посреднику, чтобы | |
392 | // передать через него результаты работы. |
|
429 | // передать через него результаты работы. | |
393 | var medium = new Promise<TNew>(this, true); |
|
430 | var medium = new Promise<TNew>(this, true); | |
394 |
|
431 | |||
395 | ResultHandler<T> resultHandler = delegate(T result) { |
|
432 | ResultHandler<T> resultHandler = delegate(T result) { | |
396 | if (medium.IsCancelled) |
|
433 | if (medium.IsCancelled) | |
397 | return; |
|
434 | return; | |
398 |
|
435 | |||
399 | var promise = chained(result); |
|
436 | var promise = chained(result); | |
400 |
|
437 | |||
401 | promise.Then( |
|
438 | promise.Then( | |
402 | medium.Resolve, |
|
439 | medium.Resolve, | |
403 | err => { |
|
440 | err => { | |
404 | medium.Reject(err); |
|
441 | medium.Reject(err); | |
405 | throw new TransientPromiseException(err); |
|
442 | throw new TransientPromiseException(err); | |
406 | } |
|
443 | } | |
407 | ); |
|
444 | ); | |
408 |
|
445 | |||
409 | // notify chained operation that it's not needed anymore |
|
446 | // notify chained operation that it's not needed anymore | |
410 | // порядок вызова Then, Cancelled важен, поскольку от этого |
|
447 | // порядок вызова Then, Cancelled важен, поскольку от этого | |
411 | // зависит IsExclusive |
|
448 | // зависит IsExclusive | |
412 | medium.Cancelled(() => { |
|
449 | medium.Cancelled(() => { | |
413 | if (promise.IsExclusive) |
|
450 | if (promise.IsExclusive) | |
414 | promise.Cancel(); |
|
451 | promise.Cancel(); | |
415 | }); |
|
452 | }); | |
416 |
|
453 | |||
417 | // внешняя отмена связанной операции рассматривается как ошибка |
|
454 | // внешняя отмена связанной операции рассматривается как ошибка | |
418 | promise.Cancelled(() => medium.Reject(new OperationCanceledException())); |
|
455 | promise.Cancelled(() => medium.Reject(new OperationCanceledException())); | |
419 | }; |
|
456 | }; | |
420 |
|
457 | |||
421 | ErrorHandler<T> errorHandler = delegate(Exception e) { |
|
458 | ErrorHandler<T> errorHandler = delegate(Exception e) { | |
422 | if (error != null) { |
|
459 | if (error != null) { | |
423 | try { |
|
460 | try { | |
424 | return error(e); |
|
461 | return error(e); | |
425 | } catch (Exception e2) { |
|
462 | } catch (Exception e2) { | |
426 | medium.Reject(e2); |
|
463 | medium.Reject(e2); | |
427 | return default(T); |
|
464 | return default(T); | |
428 | } |
|
465 | } | |
429 | } |
|
466 | } | |
430 | // в случае ошибки нужно передать исключение дальше по цепочке |
|
467 | // в случае ошибки нужно передать исключение дальше по цепочке | |
431 | medium.Reject(e); |
|
468 | medium.Reject(e); | |
432 | return default(T); |
|
469 | return default(T); | |
433 | }; |
|
470 | }; | |
434 |
|
471 | |||
435 | AddHandler( |
|
472 | AddHandler( | |
436 | resultHandler, |
|
473 | resultHandler, | |
437 | errorHandler, |
|
474 | errorHandler, | |
438 | medium.InternalCancel, |
|
475 | medium.InternalCancel, | |
439 | null |
|
476 | null | |
440 | ); |
|
477 | ); | |
441 |
|
478 | |||
442 | return medium; |
|
479 | return medium; | |
443 | } |
|
480 | } | |
444 |
|
481 | |||
445 |
public IPromise<TNew> |
|
482 | public IPromise<TNew> Then<TNew>(ChainedOperation<T, TNew> chained) { | |
446 |
return |
|
483 | return Then(chained, null); | |
447 | } |
|
484 | } | |
448 |
|
485 | |||
449 | public IPromise<T> Cancelled(Action handler) { |
|
486 | public IPromise<T> Cancelled(Action handler) { | |
450 | var medium = new Promise<T>(this, true); |
|
487 | var medium = new Promise<T>(this, true); | |
451 | AddHandler(null, null, handler, medium); |
|
488 | AddHandler(null, null, handler, medium); | |
452 | return medium; |
|
489 | return medium; | |
453 | } |
|
490 | } | |
454 |
|
491 | |||
455 | /// <summary> |
|
492 | /// <summary> | |
456 | /// Adds the specified handler for all cases (success, error, cancel) |
|
493 | /// Adds the specified handler for all cases (success, error, cancel) | |
457 | /// </summary> |
|
494 | /// </summary> | |
458 | /// <param name="handler">The handler that will be called anyway</param> |
|
495 | /// <param name="handler">The handler that will be called anyway</param> | |
459 | /// <returns>self</returns> |
|
496 | /// <returns>self</returns> | |
460 | public IPromise<T> Finally(Action handler) { |
|
497 | public IPromise<T> Finally(Action handler) { | |
461 | if (handler == null) |
|
498 | if (handler == null) | |
462 | throw new ArgumentNullException("handler"); |
|
499 | throw new ArgumentNullException("handler"); | |
463 | AddHandler( |
|
500 | AddHandler( | |
464 | x => handler(), |
|
501 | x => handler(), | |
465 | e => { |
|
502 | e => { | |
466 | handler(); |
|
503 | handler(); | |
467 | throw new TransientPromiseException(e); |
|
504 | throw new TransientPromiseException(e); | |
468 | }, |
|
505 | }, | |
469 | handler, |
|
506 | handler, | |
470 | null |
|
507 | null | |
471 | ); |
|
508 | ); | |
472 | return this; |
|
509 | return this; | |
473 | } |
|
510 | } | |
474 |
|
511 | |||
475 | /// <summary> |
|
512 | /// <summary> | |
476 | /// Преобразует результат обещания к нужному типу |
|
513 | /// Преобразует результат обещания к нужному типу | |
477 | /// </summary> |
|
514 | /// </summary> | |
478 | /// <typeparam name="T2"></typeparam> |
|
515 | /// <typeparam name="T2"></typeparam> | |
479 | /// <returns></returns> |
|
516 | /// <returns></returns> | |
480 | public IPromise<T2> Cast<T2>() { |
|
517 | public IPromise<T2> Cast<T2>() { | |
481 |
return |
|
518 | return Then(x => (T2)(object)x, null); | |
482 | } |
|
519 | } | |
483 |
|
520 | |||
484 | /// <summary> |
|
521 | /// <summary> | |
485 | /// Дожидается отложенного обещания и в случае успеха, возвращает |
|
522 | /// Дожидается отложенного обещания и в случае успеха, возвращает | |
486 | /// его, результат, в противном случае бросает исключение. |
|
523 | /// его, результат, в противном случае бросает исключение. | |
487 | /// </summary> |
|
524 | /// </summary> | |
488 | /// <remarks> |
|
525 | /// <remarks> | |
489 | /// <para> |
|
526 | /// <para> | |
490 | /// Если ожидание обещания было прервано по таймауту, это не значит, |
|
527 | /// Если ожидание обещания было прервано по таймауту, это не значит, | |
491 | /// что обещание было отменено или что-то в этом роде, это только |
|
528 | /// что обещание было отменено или что-то в этом роде, это только | |
492 | /// означает, что мы его не дождались, однако все зарегистрированные |
|
529 | /// означает, что мы его не дождались, однако все зарегистрированные | |
493 | /// обработчики, как были так остались и они будут вызваны, когда |
|
530 | /// обработчики, как были так остались и они будут вызваны, когда | |
494 | /// обещание будет выполнено. |
|
531 | /// обещание будет выполнено. | |
495 | /// </para> |
|
532 | /// </para> | |
496 | /// <para> |
|
533 | /// <para> | |
497 | /// Такое поведение вполне оправдано поскольку таймаут может истечь |
|
534 | /// Такое поведение вполне оправдано поскольку таймаут может истечь | |
498 | /// в тот момент, когда началась обработка цепочки обработчиков, и |
|
535 | /// в тот момент, когда началась обработка цепочки обработчиков, и | |
499 | /// к тому же текущее обещание может стоять в цепочке обещаний и его |
|
536 | /// к тому же текущее обещание может стоять в цепочке обещаний и его | |
500 | /// отклонение может привести к непрогнозируемому результату. |
|
537 | /// отклонение может привести к непрогнозируемому результату. | |
501 | /// </para> |
|
538 | /// </para> | |
502 | /// </remarks> |
|
539 | /// </remarks> | |
503 | /// <param name="timeout">Время ожидания</param> |
|
540 | /// <param name="timeout">Время ожидания</param> | |
504 | /// <returns>Результат выполнения обещания</returns> |
|
541 | /// <returns>Результат выполнения обещания</returns> | |
505 | public T Join(int timeout) { |
|
542 | public T Join(int timeout) { | |
506 | var evt = new ManualResetEvent(false); |
|
543 | var evt = new ManualResetEvent(false); | |
507 |
|
|
544 | Finally(() => evt.Set()); | |
508 | Cancelled(() => evt.Set()); |
|
|||
509 |
|
545 | |||
510 | if (!evt.WaitOne(timeout, true)) |
|
546 | if (!evt.WaitOne(timeout, true)) | |
511 | throw new TimeoutException(); |
|
547 | throw new TimeoutException(); | |
512 |
|
548 | |||
513 | switch (m_state) { |
|
549 | switch (m_state) { | |
514 | case SUCCEEDED_STATE: |
|
550 | case SUCCEEDED_STATE: | |
515 | return m_result; |
|
551 | return m_result; | |
516 | case CANCELLED_STATE: |
|
552 | case CANCELLED_STATE: | |
517 | throw new OperationCanceledException(); |
|
553 | throw new OperationCanceledException(); | |
518 | case REJECTED_STATE: |
|
554 | case REJECTED_STATE: | |
519 | throw new TargetInvocationException(m_error); |
|
555 | throw new TargetInvocationException(m_error); | |
520 | default: |
|
556 | default: | |
521 | throw new ApplicationException(String.Format("Invalid promise state {0}", m_state)); |
|
557 | throw new ApplicationException(String.Format("Invalid promise state {0}", m_state)); | |
522 | } |
|
558 | } | |
523 | } |
|
559 | } | |
524 |
|
560 | |||
525 | public T Join() { |
|
561 | public T Join() { | |
526 | return Join(Timeout.Infinite); |
|
562 | return Join(Timeout.Infinite); | |
527 | } |
|
563 | } | |
528 |
|
564 | |||
529 | void AddHandler(ResultHandler<T> success, ErrorHandler<T> error, Action cancel, Promise<T> medium) { |
|
565 | void AddHandler(ResultHandler<T> success, ErrorHandler<T> error, Action cancel, Promise<T> medium) { | |
530 | if (success != null || error != null) |
|
566 | if (success != null || error != null) | |
531 | Interlocked.Increment(ref m_childrenCount); |
|
567 | Interlocked.Increment(ref m_childrenCount); | |
532 |
|
568 | |||
533 | var handler = new HandlerDescriptor { |
|
569 | var handler = new HandlerDescriptor { | |
534 | resultHandler = success, |
|
570 | resultHandler = success, | |
535 | errorHandler = error, |
|
571 | errorHandler = error, | |
536 | cancellHandler = cancel, |
|
572 | cancellHandler = cancel, | |
537 | medium = medium |
|
573 | medium = medium | |
538 | }; |
|
574 | }; | |
539 |
|
575 | |||
540 | bool queued; |
|
576 | bool queued; | |
541 |
|
577 | |||
542 | if (!IsResolved) { |
|
578 | if (!IsResolved) { | |
543 | m_handlers.Enqueue(handler); |
|
579 | m_handlers.Enqueue(handler); | |
544 | queued = true; |
|
580 | queued = true; | |
545 | } else { |
|
581 | } else { | |
546 | // the promise is in resolved state, just invoke the handled with minimum overhead |
|
582 | // the promise is in resolved state, just invoke the handled with minimum overhead | |
547 | queued = false; |
|
583 | queued = false; | |
548 | InvokeHandler(handler); |
|
584 | InvokeHandler(handler); | |
549 | } |
|
585 | } | |
550 |
|
586 | |||
551 | if (queued && IsResolved && m_handlers.TryDequeue(out handler)) |
|
587 | if (queued && IsResolved && m_handlers.TryDequeue(out handler)) | |
552 | // if the promise have been resolved while we was adding handler to the queue |
|
588 | // if the promise have been resolved while we was adding handler to the queue | |
553 | // we can't guarantee that someone is still processing it |
|
589 | // we can't guarantee that someone is still processing it | |
554 | // therefore we will fetch a handler from the queue and execute it |
|
590 | // therefore we will fetch a handler from the queue and execute it | |
555 | // note that fetched handler may be not the one that we have added |
|
591 | // note that fetched handler may be not the one that we have added | |
556 | // even we can fetch no handlers at all :) |
|
592 | // even we can fetch no handlers at all :) | |
557 | InvokeHandler(handler); |
|
593 | InvokeHandler(handler); | |
558 | } |
|
594 | } | |
559 |
|
595 | |||
560 | protected virtual void InvokeHandler(HandlerDescriptor handler) { |
|
596 | protected virtual void InvokeHandler(HandlerDescriptor handler) { | |
561 | switch (m_state) { |
|
597 | switch (m_state) { | |
562 | case SUCCEEDED_STATE: |
|
598 | case SUCCEEDED_STATE: | |
563 | handler.Resolve(m_result); |
|
599 | handler.Resolve(m_result); | |
564 | break; |
|
600 | break; | |
565 | case REJECTED_STATE: |
|
601 | case REJECTED_STATE: | |
566 | handler.Reject(m_error); |
|
602 | handler.Reject(m_error); | |
567 | break; |
|
603 | break; | |
568 | case CANCELLED_STATE: |
|
604 | case CANCELLED_STATE: | |
569 | handler.Cancel(); |
|
605 | handler.Cancel(); | |
570 | break; |
|
606 | break; | |
571 | default: |
|
607 | default: | |
572 | // do nothing |
|
608 | // do nothing | |
573 | return; |
|
609 | return; | |
574 | } |
|
610 | } | |
575 | } |
|
611 | } | |
576 |
|
612 | |||
577 | void OnStateChanged() { |
|
613 | void OnStateChanged() { | |
578 | HandlerDescriptor handler; |
|
614 | HandlerDescriptor handler; | |
579 | while (m_handlers.TryDequeue(out handler)) |
|
615 | while (m_handlers.TryDequeue(out handler)) | |
580 | InvokeHandler(handler); |
|
616 | InvokeHandler(handler); | |
581 | } |
|
617 | } | |
582 |
|
618 | |||
583 | public bool IsExclusive { |
|
619 | public bool IsExclusive { | |
584 | get { |
|
620 | get { | |
585 | return m_childrenCount <= 1; |
|
621 | return m_childrenCount <= 1; | |
586 | } |
|
622 | } | |
587 | } |
|
623 | } | |
588 |
|
624 | |||
589 | /// <summary> |
|
625 | /// <summary> | |
590 | /// Объединяет несколько обещаний в одно, результатом которого является массив результатов других обещаний. |
|
626 | /// Объединяет несколько обещаний в одно, результатом которого является массив результатов других обещаний. | |
591 | /// Если хотябы одно из переданных обещаний не будет выполнено, то новое обещение тоже не будет выполнено. |
|
627 | /// Если хотябы одно из переданных обещаний не будет выполнено, то новое обещение тоже не будет выполнено. | |
592 | /// При отмене нового обещания, переданные обещания также будут отменены, если никто больше на них не подписан. |
|
628 | /// При отмене нового обещания, переданные обещания также будут отменены, если никто больше на них не подписан. | |
593 | /// </summary> |
|
629 | /// </summary> | |
594 | /// <param name="promises">Список обещаний. Если список пустой, то результирующее обещание возвращается уже выполненным.</param> |
|
630 | /// <param name="promises">Список обещаний. Если список пустой, то результирующее обещание возвращается уже выполненным.</param> | |
595 | /// <returns>Обещание объединяющее в себе результат переданных обещаний.</returns> |
|
631 | /// <returns>Обещание объединяющее в себе результат переданных обещаний.</returns> | |
596 | /// <exception cref="ArgumentNullException"><paramref name="promises"/> не может быть null</exception> |
|
632 | /// <exception cref="ArgumentNullException"><paramref name="promises"/> не может быть null</exception> | |
597 | public static IPromise<T[]> CreateComposite(IList<IPromise<T>> promises) { |
|
633 | public static IPromise<T[]> CreateComposite(IList<IPromise<T>> promises) { | |
598 | if (promises == null) |
|
634 | if (promises == null) | |
599 | throw new ArgumentNullException(); |
|
635 | throw new ArgumentNullException(); | |
600 |
|
636 | |||
601 | // создаем аккумулятор для результатов и результирующее обещание |
|
637 | // создаем аккумулятор для результатов и результирующее обещание | |
602 | var result = new T[promises.Count]; |
|
638 | var result = new T[promises.Count]; | |
603 | var promise = new Promise<T[]>(); |
|
639 | var promise = new Promise<T[]>(); | |
604 |
|
640 | |||
605 | // special case |
|
641 | // special case | |
606 | if (promises.Count == 0) { |
|
642 | if (promises.Count == 0) { | |
607 | promise.Resolve(result); |
|
643 | promise.Resolve(result); | |
608 | return promise; |
|
644 | return promise; | |
609 | } |
|
645 | } | |
610 |
|
646 | |||
611 | int pending = promises.Count; |
|
647 | int pending = promises.Count; | |
612 |
|
648 | |||
613 | for (int i = 0; i < promises.Count; i++) { |
|
649 | for (int i = 0; i < promises.Count; i++) { | |
614 | var dest = i; |
|
650 | var dest = i; | |
615 |
|
651 | |||
616 | if (promises[i] != null) { |
|
652 | if (promises[i] != null) { | |
617 | promises[i].Then( |
|
653 | promises[i].Then( | |
618 | x => { |
|
654 | x => { | |
619 | result[dest] = x; |
|
655 | result[dest] = x; | |
620 | if (Interlocked.Decrement(ref pending) == 0) |
|
656 | if (Interlocked.Decrement(ref pending) == 0) | |
621 | promise.Resolve(result); |
|
657 | promise.Resolve(result); | |
622 | }, |
|
658 | }, | |
623 | e => { |
|
659 | e => { | |
624 | promise.Reject(e); |
|
660 | promise.Reject(e); | |
625 | return default(T); |
|
661 | return default(T); | |
626 | } |
|
662 | } | |
627 | ); |
|
663 | ); | |
628 | } else { |
|
664 | } else { | |
629 | if (Interlocked.Decrement(ref pending) == 0) |
|
665 | if (Interlocked.Decrement(ref pending) == 0) | |
630 | promise.Resolve(result); |
|
666 | promise.Resolve(result); | |
631 | } |
|
667 | } | |
632 | } |
|
668 | } | |
633 |
|
669 | |||
634 | promise.Cancelled( |
|
670 | promise.Cancelled( | |
635 | () => { |
|
671 | () => { | |
636 | foreach (var d in promises) |
|
672 | foreach (var d in promises) | |
637 | if (d != null && d.IsExclusive) |
|
673 | if (d != null && d.IsExclusive) | |
638 | d.Cancel(); |
|
674 | d.Cancel(); | |
639 | } |
|
675 | } | |
640 | ); |
|
676 | ); | |
641 |
|
677 | |||
642 | return promise; |
|
678 | return promise; | |
643 | } |
|
679 | } | |
644 |
|
680 | |||
645 | /// <summary> |
|
681 | /// <summary> | |
646 | /// Объединяет несколько обещаний в одно. Результирующее обещание будет выполнено при |
|
682 | /// Объединяет несколько обещаний в одно. Результирующее обещание будет выполнено при | |
647 | /// выполнении всех указанных обещаний. При этом возвращаемые значения первичных обещаний |
|
683 | /// выполнении всех указанных обещаний. При этом возвращаемые значения первичных обещаний | |
648 | /// игнорируются. |
|
684 | /// игнорируются. | |
649 | /// </summary> |
|
685 | /// </summary> | |
650 | /// <param name="promises">Коллекция первичных обещаний, которые будут объеденены в одно.</param> |
|
686 | /// <param name="promises">Коллекция первичных обещаний, которые будут объеденены в одно.</param> | |
651 | /// <returns>Новое обещание, объединяющее в себе переданные.</returns> |
|
687 | /// <returns>Новое обещание, объединяющее в себе переданные.</returns> | |
652 | /// <remarks> |
|
688 | /// <remarks> | |
653 | /// Если в коллекции встречаюься <c>null</c>, то они воспринимаются как выполненные обещания. |
|
689 | /// Если в коллекции встречаюься <c>null</c>, то они воспринимаются как выполненные обещания. | |
654 | /// </remarks> |
|
690 | /// </remarks> | |
655 | public static IPromise CreateComposite(ICollection<IPromise> promises) { |
|
691 | public static IPromise CreateComposite(ICollection<IPromise> promises) { | |
656 | if (promises == null) |
|
692 | if (promises == null) | |
657 | throw new ArgumentNullException(); |
|
693 | throw new ArgumentNullException(); | |
658 | if (promises.Count == 0) |
|
694 | if (promises.Count == 0) | |
659 | return Promise<object>.ResultToPromise(null); |
|
695 | return Promise<object>.ResultToPromise(null); | |
660 |
|
696 | |||
661 | int countdown = promises.Count; |
|
697 | int countdown = promises.Count; | |
662 |
|
698 | |||
663 | var result = new Promise<object>(); |
|
699 | var result = new Promise<object>(); | |
664 |
|
700 | |||
665 | foreach (var d in promises) { |
|
701 | foreach (var d in promises) { | |
666 | if (d == null) { |
|
702 | if (d == null) { | |
667 | if (Interlocked.Decrement(ref countdown) == 0) |
|
703 | if (Interlocked.Decrement(ref countdown) == 0) | |
668 | result.Resolve(null); |
|
704 | result.Resolve(null); | |
669 | } else { |
|
705 | } else { | |
670 | d.Then(() => { |
|
706 | d.Then(() => { | |
671 | if (Interlocked.Decrement(ref countdown) == 0) |
|
707 | if (Interlocked.Decrement(ref countdown) == 0) | |
672 | result.Resolve(null); |
|
708 | result.Resolve(null); | |
673 | }); |
|
709 | }); | |
674 | } |
|
710 | } | |
675 | } |
|
711 | } | |
676 |
|
712 | |||
677 | result.Cancelled(() => { |
|
713 | result.Cancelled(() => { | |
678 | foreach (var d in promises) |
|
714 | foreach (var d in promises) | |
679 | if (d != null && d.IsExclusive) |
|
715 | if (d != null && d.IsExclusive) | |
680 | d.Cancel(); |
|
716 | d.Cancel(); | |
681 | }); |
|
717 | }); | |
682 |
|
718 | |||
683 | return result; |
|
719 | return result; | |
684 | } |
|
720 | } | |
685 |
|
721 | |||
686 | public static Promise<T> ResultToPromise(T result) { |
|
722 | public static Promise<T> ResultToPromise(T result) { | |
687 | var p = new Promise<T>(); |
|
723 | var p = new Promise<T>(); | |
688 | p.Resolve(result); |
|
724 | p.Resolve(result); | |
689 | return p; |
|
725 | return p; | |
690 | } |
|
726 | } | |
691 |
|
727 | |||
692 | public static Promise<T> ExceptionToPromise(Exception error) { |
|
728 | public static Promise<T> ExceptionToPromise(Exception error) { | |
693 | if (error == null) |
|
729 | if (error == null) | |
694 | throw new ArgumentNullException(); |
|
730 | throw new ArgumentNullException(); | |
695 |
|
731 | |||
696 | var p = new Promise<T>(); |
|
732 | var p = new Promise<T>(); | |
697 | p.Reject(error); |
|
733 | p.Reject(error); | |
698 | return p; |
|
734 | return p; | |
699 | } |
|
735 | } | |
700 |
|
736 | |||
701 | #region IPromiseBase explicit implementation |
|
737 | #region IPromiseBase explicit implementation | |
702 |
|
738 | |||
703 | IPromise IPromise.Error(ErrorHandler error) { |
|
739 | IPromise IPromise.Error(ErrorHandler error) { | |
704 | return Error(error); |
|
740 | return Error(error); | |
705 | } |
|
741 | } | |
706 |
|
742 | |||
707 | IPromise IPromise.Anyway(Action handler) { |
|
|||
708 | return Anyway(handler); |
|
|||
709 | } |
|
|||
710 |
|
||||
711 | IPromise IPromise.Finally(Action handler) { |
|
743 | IPromise IPromise.Finally(Action handler) { | |
712 | return Finally(handler); |
|
744 | return Finally(handler); | |
713 | } |
|
745 | } | |
714 |
|
746 | |||
715 | IPromise IPromise.Cancelled(Action handler) { |
|
747 | IPromise IPromise.Cancelled(Action handler) { | |
716 | return Cancelled(handler); |
|
748 | return Cancelled(handler); | |
717 | } |
|
749 | } | |
718 |
|
750 | |||
719 | void IPromise.Join() { |
|
751 | void IPromise.Join() { | |
720 | Join(); |
|
752 | Join(); | |
721 | } |
|
753 | } | |
722 |
|
754 | |||
723 | void IPromise.Join(int timeout) { |
|
755 | void IPromise.Join(int timeout) { | |
724 | Join(timeout); |
|
756 | Join(timeout); | |
725 | } |
|
757 | } | |
726 |
|
758 | |||
727 | #endregion |
|
759 | #endregion | |
728 |
|
760 | |||
729 |
|
761 | |||
730 |
|
762 | |||
731 | } |
|
763 | } | |
732 | } |
|
764 | } |
@@ -1,38 +1,69 | |||||
1 | using System.Threading; |
|
1 | using System.Threading; | |
|
2 | using System; | |||
|
3 | #if NET_4_5 | |||
|
4 | using System.Threading.Tasks; | |||
|
5 | #endif | |||
2 |
|
6 | |||
3 | namespace Implab { |
|
7 | namespace Implab { | |
4 | public static class PromiseExtensions { |
|
8 | public static class PromiseExtensions { | |
5 | public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) { |
|
9 | public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) { | |
|
10 | Safe.ArgumentNotNull(that, "that"); | |||
6 | var context = SynchronizationContext.Current; |
|
11 | var context = SynchronizationContext.Current; | |
7 | if (context == null) |
|
12 | if (context == null) | |
8 | return that; |
|
13 | return that; | |
9 |
|
14 | |||
10 | var p = new SyncContextPromise<T>(context, that, true); |
|
15 | var p = new SyncContextPromise<T>(context, that, true); | |
11 |
|
16 | |||
12 | that.Then( |
|
17 | that.Then( | |
13 | x => p.Resolve(x), |
|
18 | x => p.Resolve(x), | |
14 | e => { |
|
19 | e => { | |
15 | p.Reject(e); |
|
20 | p.Reject(e); | |
16 | return default(T); |
|
21 | return default(T); | |
17 | } |
|
22 | } | |
18 | ); |
|
23 | ); | |
19 | return p; |
|
24 | return p; | |
20 | } |
|
25 | } | |
21 |
|
26 | |||
22 | public static IPromise<T> DispatchToContext<T>(this IPromise<T> that, SynchronizationContext context) { |
|
27 | public static IPromise<T> DispatchToContext<T>(this IPromise<T> that, SynchronizationContext context) { | |
|
28 | Safe.ArgumentNotNull(that, "that"); | |||
23 | Safe.ArgumentNotNull(context, "context"); |
|
29 | Safe.ArgumentNotNull(context, "context"); | |
24 |
|
30 | |||
25 | var p = new SyncContextPromise<T>(context, that, true); |
|
31 | var p = new SyncContextPromise<T>(context, that, true); | |
26 |
|
32 | |||
27 | that.Then( |
|
33 | that.Then( | |
28 | x => p.Resolve(x), |
|
34 | x => p.Resolve(x), | |
29 | e => { |
|
35 | e => { | |
30 | p.Reject(e); |
|
36 | p.Reject(e); | |
31 | return default(T); |
|
37 | return default(T); | |
32 | } |
|
38 | } | |
33 | ); |
|
39 | ); | |
34 | return p; |
|
40 | return p; | |
35 | } |
|
41 | } | |
|
42 | ||||
|
43 | public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) { | |||
|
44 | Safe.ArgumentNotNull(that, "that"); | |||
|
45 | Safe.ArgumentNotNull(callback, "callback"); | |||
|
46 | return ar => { | |||
|
47 | try { | |||
|
48 | that.Resolve(callback(ar)); | |||
|
49 | } catch (Exception err) { | |||
|
50 | that.Reject(err); | |||
|
51 | } | |||
|
52 | }; | |||
|
53 | } | |||
|
54 | ||||
|
55 | #if NET_4_5 | |||
|
56 | ||||
|
57 | public static Task<T> GetTask<T>(this IPromise<T> that) { | |||
|
58 | Safe.ArgumentNotNull(that, "that"); | |||
|
59 | var tcs = new TaskCompletionSource<T>(); | |||
|
60 | ||||
|
61 | that.Last(tcs.SetResult, tcs.SetException, tcs.SetCanceled); | |||
|
62 | ||||
|
63 | return tcs.Task; | |||
|
64 | } | |||
|
65 | ||||
|
66 | #endif | |||
36 | } |
|
67 | } | |
37 | } |
|
68 | } | |
38 |
|
69 |
General Comments 0
You need to be logged in to leave comments.
Login now