Skip to content

Commit

Permalink
feat: ValueSet
Browse files Browse the repository at this point in the history
  • Loading branch information
pkar70 committed Apr 26, 2022
1 parent da4338d commit dd54b5c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
40 changes: 37 additions & 3 deletions src/Uno.Foundation/Collections/ValueSet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if !NET461
#nullable enable
#if !NET461
#pragma warning disable 67
using System;
using global::System.Collections;
Expand All @@ -10,7 +11,40 @@ namespace Windows.Foundation.Collections
{
public sealed partial class ValueSet : IPropertySet, IObservableMap<string, object>, IDictionary<string, object>, IEnumerable<KeyValuePair<string, object>>
{

private Dictionary<string, object> _dictionary;

public ValueSet()
{
_dictionary = new Dictionary<string, object>();
}

public void Add(string key, object value) => _dictionary.Add(key, value);
public bool ContainsKey(string key) => _dictionary.ContainsKey(key);
public bool Remove(string key) => _dictionary.Remove(key);
public bool TryGetValue(string key, out object value)
{
if (key is null)
{
throw new ArgumentNullException("TryGetValue with null key");
}
return _dictionary.TryGetValue(key, out value);
}
public ICollection<string> Keys => _dictionary.Keys;
public ICollection<object> Values => _dictionary.Values;
public void Add(KeyValuePair<string, object> item) => _dictionary.Add(item.Key, item.Value);
public void Clear() => _dictionary.Clear();
public bool Remove(KeyValuePair<string, object> item) => Remove(item.Key);
public int Count => _dictionary.Count;

// current implementation is always read/write
public bool IsReadOnly => false;

// auto-generated by VStudio, as required by IDictionary
object IDictionary<string, object>.this[string key]
{
get => _dictionary[key];
set => _dictionary[key] = value;
}
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,39 @@ public ValueSet()
// Processing: Windows.Foundation.Collections.IPropertySet
// Processing: Windows.Foundation.Collections.IObservableMap<string, object>
// Processing: System.Collections.Generic.IDictionary<string, object>
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.IDictionary<string, object>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Add( string key, object value)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.IDictionary<string, object>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool ContainsKey( string key)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.IDictionary<string, object>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool Remove( string key)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.IDictionary<string, object>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool TryGetValue( string key, out object value)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public object this[string key]
{
Expand All @@ -100,7 +100,7 @@ public object this[string key]
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.ICollection<string> Keys
{
Expand All @@ -110,7 +110,7 @@ public object this[string key]
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.ICollection<object> Values
{
Expand All @@ -121,15 +121,15 @@ public object this[string key]
}
#endif
// Processing: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Add( global::System.Collections.Generic.KeyValuePair<string, object> item)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Clear()
Expand All @@ -153,15 +153,15 @@ public void CopyTo( global::System.Collections.Generic.KeyValuePair<string, obje
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
// DeclaringType: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool Remove( global::System.Collections.Generic.KeyValuePair<string, object> item)
{
throw new global::System.NotSupportedException();
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public int Count
{
Expand All @@ -171,7 +171,7 @@ public int Count
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsReadOnly
{
Expand Down

0 comments on commit dd54b5c

Please sign in to comment.