Struct WidgetMode
- Namespace
- Cloudflare.NET.Turnstile.Models
- Assembly
- Cloudflare.NET.dll
Turnstile widget mode determining user interaction level.
Widget modes control how the Turnstile challenge is presented to users, ranging from fully invisible to requiring explicit user interaction.
[JsonConverter(typeof(ExtensibleEnumConverter<WidgetMode>))]
public readonly struct WidgetMode : IExtensibleEnum<WidgetMode>, IEquatable<WidgetMode>
- Implements
- Inherited Members
Examples
// Using a known mode
var mode = WidgetMode.Invisible;
// Checking widget mode
if (widget.Mode == WidgetMode.Managed) { ... }
// Using implicit conversion from string
WidgetMode customMode = "future-mode";
Remarks
This is an extensible enum that provides IntelliSense for known values while allowing custom values for new modes that may be added to the Cloudflare API in the future.
Constructors
WidgetMode(string)
Creates a new WidgetMode with the specified value.
public WidgetMode(string value)
Parameters
valuestringThe string value representing the mode.
Exceptions
- ArgumentNullException
Thrown when
valueis null.
Properties
Invisible
No visible challenge - automatic verification.
public static WidgetMode Invisible { get; }
Property Value
Remarks
The widget runs completely in the background without any user interaction. Best for maintaining user experience while still providing bot protection.
Managed
Cloudflare manages when to show challenge.
public static WidgetMode Managed { get; }
Property Value
Remarks
Cloudflare dynamically decides whether to show a challenge based on various signals. This provides a balance between security and user experience.
NonInteractive
Always requires user interaction.
public static WidgetMode NonInteractive { get; }
Property Value
Remarks
The widget always displays a challenge that requires user action. Use when you need explicit user verification for high-security scenarios.
Value
Gets the underlying string value of this mode.
public string Value { get; }
Property Value
Methods
Create(string)
Creates a new instance of the extensible enum from the specified string value.
public static WidgetMode Create(string value)
Parameters
valuestringThe string value to wrap.
Returns
- WidgetMode
A new instance of WidgetMode containing the specified value.
Equals(WidgetMode)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(WidgetMode other)
Parameters
otherWidgetModeAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(WidgetMode, WidgetMode)
Determines whether two WidgetMode values are equal.
public static bool operator ==(WidgetMode left, WidgetMode right)
Parameters
leftWidgetModerightWidgetMode
Returns
implicit operator string(WidgetMode)
Implicitly converts a WidgetMode to its string value.
public static implicit operator string(WidgetMode mode)
Parameters
modeWidgetModeThe mode to convert.
Returns
implicit operator WidgetMode(string)
Implicitly converts a string to a WidgetMode.
public static implicit operator WidgetMode(string value)
Parameters
valuestringThe string value to convert.
Returns
operator !=(WidgetMode, WidgetMode)
Determines whether two WidgetMode values are not equal.
public static bool operator !=(WidgetMode left, WidgetMode right)
Parameters
leftWidgetModerightWidgetMode