Tutorial by Examples: e

ResultNotNull() checks to see if the object passed in is not null. If the object and message are not null it will then simply return the object that was passed in, otherwise it will throw InvalidOperationException. return Assert.ResultNotNull(this.Database.GetItem(this.ItemRootId), string.Concat(&q...
This checks to see if the given object is null, and then throws RequiredObjectIsNullException if it is. Assert.Required(parameter, "parameter is required.");
IsNotNull This is a very simple and popular method to use to check if an item is not null. It simply checks the object that is passed in to see if it is null. Assert.IsNotNull(database, type, "Name: {0}", item); IsNotNullOrEmpty This is the same as IsNotNull above, but works on strin...
ArgumentCondition This method checks to see if the argument specified is true. It also takes in the name of the argument that is logged if the condition fails. Assert.ArgumentCondition(pageIndex >= 0, "pageIndex", "Value must be greater than or equal to zero."); ArgumentN...
Checks to see if the passed Item is in Editing mode. If not, it throws an EditingNotAllowedException. Assert.IsEditing(Sitecore.Context.Item);
CanRunApplication To check to see if the user has permission to run the given application. If not, AccessDeniedException is thrown. Assert.CanRunApplication("WebEdit"); HasAccess HasAccess will check if the given parameter is true, otherwise an AccessDeniedException will be thrown. ...
When writing a class with generics in java, it is possible to ensure that the type parameter is an enum. Since all enums extend the Enum class, the following syntax may be used. public class Holder<T extends Enum<T>> { public final T value; public Holder(T init) { t...
To create a PostgreSQL ArrayField, we should give ArrayField the type of data we want it to store as a field as its first argument. Since we'll be storing book ratings, we will use FloatField. from django.db import models, FloatField from django.contrib.postgres.fields import ArrayField cla...
from django.db import models, IntegerField from django.contrib.postgres.fields import ArrayField class IceCream(models.Model): scoops = ArrayField(IntegerField() # we'll use numbers to ID the scoops , size=6) # our parlor only lets you have 6 scoops When you us...
This query returns all cones with a chocolate scoop and a vanilla scoop. VANILLA, CHOCOLATE, MINT, STRAWBERRY = 1, 2, 3, 4 # constants for flavors choco_vanilla_cones = IceCream.objects.filter(scoops__contains=[CHOCOLATE, VANILLA]) Don't forget to import the IceCream model from your models.py ...
You can nest ArrayFields by passing another ArrayField as it's base_field. from django.db import models, IntegerField from django.contrib.postgres.fields import ArrayField class SudokuBoard(models.Model): numbers = ArrayField( ArrayField( models.IntegerField(), ...
This query returns all cones with either a mint scoop or a vanilla scoop. minty_vanilla_cones = IceCream.objects.filter(scoops__contained_by=[MINT, VANILLA])
In order to define a Set of your own type you need to conform your type to Hashable struct Starship: Hashable { let name: String var hashValue: Int { return name.hashValue } } func ==(left:Starship, right: Starship) -> Bool { return left.name == right.name } Now you can cr...
Create a Loader object: var loader:Loader = new Loader(); //import Add listeners on the loader. Standard ones are complete and io/security errors loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); //when the loader is done loading, call this function loader.co...
Twilio's Node.JS API natively supports promises, allowing you to use promises when sending SMS messages (this example was taken and adapted directly from Twilio's API Docs). // Create an authenticated Twilio REST API client var twilio = require('twilio'); var client = new twilio.RestClient('ACCOU...
The browser function can be used like a breakpoint: code execution will pause at the point it is called. Then user can then inspect variable values, execute arbitrary R code and step through the code line by line. Once browser() is hit in the code the interactive interpreter will start. Any R code ...
Twilio help build apps that communicate with everyone in the world. Voice & Video, Messaging and Authentication APIs for every application. You can get an API key for free. To send a message through Twilio, your application needs to make an HTTP POST request to Twilio with the following things...
A yield statement is similar to a return statement, except that instead of stopping execution of the function and returning, yield instead returns a Generator object and pauses execution of the generator function. Here is an example of the range function, written as a generator: function gen_one_t...
pip install sqlalchemy For most common applications, particularly web applications, it is usually recommended that beginners consider using a supplementary library, such as flask-sqlalchemy. pip install flask-sqlalchemy
The FlagsAttribute should be used whenever the enumerable represents a collection of flags, rather than a single value. The numeric value assigned to each enum value helps when manipulating enums using bitwise operators. Example 1 : With [Flags] [Flags] enum Colors { Red=1, Blue=2, ...

Page 182 of 1191