@@ -1,198 +1,196 | |||||
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> |
|
|||
11 | <SchemaVersion>2.0</SchemaVersion> |
|
|||
12 | </PropertyGroup> |
|
10 | </PropertyGroup> | |
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
11 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
14 | <DebugSymbols>true</DebugSymbols> |
|
12 | <DebugSymbols>true</DebugSymbols> | |
15 | <DebugType>full</DebugType> |
|
13 | <DebugType>full</DebugType> | |
16 | <Optimize>false</Optimize> |
|
14 | <Optimize>false</Optimize> | |
17 | <OutputPath>bin\Debug</OutputPath> |
|
15 | <OutputPath>bin\Debug</OutputPath> | |
18 | <DefineConstants>TRACE;DEBUG;</DefineConstants> |
|
16 | <DefineConstants>TRACE;DEBUG;</DefineConstants> | |
19 | <ErrorReport>prompt</ErrorReport> |
|
17 | <ErrorReport>prompt</ErrorReport> | |
20 | <WarningLevel>4</WarningLevel> |
|
18 | <WarningLevel>4</WarningLevel> | |
21 | <ConsolePause>false</ConsolePause> |
|
19 | <ConsolePause>false</ConsolePause> | |
22 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
20 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
23 | </PropertyGroup> |
|
21 | </PropertyGroup> | |
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
22 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
25 | <DebugType>full</DebugType> |
|
23 | <DebugType>full</DebugType> | |
26 | <Optimize>true</Optimize> |
|
24 | <Optimize>true</Optimize> | |
27 | <OutputPath>bin\Release</OutputPath> |
|
25 | <OutputPath>bin\Release</OutputPath> | |
28 | <ErrorReport>prompt</ErrorReport> |
|
26 | <ErrorReport>prompt</ErrorReport> | |
29 | <WarningLevel>4</WarningLevel> |
|
27 | <WarningLevel>4</WarningLevel> | |
30 | <ConsolePause>false</ConsolePause> |
|
28 | <ConsolePause>false</ConsolePause> | |
31 | </PropertyGroup> |
|
29 | </PropertyGroup> | |
32 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> |
|
30 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |
33 | <DebugSymbols>true</DebugSymbols> |
|
31 | <DebugSymbols>true</DebugSymbols> | |
34 | <DebugType>full</DebugType> |
|
32 | <DebugType>full</DebugType> | |
35 | <Optimize>false</Optimize> |
|
33 | <Optimize>false</Optimize> | |
36 | <OutputPath>bin\Debug</OutputPath> |
|
34 | <OutputPath>bin\Debug</OutputPath> | |
37 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> |
|
35 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> | |
38 | <ErrorReport>prompt</ErrorReport> |
|
36 | <ErrorReport>prompt</ErrorReport> | |
39 | <WarningLevel>4</WarningLevel> |
|
37 | <WarningLevel>4</WarningLevel> | |
40 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
38 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
41 | <ConsolePause>false</ConsolePause> |
|
39 | <ConsolePause>false</ConsolePause> | |
42 | </PropertyGroup> |
|
40 | </PropertyGroup> | |
43 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> |
|
41 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |
44 | <Optimize>true</Optimize> |
|
42 | <Optimize>true</Optimize> | |
45 | <OutputPath>bin\Release</OutputPath> |
|
43 | <OutputPath>bin\Release</OutputPath> | |
46 | <ErrorReport>prompt</ErrorReport> |
|
44 | <ErrorReport>prompt</ErrorReport> | |
47 | <WarningLevel>4</WarningLevel> |
|
45 | <WarningLevel>4</WarningLevel> | |
48 | <ConsolePause>false</ConsolePause> |
|
46 | <ConsolePause>false</ConsolePause> | |
49 | <DefineConstants>NET_4_5</DefineConstants> |
|
47 | <DefineConstants>NET_4_5</DefineConstants> | |
50 | </PropertyGroup> |
|
48 | </PropertyGroup> | |
51 | <ItemGroup> |
|
49 | <ItemGroup> | |
52 | <Reference Include="System" /> |
|
50 | <Reference Include="System" /> | |
53 | <Reference Include="System.Xml" /> |
|
51 | <Reference Include="System.Xml" /> | |
54 | </ItemGroup> |
|
52 | </ItemGroup> | |
55 | <ItemGroup> |
|
53 | <ItemGroup> | |
56 | <Compile Include="Component.cs" /> |
|
54 | <Compile Include="Component.cs" /> | |
57 | <Compile Include="CustomEqualityComparer.cs" /> |
|
55 | <Compile Include="CustomEqualityComparer.cs" /> | |
58 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> |
|
56 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> | |
59 | <Compile Include="Diagnostics\EventText.cs" /> |
|
57 | <Compile Include="Diagnostics\EventText.cs" /> | |
60 | <Compile Include="Diagnostics\IEventTextFormatter.cs" /> |
|
58 | <Compile Include="Diagnostics\IEventTextFormatter.cs" /> | |
61 | <Compile Include="Diagnostics\LogChannel.cs" /> |
|
59 | <Compile Include="Diagnostics\LogChannel.cs" /> | |
62 | <Compile Include="Diagnostics\LogicalOperation.cs" /> |
|
60 | <Compile Include="Diagnostics\LogicalOperation.cs" /> | |
63 | <Compile Include="Diagnostics\TextFileListener.cs" /> |
|
61 | <Compile Include="Diagnostics\TextFileListener.cs" /> | |
64 | <Compile Include="Diagnostics\TextListenerBase.cs" /> |
|
62 | <Compile Include="Diagnostics\TextListenerBase.cs" /> | |
65 | <Compile Include="Diagnostics\TraceLog.cs" /> |
|
63 | <Compile Include="Diagnostics\TraceLog.cs" /> | |
66 | <Compile Include="Diagnostics\TraceContext.cs" /> |
|
64 | <Compile Include="Diagnostics\TraceContext.cs" /> | |
67 | <Compile Include="Diagnostics\TraceEvent.cs" /> |
|
65 | <Compile Include="Diagnostics\TraceEvent.cs" /> | |
68 | <Compile Include="Diagnostics\TraceEventType.cs" /> |
|
66 | <Compile Include="Diagnostics\TraceEventType.cs" /> | |
69 | <Compile Include="Disposable.cs" /> |
|
67 | <Compile Include="Disposable.cs" /> | |
70 | <Compile Include="ICancellable.cs" /> |
|
68 | <Compile Include="ICancellable.cs" /> | |
71 | <Compile Include="IProgressHandler.cs" /> |
|
69 | <Compile Include="IProgressHandler.cs" /> | |
72 | <Compile Include="IProgressNotifier.cs" /> |
|
70 | <Compile Include="IProgressNotifier.cs" /> | |
73 | <Compile Include="IPromiseT.cs" /> |
|
71 | <Compile Include="IPromiseT.cs" /> | |
74 | <Compile Include="IPromise.cs" /> |
|
72 | <Compile Include="IPromise.cs" /> | |
75 | <Compile Include="IServiceLocator.cs" /> |
|
73 | <Compile Include="IServiceLocator.cs" /> | |
76 | <Compile Include="ITaskController.cs" /> |
|
74 | <Compile Include="ITaskController.cs" /> | |
77 | <Compile Include="JSON\JSONElementContext.cs" /> |
|
75 | <Compile Include="JSON\JSONElementContext.cs" /> | |
78 | <Compile Include="JSON\JSONElementType.cs" /> |
|
76 | <Compile Include="JSON\JSONElementType.cs" /> | |
79 | <Compile Include="JSON\JSONGrammar.cs" /> |
|
77 | <Compile Include="JSON\JSONGrammar.cs" /> | |
80 | <Compile Include="JSON\JSONParser.cs" /> |
|
78 | <Compile Include="JSON\JSONParser.cs" /> | |
81 | <Compile Include="JSON\JSONScanner.cs" /> |
|
79 | <Compile Include="JSON\JSONScanner.cs" /> | |
82 | <Compile Include="JSON\JsonTokenType.cs" /> |
|
80 | <Compile Include="JSON\JsonTokenType.cs" /> | |
83 | <Compile Include="JSON\JSONWriter.cs" /> |
|
81 | <Compile Include="JSON\JSONWriter.cs" /> | |
84 | <Compile Include="JSON\JSONXmlReader.cs" /> |
|
82 | <Compile Include="JSON\JSONXmlReader.cs" /> | |
85 | <Compile Include="JSON\JSONXmlReaderOptions.cs" /> |
|
83 | <Compile Include="JSON\JSONXmlReaderOptions.cs" /> | |
86 | <Compile Include="JSON\StringTranslator.cs" /> |
|
84 | <Compile Include="JSON\StringTranslator.cs" /> | |
87 | <Compile Include="Parallels\DispatchPool.cs" /> |
|
85 | <Compile Include="Parallels\DispatchPool.cs" /> | |
88 | <Compile Include="Parallels\ArrayTraits.cs" /> |
|
86 | <Compile Include="Parallels\ArrayTraits.cs" /> | |
89 | <Compile Include="Parallels\MTQueue.cs" /> |
|
87 | <Compile Include="Parallels\MTQueue.cs" /> | |
90 | <Compile Include="Parallels\WorkerPool.cs" /> |
|
88 | <Compile Include="Parallels\WorkerPool.cs" /> | |
91 | <Compile Include="Parsing\Alphabet.cs" /> |
|
89 | <Compile Include="Parsing\Alphabet.cs" /> | |
92 | <Compile Include="Parsing\AlphabetBase.cs" /> |
|
90 | <Compile Include="Parsing\AlphabetBase.cs" /> | |
93 | <Compile Include="Parsing\AltToken.cs" /> |
|
91 | <Compile Include="Parsing\AltToken.cs" /> | |
94 | <Compile Include="Parsing\BinaryToken.cs" /> |
|
92 | <Compile Include="Parsing\BinaryToken.cs" /> | |
95 | <Compile Include="Parsing\CatToken.cs" /> |
|
93 | <Compile Include="Parsing\CatToken.cs" /> | |
96 | <Compile Include="Parsing\CDFADefinition.cs" /> |
|
94 | <Compile Include="Parsing\CDFADefinition.cs" /> | |
97 | <Compile Include="Parsing\DFABuilder.cs" /> |
|
95 | <Compile Include="Parsing\DFABuilder.cs" /> | |
98 | <Compile Include="Parsing\DFADefinitionBase.cs" /> |
|
96 | <Compile Include="Parsing\DFADefinitionBase.cs" /> | |
99 | <Compile Include="Parsing\DFAStateDescriptor.cs" /> |
|
97 | <Compile Include="Parsing\DFAStateDescriptor.cs" /> | |
100 | <Compile Include="Parsing\DFAutomaton.cs" /> |
|
98 | <Compile Include="Parsing\DFAutomaton.cs" /> | |
101 | <Compile Include="Parsing\EDFADefinition.cs" /> |
|
99 | <Compile Include="Parsing\EDFADefinition.cs" /> | |
102 | <Compile Include="Parsing\EmptyToken.cs" /> |
|
100 | <Compile Include="Parsing\EmptyToken.cs" /> | |
103 | <Compile Include="Parsing\EndToken.cs" /> |
|
101 | <Compile Include="Parsing\EndToken.cs" /> | |
104 | <Compile Include="Parsing\EnumAlphabet.cs" /> |
|
102 | <Compile Include="Parsing\EnumAlphabet.cs" /> | |
105 | <Compile Include="Parsing\Grammar.cs" /> |
|
103 | <Compile Include="Parsing\Grammar.cs" /> | |
106 | <Compile Include="Parsing\IAlphabet.cs" /> |
|
104 | <Compile Include="Parsing\IAlphabet.cs" /> | |
107 | <Compile Include="Parsing\IDFADefinition.cs" /> |
|
105 | <Compile Include="Parsing\IDFADefinition.cs" /> | |
108 | <Compile Include="Parsing\IVisitor.cs" /> |
|
106 | <Compile Include="Parsing\IVisitor.cs" /> | |
109 | <Compile Include="Parsing\ParserException.cs" /> |
|
107 | <Compile Include="Parsing\ParserException.cs" /> | |
110 | <Compile Include="Parsing\Scanner.cs" /> |
|
108 | <Compile Include="Parsing\Scanner.cs" /> | |
111 | <Compile Include="Parsing\StarToken.cs" /> |
|
109 | <Compile Include="Parsing\StarToken.cs" /> | |
112 | <Compile Include="Parsing\SymbolToken.cs" /> |
|
110 | <Compile Include="Parsing\SymbolToken.cs" /> | |
113 | <Compile Include="Parsing\Token.cs" /> |
|
111 | <Compile Include="Parsing\Token.cs" /> | |
114 | <Compile Include="SafePool.cs" /> |
|
112 | <Compile Include="SafePool.cs" /> | |
115 | <Compile Include="ServiceLocator.cs" /> |
|
113 | <Compile Include="ServiceLocator.cs" /> | |
116 | <Compile Include="TaskController.cs" /> |
|
114 | <Compile Include="TaskController.cs" /> | |
117 | <Compile Include="ProgressInitEventArgs.cs" /> |
|
115 | <Compile Include="ProgressInitEventArgs.cs" /> | |
118 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
116 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
119 | <Compile Include="Promise.cs" /> |
|
117 | <Compile Include="Promise.cs" /> | |
120 | <Compile Include="Parallels\AsyncPool.cs" /> |
|
118 | <Compile Include="Parallels\AsyncPool.cs" /> | |
121 | <Compile Include="Safe.cs" /> |
|
119 | <Compile Include="Safe.cs" /> | |
122 | <Compile Include="ValueEventArgs.cs" /> |
|
120 | <Compile Include="ValueEventArgs.cs" /> | |
123 | <Compile Include="PromiseExtensions.cs" /> |
|
121 | <Compile Include="PromiseExtensions.cs" /> | |
124 | <Compile Include="TransientPromiseException.cs" /> |
|
122 | <Compile Include="TransientPromiseException.cs" /> | |
125 | <Compile Include="SyncContextPromise.cs" /> |
|
123 | <Compile Include="SyncContextPromise.cs" /> | |
126 | </ItemGroup> |
|
124 | </ItemGroup> | |
127 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
125 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
128 | <ItemGroup /> |
|
126 | <ItemGroup /> | |
129 | <ProjectExtensions> |
|
127 | <ProjectExtensions> | |
130 | <MonoDevelop> |
|
128 | <MonoDevelop> | |
131 | <Properties> |
|
129 | <Properties> | |
132 | <Policies> |
|
130 | <Policies> | |
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" /> |
|
131 | <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" /> | |
134 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> |
|
132 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> | |
135 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> |
|
133 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> | |
136 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> |
|
134 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> | |
137 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> |
|
135 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> | |
138 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> |
|
136 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> | |
139 | <NameConventionPolicy> |
|
137 | <NameConventionPolicy> | |
140 | <Rules> |
|
138 | <Rules> | |
141 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
139 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" 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" /> |
|
140 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
143 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
141 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
144 | <RequiredPrefixes> |
|
142 | <RequiredPrefixes> | |
145 | <String>I</String> |
|
143 | <String>I</String> | |
146 | </RequiredPrefixes> |
|
144 | </RequiredPrefixes> | |
147 | </NamingRule> |
|
145 | </NamingRule> | |
148 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
146 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
149 | <RequiredSuffixes> |
|
147 | <RequiredSuffixes> | |
150 | <String>Attribute</String> |
|
148 | <String>Attribute</String> | |
151 | </RequiredSuffixes> |
|
149 | </RequiredSuffixes> | |
152 | </NamingRule> |
|
150 | </NamingRule> | |
153 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
151 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
154 | <RequiredSuffixes> |
|
152 | <RequiredSuffixes> | |
155 | <String>EventArgs</String> |
|
153 | <String>EventArgs</String> | |
156 | </RequiredSuffixes> |
|
154 | </RequiredSuffixes> | |
157 | </NamingRule> |
|
155 | </NamingRule> | |
158 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
156 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
159 | <RequiredSuffixes> |
|
157 | <RequiredSuffixes> | |
160 | <String>Exception</String> |
|
158 | <String>Exception</String> | |
161 | </RequiredSuffixes> |
|
159 | </RequiredSuffixes> | |
162 | </NamingRule> |
|
160 | </NamingRule> | |
163 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
161 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
164 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> |
|
162 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> | |
165 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
163 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
166 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> |
|
164 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> | |
167 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
165 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
168 | <RequiredPrefixes> |
|
166 | <RequiredPrefixes> | |
169 | <String>m_</String> |
|
167 | <String>m_</String> | |
170 | </RequiredPrefixes> |
|
168 | </RequiredPrefixes> | |
171 | </NamingRule> |
|
169 | </NamingRule> | |
172 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> |
|
170 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> | |
173 | <RequiredPrefixes> |
|
171 | <RequiredPrefixes> | |
174 | <String>_</String> |
|
172 | <String>_</String> | |
175 | </RequiredPrefixes> |
|
173 | </RequiredPrefixes> | |
176 | </NamingRule> |
|
174 | </NamingRule> | |
177 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
175 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
178 | <RequiredPrefixes> |
|
176 | <RequiredPrefixes> | |
179 | <String>m_</String> |
|
177 | <String>m_</String> | |
180 | </RequiredPrefixes> |
|
178 | </RequiredPrefixes> | |
181 | </NamingRule> |
|
179 | </NamingRule> | |
182 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
180 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
183 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
181 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
184 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
182 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
185 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
183 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
186 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
184 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
187 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
185 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
188 | <RequiredPrefixes> |
|
186 | <RequiredPrefixes> | |
189 | <String>T</String> |
|
187 | <String>T</String> | |
190 | </RequiredPrefixes> |
|
188 | </RequiredPrefixes> | |
191 | </NamingRule> |
|
189 | </NamingRule> | |
192 | </Rules> |
|
190 | </Rules> | |
193 | </NameConventionPolicy> |
|
191 | </NameConventionPolicy> | |
194 | </Policies> |
|
192 | </Policies> | |
195 | </Properties> |
|
193 | </Properties> | |
196 | </MonoDevelop> |
|
194 | </MonoDevelop> | |
197 | </ProjectExtensions> |
|
195 | </ProjectExtensions> | |
198 | </Project> No newline at end of file |
|
196 | </Project> |
@@ -1,324 +1,324 | |||||
1 | using Implab; |
|
1 | using Implab; | |
2 | using Implab.Parsing; |
|
2 | using Implab.Parsing; | |
3 | using System; |
|
3 | using System; | |
4 | using System.Collections.Generic; |
|
4 | using System.Collections.Generic; | |
5 | using System.Globalization; |
|
5 | using System.Globalization; | |
6 | using System.IO; |
|
6 | using System.IO; | |
7 | using System.Linq; |
|
7 | using System.Linq; | |
8 | using System.Text; |
|
8 | using System.Text; | |
9 | using System.Threading.Tasks; |
|
9 | using System.Threading.Tasks; | |
10 | using System.Xml; |
|
10 | using System.Xml; | |
11 |
|
11 | |||
12 | namespace Implab.JSON { |
|
12 | namespace Implab.JSON { | |
13 | public class JSONXmlReader : XmlReader { |
|
13 | public class JSONXmlReader : XmlReader { | |
14 |
|
14 | |||
15 | enum ValueContext { |
|
15 | enum ValueContext { | |
16 | Undefined, |
|
16 | Undefined, | |
17 | ElementStart, |
|
17 | ElementStart, | |
18 | ElementValue, |
|
18 | ElementValue, | |
19 | ElementEnd, |
|
19 | ElementEnd, | |
20 | ElementEmpty |
|
20 | ElementEmpty | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | struct LocalNameContext { |
|
23 | struct LocalNameContext { | |
24 | public string localName; |
|
24 | public string localName; | |
25 | public bool isArray; |
|
25 | public bool isArray; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | JSONParser m_parser; |
|
28 | JSONParser m_parser; | |
29 | ValueContext m_valueContext; |
|
29 | ValueContext m_valueContext; | |
30 | ReadState m_state = ReadState.Initial; |
|
30 | ReadState m_state = ReadState.Initial; | |
31 | Stack<LocalNameContext> m_localNameStack = new Stack<LocalNameContext>(); |
|
31 | Stack<LocalNameContext> m_localNameStack = new Stack<LocalNameContext>(); | |
32 | LocalNameContext m_localName; |
|
32 | LocalNameContext m_localName; | |
33 | int m_depthCorrection = 0; |
|
33 | int m_depthCorrection = 0; | |
34 |
|
34 | |||
35 | readonly string m_rootName; |
|
35 | readonly string m_rootName; | |
36 | readonly string m_prefix; |
|
36 | readonly string m_prefix; | |
37 | readonly string m_namespaceUri; |
|
37 | readonly string m_namespaceUri; | |
38 | readonly bool m_flattenArrays; |
|
38 | readonly bool m_flattenArrays; | |
39 | readonly string m_arrayItemName; |
|
39 | readonly string m_arrayItemName; | |
40 | readonly XmlNameTable m_nameTable; |
|
40 | readonly XmlNameTable m_nameTable; | |
41 |
|
41 | |||
42 | JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { |
|
42 | JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { | |
43 | m_parser = parser; |
|
43 | m_parser = parser; | |
44 |
|
44 | |||
45 | if (options != null) { |
|
45 | if (options != null) { | |
46 | m_prefix = options.NodesPrefix ?? String.Empty; |
|
46 | m_prefix = options.NodesPrefix ?? String.Empty; | |
47 | m_namespaceUri = options.NamespaceURI ?? String.Empty; |
|
47 | m_namespaceUri = options.NamespaceURI ?? String.Empty; | |
48 | m_rootName = options.RootName ?? "json"; |
|
48 | m_rootName = options.RootName ?? "json"; | |
49 | m_flattenArrays = options.FlattenArrays; |
|
49 | m_flattenArrays = options.FlattenArrays; | |
50 | m_arrayItemName = options.ArrayItemName ?? "item"; |
|
50 | m_arrayItemName = options.ArrayItemName ?? "item"; | |
51 | m_nameTable = options.NameTable ?? new NameTable(); |
|
51 | m_nameTable = options.NameTable ?? new NameTable(); | |
52 | } else { |
|
52 | } else { | |
53 | m_prefix = String.Empty; |
|
53 | m_prefix = String.Empty; | |
54 | m_namespaceUri = String.Empty; |
|
54 | m_namespaceUri = String.Empty; | |
55 | m_rootName = "json"; |
|
55 | m_rootName = "json"; | |
56 | m_flattenArrays = false; |
|
56 | m_flattenArrays = false; | |
57 | m_arrayItemName = "item"; |
|
57 | m_arrayItemName = "item"; | |
58 | m_nameTable = new NameTable(); |
|
58 | m_nameTable = new NameTable(); | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | /// <summary> |
|
62 | /// <summary> | |
63 | /// Always 0, JSON doesn't support attributes |
|
63 | /// Always 0, JSON doesn't support attributes | |
64 | /// </summary> |
|
64 | /// </summary> | |
65 | public override int AttributeCount { |
|
65 | public override int AttributeCount { | |
66 | get { return 0; } |
|
66 | get { return 0; } | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | public override string BaseURI { |
|
69 | public override string BaseURI { | |
70 | get { return String.Empty; } |
|
70 | get { return String.Empty; } | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | public override int Depth { |
|
73 | public override int Depth { | |
74 | get { |
|
74 | get { | |
75 | return m_localNameStack.Count + m_depthCorrection; |
|
75 | return m_localNameStack.Count + m_depthCorrection; | |
76 | } |
|
76 | } | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | public override bool EOF { |
|
79 | public override bool EOF { | |
80 | get { return m_parser.EOF; } |
|
80 | get { return m_parser.EOF; } | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | /// <summary> |
|
83 | /// <summary> | |
84 | /// Always throws an exception |
|
84 | /// Always throws an exception | |
85 | /// </summary> |
|
85 | /// </summary> | |
86 | /// <param name="i"></param> |
|
86 | /// <param name="i"></param> | |
87 | /// <returns></returns> |
|
87 | /// <returns></returns> | |
88 | public override string GetAttribute(int i) { |
|
88 | public override string GetAttribute(int i) { | |
89 | throw new ArgumentOutOfRangeException(); |
|
89 | throw new ArgumentOutOfRangeException(); | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | /// <summary> |
|
92 | /// <summary> | |
93 | /// Always returns empty string |
|
93 | /// Always returns empty string | |
94 | /// </summary> |
|
94 | /// </summary> | |
95 | /// <param name="name"></param> |
|
95 | /// <param name="name"></param> | |
96 | /// <param name="namespaceURI"></param> |
|
96 | /// <param name="namespaceURI"></param> | |
97 | /// <returns></returns> |
|
97 | /// <returns></returns> | |
98 | public override string GetAttribute(string name, string namespaceURI) { |
|
98 | public override string GetAttribute(string name, string namespaceURI) { | |
99 | return String.Empty; |
|
99 | return String.Empty; | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | /// <summary> |
|
102 | /// <summary> | |
103 | /// Always returns empty string |
|
103 | /// Always returns empty string | |
104 | /// </summary> |
|
104 | /// </summary> | |
105 | /// <param name="name"></param> |
|
105 | /// <param name="name"></param> | |
106 | /// <returns></returns> |
|
106 | /// <returns></returns> | |
107 | public override string GetAttribute(string name) { |
|
107 | public override string GetAttribute(string name) { | |
108 | return String.Empty; |
|
108 | return String.Empty; | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | public override bool IsEmptyElement { |
|
111 | public override bool IsEmptyElement { | |
112 | get { return m_parser.ElementType == JSONElementType.Value && m_valueContext == ValueContext.ElementEmpty; } |
|
112 | get { return m_parser.ElementType == JSONElementType.Value && m_valueContext == ValueContext.ElementEmpty; } | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | public override string LocalName { |
|
115 | public override string LocalName { | |
116 | get { return m_localName.localName; } |
|
116 | get { return m_localName.localName; } | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | public override string LookupNamespace(string prefix) { |
|
119 | public override string LookupNamespace(string prefix) { | |
120 | if (String.IsNullOrEmpty(prefix) || prefix == m_prefix) |
|
120 | if (String.IsNullOrEmpty(prefix) || prefix == m_prefix) | |
121 | return m_namespaceUri; |
|
121 | return m_namespaceUri; | |
122 | else |
|
122 | else | |
123 | return String.Empty; |
|
123 | return String.Empty; | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | public override bool MoveToAttribute(string name, string ns) { |
|
126 | public override bool MoveToAttribute(string name, string ns) { | |
127 | return false; |
|
127 | return false; | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | public override bool MoveToAttribute(string name) { |
|
130 | public override bool MoveToAttribute(string name) { | |
131 | return false; |
|
131 | return false; | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | public override bool MoveToElement() { |
|
134 | public override bool MoveToElement() { | |
135 | return false; |
|
135 | return false; | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | public override bool MoveToFirstAttribute() { |
|
138 | public override bool MoveToFirstAttribute() { | |
139 | return false; |
|
139 | return false; | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | public override bool MoveToNextAttribute() { |
|
142 | public override bool MoveToNextAttribute() { | |
143 | return false; |
|
143 | return false; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | public override XmlNameTable NameTable { |
|
146 | public override XmlNameTable NameTable { | |
147 | get { return m_nameTable; } |
|
147 | get { return m_nameTable; } | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | public override string NamespaceURI { |
|
150 | public override string NamespaceURI { | |
151 | get { return m_namespaceUri; } |
|
151 | get { return m_namespaceUri; } | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | public override XmlNodeType NodeType { |
|
154 | public override XmlNodeType NodeType { | |
155 | get { |
|
155 | get { | |
156 | switch (m_parser.ElementType) { |
|
156 | switch (m_parser.ElementType) { | |
157 | case JSONElementType.BeginObject: |
|
157 | case JSONElementType.BeginObject: | |
158 | case JSONElementType.BeginArray: |
|
158 | case JSONElementType.BeginArray: | |
159 | return XmlNodeType.Element; |
|
159 | return XmlNodeType.Element; | |
160 | case JSONElementType.EndObject: |
|
160 | case JSONElementType.EndObject: | |
161 | case JSONElementType.EndArray: |
|
161 | case JSONElementType.EndArray: | |
162 | return XmlNodeType.EndElement; |
|
162 | return XmlNodeType.EndElement; | |
163 | case JSONElementType.Value: |
|
163 | case JSONElementType.Value: | |
164 | switch (m_valueContext) { |
|
164 | switch (m_valueContext) { | |
165 | case ValueContext.ElementStart: |
|
165 | case ValueContext.ElementStart: | |
166 | case ValueContext.ElementEmpty: |
|
166 | case ValueContext.ElementEmpty: | |
167 | return XmlNodeType.Element; |
|
167 | return XmlNodeType.Element; | |
168 | case ValueContext.ElementValue: |
|
168 | case ValueContext.ElementValue: | |
169 | return XmlNodeType.Text; |
|
169 | return XmlNodeType.Text; | |
170 | case ValueContext.ElementEnd: |
|
170 | case ValueContext.ElementEnd: | |
171 | return XmlNodeType.EndElement; |
|
171 | return XmlNodeType.EndElement; | |
172 | default: |
|
172 | default: | |
173 | throw new InvalidOperationException(); |
|
173 | throw new InvalidOperationException(); | |
174 | } |
|
174 | } | |
175 | default: |
|
175 | default: | |
176 | throw new InvalidOperationException(); |
|
176 | throw new InvalidOperationException(); | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | public override string Prefix { |
|
181 | public override string Prefix { | |
182 | get { return m_prefix; } |
|
182 | get { return m_prefix; } | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | public override bool Read() { |
|
185 | public override bool Read() { | |
186 | if (m_state != System.Xml.ReadState.Interactive && m_state != System.Xml.ReadState.Initial) |
|
186 | if (m_state != System.Xml.ReadState.Interactive && m_state != System.Xml.ReadState.Initial) | |
187 | return false; |
|
187 | return false; | |
188 |
|
188 | |||
189 | if (m_state == ReadState.Initial) |
|
189 | if (m_state == ReadState.Initial) | |
190 | m_state = System.Xml.ReadState.Interactive; |
|
190 | m_state = System.Xml.ReadState.Interactive; | |
191 |
|
191 | |||
192 | try { |
|
192 | try { | |
193 | switch (m_parser.ElementType) { |
|
193 | switch (m_parser.ElementType) { | |
194 | case JSONElementType.Value: |
|
194 | case JSONElementType.Value: | |
195 | switch (m_valueContext) { |
|
195 | switch (m_valueContext) { | |
196 | case ValueContext.ElementStart: |
|
196 | case ValueContext.ElementStart: | |
197 | SetLocalName(String.Empty); |
|
197 | SetLocalName(String.Empty); | |
198 | m_valueContext = ValueContext.ElementValue; |
|
198 | m_valueContext = ValueContext.ElementValue; | |
199 | return true; |
|
199 | return true; | |
200 | case ValueContext.ElementValue: |
|
200 | case ValueContext.ElementValue: | |
201 | RestoreLocalName(); |
|
201 | RestoreLocalName(); | |
202 | m_valueContext = ValueContext.ElementEnd; |
|
202 | m_valueContext = ValueContext.ElementEnd; | |
203 | return true; |
|
203 | return true; | |
204 | case ValueContext.ElementEmpty: |
|
204 | case ValueContext.ElementEmpty: | |
205 | case ValueContext.ElementEnd: |
|
205 | case ValueContext.ElementEnd: | |
206 | RestoreLocalName(); |
|
206 | RestoreLocalName(); | |
207 | break; |
|
207 | break; | |
208 | } |
|
208 | } | |
209 | break; |
|
209 | break; | |
210 | case JSONElementType.EndArray: |
|
210 | case JSONElementType.EndArray: | |
211 | case JSONElementType.EndObject: |
|
211 | case JSONElementType.EndObject: | |
212 | RestoreLocalName(); |
|
212 | RestoreLocalName(); | |
213 | break; |
|
213 | break; | |
214 | } |
|
214 | } | |
215 | string itemName = m_parser.ElementType == JSONElementType.None ? m_rootName : m_flattenArrays ? m_localName.localName : m_arrayItemName; |
|
215 | string itemName = m_parser.ElementType == JSONElementType.None ? m_rootName : m_flattenArrays ? m_localName.localName : m_arrayItemName; | |
216 | while (m_parser.Read()) { |
|
216 | while (m_parser.Read()) { | |
217 | if (!String.IsNullOrEmpty(m_parser.ElementName)) |
|
217 | if (!String.IsNullOrEmpty(m_parser.ElementName)) | |
218 | itemName = m_parser.ElementName; |
|
218 | itemName = m_parser.ElementName; | |
219 |
|
219 | |||
220 | switch (m_parser.ElementType) { |
|
220 | switch (m_parser.ElementType) { | |
221 | case JSONElementType.BeginArray: |
|
221 | case JSONElementType.BeginArray: | |
222 | if (m_flattenArrays && !m_localName.isArray) { |
|
222 | if (m_flattenArrays && !m_localName.isArray) { | |
223 | m_depthCorrection--; |
|
223 | m_depthCorrection--; | |
224 | SetLocalName(itemName, true); |
|
224 | SetLocalName(itemName, true); | |
225 | continue; |
|
225 | continue; | |
226 | } else { |
|
226 | } else { | |
227 | SetLocalName(itemName, true); |
|
227 | SetLocalName(itemName, true); | |
228 | } |
|
228 | } | |
229 | break; |
|
229 | break; | |
230 | case JSONElementType.BeginObject: |
|
230 | case JSONElementType.BeginObject: | |
231 | SetLocalName(itemName); |
|
231 | SetLocalName(itemName); | |
232 | break; |
|
232 | break; | |
233 | case JSONElementType.EndArray: |
|
233 | case JSONElementType.EndArray: | |
234 | if (m_flattenArrays && !m_localNameStack.Peek().isArray) { |
|
234 | if (m_flattenArrays && !m_localNameStack.Peek().isArray) { | |
235 | RestoreLocalName(); |
|
235 | RestoreLocalName(); | |
236 | m_depthCorrection++; |
|
236 | m_depthCorrection++; | |
237 | continue; |
|
237 | continue; | |
238 | } |
|
238 | } | |
239 | break; |
|
239 | break; | |
240 | case JSONElementType.EndObject: |
|
240 | case JSONElementType.EndObject: | |
241 | break; |
|
241 | break; | |
242 | case JSONElementType.Value: |
|
242 | case JSONElementType.Value: | |
243 | SetLocalName(itemName); |
|
243 | SetLocalName(itemName); | |
244 | m_valueContext = m_parser.ElementValue == null ? ValueContext.ElementEmpty : ValueContext.ElementStart; |
|
244 | m_valueContext = m_parser.ElementValue == null ? ValueContext.ElementEmpty : ValueContext.ElementStart; | |
245 | break; |
|
245 | break; | |
246 | default: |
|
246 | default: | |
247 | break; |
|
247 | break; | |
248 | } |
|
248 | } | |
249 | return true; |
|
249 | return true; | |
250 | } |
|
250 | } | |
251 |
|
251 | |||
252 | m_state = System.Xml.ReadState.EndOfFile; |
|
252 | m_state = System.Xml.ReadState.EndOfFile; | |
253 | return false; |
|
253 | return false; | |
254 | } catch { |
|
254 | } catch { | |
255 | m_state = System.Xml.ReadState.Error; |
|
255 | m_state = System.Xml.ReadState.Error; | |
256 | throw; |
|
256 | throw; | |
257 | } |
|
257 | } | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | public override bool ReadAttributeValue() { |
|
260 | public override bool ReadAttributeValue() { | |
261 | return false; |
|
261 | return false; | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | public override ReadState ReadState { |
|
264 | public override ReadState ReadState { | |
265 | get { return m_state; } |
|
265 | get { return m_state; } | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | public override void ResolveEntity() { |
|
268 | public override void ResolveEntity() { | |
269 | // do nothing |
|
269 | // do nothing | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | public override string Value { |
|
272 | public override string Value { | |
273 | get { |
|
273 | get { | |
274 | if (m_parser.ElementValue == null) |
|
274 | if (m_parser.ElementValue == null) | |
275 | return String.Empty; |
|
275 | return String.Empty; | |
276 | if (Convert.GetTypeCode(m_parser.ElementValue) == TypeCode.Double) |
|
276 | if (Convert.GetTypeCode(m_parser.ElementValue) == TypeCode.Double) | |
277 | return ((double)m_parser.ElementValue).ToString(CultureInfo.InvariantCulture); |
|
277 | return ((double)m_parser.ElementValue).ToString(CultureInfo.InvariantCulture); | |
278 | else |
|
278 | else | |
279 |
return |
|
279 | return m_parser.ElementValue.ToString(); | |
280 | } |
|
280 | } | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | void SetLocalName(string name) { |
|
283 | void SetLocalName(string name) { | |
284 | m_localNameStack.Push(m_localName); |
|
284 | m_localNameStack.Push(m_localName); | |
285 | m_localName.localName = name; |
|
285 | m_localName.localName = name; | |
286 | m_localName.isArray = false; |
|
286 | m_localName.isArray = false; | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 | void SetLocalName(string name, bool isArray) { |
|
289 | void SetLocalName(string name, bool isArray) { | |
290 | m_localNameStack.Push(m_localName); |
|
290 | m_localNameStack.Push(m_localName); | |
291 | m_localName.localName = name; |
|
291 | m_localName.localName = name; | |
292 | m_localName.isArray = isArray; |
|
292 | m_localName.isArray = isArray; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | void RestoreLocalName() { |
|
295 | void RestoreLocalName() { | |
296 | m_localName = m_localNameStack.Pop(); |
|
296 | m_localName = m_localNameStack.Pop(); | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | public override void Close() { |
|
299 | public override void Close() { | |
300 |
|
300 | |||
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | protected override void Dispose(bool disposing) { |
|
303 | protected override void Dispose(bool disposing) { | |
304 | if (disposing) { |
|
304 | if (disposing) { | |
305 | m_parser.Dispose(); |
|
305 | m_parser.Dispose(); | |
306 | } |
|
306 | } | |
307 | base.Dispose(disposing); |
|
307 | base.Dispose(disposing); | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | public static JSONXmlReader Create(string file, JSONXmlReaderOptions options) { |
|
310 | public static JSONXmlReader Create(string file, JSONXmlReaderOptions options) { | |
311 | return Create(File.OpenText(file), options); |
|
311 | return Create(File.OpenText(file), options); | |
312 | } |
|
312 | } | |
313 |
|
313 | |||
314 | public static JSONXmlReader Create(TextReader reader, JSONXmlReaderOptions options) { |
|
314 | public static JSONXmlReader Create(TextReader reader, JSONXmlReaderOptions options) { | |
315 | return new JSONXmlReader(new JSONParser(reader, true), options); |
|
315 | return new JSONXmlReader(new JSONParser(reader, true), options); | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | public static JSONXmlReader Create(Stream stream, JSONXmlReaderOptions options) { |
|
318 | public static JSONXmlReader Create(Stream stream, JSONXmlReaderOptions options) { | |
319 | Safe.ArgumentNotNull(stream, "stream"); |
|
319 | Safe.ArgumentNotNull(stream, "stream"); | |
320 | // HACK don't dispose StreaReader to keep stream opened |
|
320 | // HACK don't dispose StreaReader to keep stream opened | |
321 | return Create(new StreamReader(stream), options); |
|
321 | return Create(new StreamReader(stream), options); | |
322 | } |
|
322 | } | |
323 | } |
|
323 | } | |
324 | } |
|
324 | } |
General Comments 0
You need to be logged in to leave comments.
Login now