Tutorial by Examples: attribut

[Header( "My variables" )] public string MyString; [HideInInspector] public string MyHiddenString; [Multiline( 5 )] public string MyMultilineString; [TextArea( 2, 8 )] public string MyTextArea; [Space( 15 )] public int MyInt; [Range( 2.5f, 12.5f )] public float MyFlo...
[DisallowMultipleComponent] [RequireComponent( typeof( Rigidbody ) )] public class AttributesExample : MonoBehaviour { [...] } [DisallowMultipleComponent] The DisallowMultipleComponent attribute prevents users adding multiple instances of this component to one GameObject. [Requi...
[ExecuteInEditMode] public class AttributesExample : MonoBehaviour { [RuntimeInitializeOnLoadMethod] private static void FooBar() { [...] } [RuntimeInitializeOnLoadMethod( RuntimeInitializeLoadType.BeforeSceneLoad )] private static void Foo() { ...
[AddComponentMenu( "Examples/Attribute Example" )] public class AttributesExample : MonoBehaviour { [ContextMenuItem( "My Field Action", "MyFieldContextAction" )] public string MyString; private void MyFieldContextAction() { [...] ...
[InitializeOnLoad] public class AttributesExample : MonoBehaviour { static AttributesExample() { [...] } [InitializeOnLoadMethod] private static void Foo() { [...] } } [InitializeOnLoad] public class AttributesExample : MonoBeh...
// $orders is collection $orders->addAttributeToSelect('status'); // get status attribute $orders->addAttributeToSelect('*'); // get all attributes
<input type="text" value="<?php echo esc_attr($_POST['username']); ?>" />
Pass in a literal value (not an object), such as a string or number. Child scope gets his own value, if it updates the value, parent scope has his own old value (child scope can't modify the parens scope value). When parent scope value is changed, child scope value will be changed as well. All int...
The attribute and namespace axes contain all attribute and namespace nodes of an element. The shortcut @ stands for attribute::, so the following are equivalent: child::div/attribute::class div/@class
To select an element by an exact HTML attribute use the css locator pattern [attribute=value] //selects the first element with href value '/contact' element(by.css('[href="/contact"]')); //selects the first element with tag option and value 'foo' element(by.css('option[value="f...
To select an element by an HTML attribute that contains a specified value use the css locator pattern [attribute*=value] //selects the first element with href value that contains'cont' element(by.css('[href*="cont"]')); //selects the first element with tag h1 and class attribute that...
The next example can be used to determine whether a enumeration has the FlagsAttribute specified. The methodology used is based on Reflection. This example will give a True result: Dim enu As [Enum] = New FileAttributes() Dim hasFlags As Boolean = enu.GetType().GetCustomAttributes(GetType(FlagsAt...
When it comes to validate some rules which are not generic data validation e.g ensuring a field is required or some range of values but they are specific to your business logic then you can create your own Custom Validator. To create a custom validation attribute, you just need to inherit Validation...
Enabling Attribute Routing To enable attribute routing, call MapMvcAttributeRoutes during configuration. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapMvcAttributeRoutes(); routes.MapRoute( name: “Default”, ...
This attribute handles all unhandled exceptions in the code, (this is mostly for Ajax Requests - that deal with JSON - but can be extended) public class ExceptionHandlerAttribute : HandleErrorAttribute { /// <summary> /// Overriden method to handle exception /// </summary...
To decouple and reuse the same error logging code for all your services you need two boilerplate classes and tuck them away in a library somewhere. ErrorhandlerAttribute implementing IServiceBehavior. FaultErrorhandler implementing IErrorhandler which logs all the exceptions. [AttributeUsage(Attr...
Imagine the following XML: <root> <element foobar="hello_world" /> <element example="this is one!" /> </root> /root/element[@foobar] and will return the <element foobar="hello_world" /> element.
Imagine the following XML: <root> <element foobar="hello_world" /> <element example="this is one!" /> </root> The following XPath expression: /root/element[@foobar = 'hello_world'] will return the <element foobar="hello_world&quo...
If the built in attributes are not sufficient to validate your model data, then you can place your validation logic in a class derived from ValidationAttribute. In this example only odd numbers are valid values for a model member. Custom Validation Attribute public class OddNumberAttribute : Valid...
For using Attribute Routing in areas, registering areas and [RouteArea(...)] definitions are required. In RouteConfig.cs : public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ...

Page 7 of 10