18using System.Collections.Generic;
55 private readonly List<StorageAction> _actions =
new List<StorageAction>();
61 internal GPALUrl(
string url =
null)
63 _url =
string.IsNullOrWhiteSpace(url) ?
"https://google.com" : url;
69 public string Url => _url;
79 public static implicit
operator string(GPALUrl url) => url?._url;
81 private static int implicitCount = 0;
90 public static implicit
operator GPALUrl(
string url)
95 if (0 == implicitCount++)
96 GPAL.
PublishSimpleEvent(GPALEventType.DEBUG, $
"Implicit GPALUrl conversions lack equality, even if Urls match. Create instance using GPAL.Url for reuse.");
98 return new GPALUrl(url);
108 _url =
string.IsNullOrWhiteSpace(url) ?
"https://google.com" : url;
130 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(data))
133 int lastIndex = _actions.Count - 1;
135 _actions[lastIndex].Data = data;
148 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(key))
151 int lastIndex = _actions.Count - 1;
153 _actions[lastIndex].Key = key;
165 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(path))
168 int lastIndex = _actions.Count - 1;
170 _actions[lastIndex].Path = path;
182 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(domain))
185 int lastIndex = _actions.Count - 1;
187 _actions[lastIndex].Domain = domain;
199 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(storeName))
202 int lastIndex = _actions.Count - 1;
204 _actions[lastIndex].StoreName = storeName;
216 if (_actions.Count == 0 ||
string.IsNullOrWhiteSpace(userDefined))
219 int lastIndex = _actions.Count - 1;
221 _actions[lastIndex].UserDefined = userDefined;
228 if (_actions.Count == 0)
231 int lastIndex = _actions.Count - 1;
233 _actions[lastIndex].DeleteAcrossOrigins = trueOrFalse;
245 _actions.Add(storageAction);
254 public List<StorageAction>
Add(List<StorageAction> storageActions)
256 _actions.AddRange(storageActions);
273 public class StorageAction
275 public StorageAction()
279 public StorageAction(StorageAction action)
293 public WebsiteStorageAction
Action {
get;
internal set; } = WebsiteStorageAction.notSet;
298 public WebsiteStorageType
StorageType {
get;
internal set; } = WebsiteStorageType.notSet;
303 public string Key {
get;
internal set; }
308 public string Path {
get;
internal set; }
313 public string Domain {
get;
internal set; }
320 internal string _data =
null;
330 internal set => _data = value;
IAllowGPALUrlStorageItemConfig WithStorageKey(string key)
Specifies the key for the most recently added storage action.
IAllowGPALUrlStorageItemConfig WithStoragePath(string path)
Specifies the path restriction for the most recently added storage action (mainly for cookies).
IAllowGPALUrlStorageItemConfig WithDeleteAcrossOrigins(bool trueOrFalse)
OttoMagic Only: For delete operations without a domain, limit to origin? true = delete across origins...
IAllowGPALUrlStorageItemConfig WithStorageDomain(string domain)
Specifies the domain restriction for the most recently added storage action (mainly cookies).
IGPALUrl ToGPALObject()
Returns this instance typed as IGPALUrl.
IAllowGPALUrlStorageType ForUrl(string url)
Changes (or sets) the target URL for this builder instance.
string Url
Gets the target URL string.
List< StorageAction > Add(StorageAction storageAction)
Adds a fully-configured StorageAction to the list.
List< StorageAction > Add(List< StorageAction > storageActions)
Adds multiple fully-configured StorageAction items.
IAllowGPALUrlStorageItemConfig WithStorageType(WebsiteStorageType type)
Specify the storage type for this storage action.
IAllowGPALUrlStorageItemConfig WithStorageData(string data)
Specifies the data to set.
IAllowGPALUrlStorageItemConfig WithStorageStoreName(string storeName)
Specifies the IndexedDB store name for the most recently added action.
IAllowGPALUrlStorageItemConfig WithUserDefined(string userDefined)
Specifies the data to set.
Represents a single storage-related action to perform before navigating to a URL.
bool DeleteAcrossOrigins
OttoMagic Only: For delete operations without a domain, limit to origin? true = delete across origins...
WebsiteStorageType StorageType
The target storage type (cookies, localStorage, indexedDb, etc.).
string Key
Key name for localStorage, sessionStorage, IndexedDB, or cookie name.
bool IncludeProvenance
For wildcard storage gets returning multiple elements. If set to true, return domain,...
WebsiteStorageAction Action
The action to perform: "get", "set", or "delete".
string UserDefined
User defined data strictly used for filtering in GPAL, can store any data of value.
string StoreName
IndexedDB object store name.
string Domain
Domain restriction (primarily for cookies).
string Path
Path restriction (primarily for cookies).
string Data
Value to get/set (used when Action = "get" or "set"). NOTE: context sensitive (json) data NOTE: Data ...
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
static void PublishSimpleEvent(GPALEventType gPALEventType, string msg, dynamic gPALObject=null, Enums.GPALObjectType gPALObjectType=GPALObjectType.None, Exception ex=null)
Publish a message to either the information channel or exception channel (if exception passed in) Pub...
Interface after deleting a specific item - allows optional path/domain.
Interface after URL is set - allows selecting storage type.
Public interface exposed to consumers.
IReadOnlyList< StorageAction > GetActions()
List of storage actions to perform before navigation.