Table of Contents

Class WinformsCoreControl

Namespace
Ranorex
Assembly
Ranorex.Plugin.WinForms.Core.dll

Capability of a .NET Core Windows Forms control.

public class WinformsCoreControl : Adapter, IAdapter
Inheritance
WinformsCoreControl
Implements
Inherited Members

Constructors

WinformsCoreControl()

Creates a new WinformsCoreControl adapter instance. This constructor is used internally by the Ranorex Core Framework for performance issues!

protected WinformsCoreControl()

WinformsCoreControl(Element)

Creates a new WinformsCoreControl adapter instance.

public WinformsCoreControl(Element element)

Parameters

element Element

The element to create the adapter for.

Exceptions

NullReferenceException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

Properties

ControlName

The name of the Windows Forms control.

public virtual string ControlName { get; }

Property Value

string

ControlText

The text of the Windows Forms control.

public virtual string ControlText { get; set; }

Property Value

string

Exceptions

SetAttributeFailedException

Thrown if setting the attribute value failed.

ControlType

The full type name of the Windows Forms control.

public virtual string ControlType { get; }

Property Value

string

ControlTypeName

The (short) type name of the Windows Forms control.

public virtual string ControlTypeName { get; }

Property Value

string

FullTypeLineage

The full type name lineage of the Windows Forms control.

public virtual string[] FullTypeLineage { get; }

Property Value

string[]

this[string]

Gets or sets the (serializable) value of the specified control property.

public object this[string name] { get; set; }

Parameters

name string

The name of the property.

Property Value

object

The value of the property.

Remarks

The getter of this property calls the GetPropertyValue(string) method, the setter calls the SetPropertyValue(string, object) method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

RequiredCapabilities

Capabilities required by the adapter implementation.

protected override string[] RequiredCapabilities { get; }

Property Value

string[]

Methods

FromElement(Element)

Converts an Element to an instance of this class.

public static WinformsCoreControl FromElement(Element element)

Parameters

element Element

The element to convert.

Returns

WinformsCoreControl

The WinformsCoreControl.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

FromPath(string)

Converts a string to an instance of this class by searching the root.

public static WinformsCoreControl FromPath(string path)

Parameters

path string

The search path.

Returns

WinformsCoreControl

The WinformsCoreControl.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

GetPropertyValue(BindingFlags, string)

Gets the (serializable) value of the specified control property.

public virtual object GetPropertyValue(BindingFlags flags, string name)

Parameters

flags BindingFlags

A combination of flags that further specify which property to get.

name string

The name of the property.

Returns

object

The value of the property.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue(string)

Gets the (serializable) value of the specified control property.

public virtual object GetPropertyValue(string name)

Parameters

name string

The name of the property.

Returns

object

The value of the property.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue<T>(BindingFlags, string)

Gets the (serializable) value of the specified control property.

public T GetPropertyValue<T>(BindingFlags flags, string name)

Parameters

flags BindingFlags

A combination of flags that further specify which property to get.

name string

The name of the property.

Returns

T

The value of the named property or the default value of the specified type if the returned value is null and the specified type is a value type.

Type Parameters

T

The type of the property to get the value from.

Exceptions

InvalidCastException

If the returned value cannot be casted to the specified type.

ActionFailedException

Thrown if invoking the action failed.

GetPropertyValue<T>(string)

Gets the (serializable) value of the specified control property.

public T GetPropertyValue<T>(string name)

Parameters

name string

The name of the property.

Returns

T

The value of the named property or the default value of the specified type if the returned value is null and the specified type is a value type.

Type Parameters

T

The type of the property to get the value from.

Exceptions

InvalidCastException

If the returned value cannot be casted to the specified type.

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(BindingFlags, string, object[])

Invokes the specified method on the control. All parameters and the return value need to be serializable.

public object InvokeMethod(BindingFlags flags, string name, object[] args)

Parameters

flags BindingFlags

A combination of flags that further specify which method to invoke.

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

Returns

object

The (serializable) return value of the invoked method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(BindingFlags, string, object[], Duration)

Invokes the specified method on the control. All parameters and the return value need to be serializable.

public virtual object InvokeMethod(BindingFlags flags, string name, object[] args, Duration timeout)

Parameters

flags BindingFlags

A combination of flags that further specify which method to invoke.

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

timeout Duration

The timeout for this action. The action will return after the timeout even if the method has not yet finished executing.

Returns

object

The (serializable) return value of the invoked method.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(string)

Invokes the specified method on the control.

public object InvokeMethod(string name)

Parameters

name string

The name of the method to invoke.

Returns

object

The (serializable) return value of the invoked method.

Remarks

Use this method to invoke public instance methods without arguments on a control.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeMethod(string, object[])

Invokes the specified method on the control. All parameters need to be serializable.

public object InvokeMethod(string name, object[] args)

Parameters

name string

The name of the method to invoke.

args object[]

The (serializable) values passed as parameters to the method.

Returns

object

The (serializable) return value of the invoked method.

Remarks

Use this method to invoke public instance methods on a control.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeRemotely(string, string, string, object)

Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.

public object InvokeRemotely(string assemblyPath, string fullTypeName, string methodName, object inputData)

Parameters

assemblyPath string

The full path to the assembly which contains the remote method to be called at the remote control.

fullTypeName string

The full name of the type which contains the remote method to be called at the remote control.

methodName string

The name of the method which should be called at the remote control.

inputData object

The (serializable) input data passed to the remote method at the remote control.

Returns

object

The (serializable) return value of the remotely invoked delegate.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

InvokeRemotely(string, string, string, object, Duration)

Invokes the delegate remotely at the control. All parameters and the return value need to be serializable.

public virtual object InvokeRemotely(string assemblyPath, string fullTypeName, string methodName, object inputData, Duration timeout)

Parameters

assemblyPath string

The full path to the assembly which contains the remote method to be called at the remote control.

fullTypeName string

The full name of the type which contains the remote method to be called at the remote control.

methodName string

The name of the method which should be called at the remote control.

inputData object

The (serializable) input data passed to the remote method at the remote control.

timeout Duration

The timeout for this action. The action will return after the timeout even if the delegate has not yet finished executing.

Returns

object

The (serializable) return value of the remotely invoked delegate.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

SetPropertyValue(BindingFlags, string, object)

Sets the (serializable) value of the specified control property.

public virtual void SetPropertyValue(BindingFlags flags, string name, object value)

Parameters

flags BindingFlags

A combination of flags that further specify which property to set.

name string

The name of the property.

value object

The value (must be serializable) to set the property to.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

SetPropertyValue(string, object)

Sets the (serializable) value of the specified control property.

public virtual void SetPropertyValue(string name, object value)

Parameters

name string

The name of the property.

value object

The value (must be serializable) to set the property to.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

Operators

implicit operator WinformsCoreControl(Element)

Implicitly converts an Element to an instance of this class.

public static implicit operator WinformsCoreControl(Element element)

Parameters

element Element

The element to convert.

Returns

WinformsCoreControl

The WinformsCoreControl.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

implicit operator WinformsCoreControl(string)

Implicitly converts a string to an instance of this class by searching the root.

public static implicit operator WinformsCoreControl(string path)

Parameters

path string

The search path.

Returns

WinformsCoreControl

The WinformsCoreControl.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.