Skip to content

Commit 5c2d4b9

Browse files
committed
Added the storage interface
1 parent 13a45ab commit 5c2d4b9

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

AngleSharp.Io/AngleSharp.Io.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
<Compile Include="ConfigurationExtensions.cs" />
5050
<Compile Include="Dom\WebSocketReadyState.cs" />
5151
<Compile Include="Extensions\GeneralExtensions.cs" />
52-
<Compile Include="Dom\IWebSocket.cs" />
52+
<Compile Include="Dom\WebSocket.cs" />
53+
<Compile Include="Interfaces\IStorage.cs" />
5354
<Compile Include="Network\HttpClientRequester.cs" />
5455
<Compile Include="Network\Response.cs" />
5556
<Compile Include="Properties\AssemblyInfo.cs" />
File renamed without changes.

AngleSharp.Io/Interfaces/IStorage.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace AngleSharp.Io.Dom
2+
{
3+
using AngleSharp.Attributes;
4+
using System;
5+
6+
/// <summary>
7+
/// Represents the Storage interface. For more information see:
8+
/// http://www.w3.org/TR/webstorage/#the-storage-interface
9+
/// </summary>
10+
[DomName("Storage")]
11+
[DomExposed("Window")]
12+
public interface IStorage
13+
{
14+
/// <summary>
15+
/// Gets the number of stored keys.
16+
/// </summary>
17+
[DomName("length")]
18+
Int32 Length { get; }
19+
20+
/// <summary>
21+
/// Gets the key at the given index, if any.
22+
/// </summary>
23+
/// <param name="index">The index of the key.</param>
24+
/// <returns>The key or null.</returns>
25+
[DomName("key")]
26+
String Key(Int32 index);
27+
28+
/// <summary>
29+
/// Gets or sets the item's value.
30+
/// </summary>
31+
/// <param name="key">The key of the item.</param>
32+
/// <returns>The value if any.</returns>
33+
[DomAccessor(Accessors.Getter | Accessors.Setter)]
34+
String this[String key] { get; set; }
35+
36+
/// <summary>
37+
/// Removes the item with the specified key.
38+
/// </summary>
39+
/// <param name="key">The key of the item to remove.</param>
40+
[DomAccessor(Accessors.Deleter)]
41+
[DomName("removeItem")]
42+
void Remove(String key);
43+
44+
/// <summary>
45+
/// Clears all items from the storage.
46+
/// </summary>
47+
[DomName("clear")]
48+
void Clear();
49+
}
50+
}

0 commit comments

Comments
 (0)