Difference between revisions of "Phonenumber class"
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
|Name=<nowiki>Phonenumber</nowiki> | |Name=<nowiki>Phonenumber</nowiki> | ||
|Description=<nowiki>A phonenumber</nowiki> | |Description=<nowiki>A phonenumber</nowiki> | ||
+ | |InheritsFrom=Array|Constructors= | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=array|Name=<nowiki>phoneArray</nowiki>|Description=<nowiki>Array of type, number, call-prefix[, country isocode]</nowiki>}} | ||
+ | |Description=<nowiki>Create new phonenumber</nowiki>}} | ||
|Methods= | |Methods= | ||
− | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Any</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Any</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and return true/false</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and return true/false</nowiki>}} | ||
|Description=<nowiki>Return true if the array contains the element using the given function.</nowiki>}} | |Description=<nowiki>Return true if the array contains the element using the given function.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Contains</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Clear</nowiki>|Inherited=array|Description=<nowiki>Remove all items in array</nowiki>}} |
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Contains</nowiki>|Inherited=array|Parameters= | ||
{{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to check for</nowiki>}} | {{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to check for</nowiki>}} | ||
|Description=<nowiki>Return true if the array contains the element using the normal equal operator.</nowiki>}} | |Description=<nowiki>Return true if the array contains the element using the normal equal operator.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Except</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Except</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=array|Name=<nowiki>elements</nowiki>|Description=<nowiki>Elements to remove</nowiki>}} | {{CGscriptParameters_Template|Type=array|Name=<nowiki>elements</nowiki>|Description=<nowiki>Elements to remove</nowiki>}} | ||
|Description=<nowiki>Return all elements that does not exist in the other collection.</nowiki>}} | |Description=<nowiki>Return all elements that does not exist in the other collection.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>First</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>First</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | ||
|Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition.</nowiki>}} | |Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>FirstOrDefault</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>FirstOrDefault</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | ||
|Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition or empty if not found.</nowiki>}} | |Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition or empty if not found.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>Frequency</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Foreach</nowiki>|Inherited=array|Parameters= |
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>function</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index</nowiki>}} | ||
+ | |Description=<nowiki>Filters a sequence of values based on a predicate.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>Frequency</nowiki>|Inherited=array|Parameters= | ||
{{CGscriptParameters_Template|Type=number|Name=<nowiki>number</nowiki>|Description=<nowiki>The number to search for</nowiki>}} | {{CGscriptParameters_Template|Type=number|Name=<nowiki>number</nowiki>|Description=<nowiki>The number to search for</nowiki>}} | ||
|Description=<nowiki>Counts the number of times a given Number object exists in the Array. Can only use if all the elements are of type Number</nowiki>}} | |Description=<nowiki>Counts the number of times a given Number object exists in the Array. Can only use if all the elements are of type Number</nowiki>}} | ||
Line 24: | Line 32: | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}} | ||
|Description=<nowiki>Backward-compatible indexer</nowiki>}} | |Description=<nowiki>Backward-compatible indexer</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>IndexOf</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>IndexOf</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to search for</nowiki>}} | {{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to search for</nowiki>}} | ||
− | |Description=<nowiki>Return index of the given element, or -1.</nowiki>}} | + | |Description=<nowiki>Return index of the given element using ==, or -1.</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsCharacterArray</nowiki>|Description=<nowiki>check if array is an array of characters</nowiki>}} | + | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>IndexOfObject</nowiki>|Inherited=array|Parameters= |
− | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsNumericArray</nowiki>|Description=<nowiki>check if array is an array of integer numbers</nowiki>}} | + | {{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to search for</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsStringArray</nowiki>|Description=<nowiki>check if array is an array of string</nowiki>}} | + | |Description=<nowiki>Return index of the given element using references, or -1.</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>OrderBy</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsCharacterArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of characters</nowiki>}} |
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsNumericArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of integer numbers</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsStringArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of string</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>OrderBy</nowiki>|Inherited=array|Parameters= | ||
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>comparer</nowiki>|Description=<nowiki>Function that compares two objects of the same type. Must return a signed integer that indicates the relative values of first param A and second param B. Value Less than 0 : A is less than B.Value 0 : A equals B.Value Greater than 0 : A is greater than B.It can also be a function that takes 1 parameter and returns a string or number.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>comparer</nowiki>|Description=<nowiki>Function that compares two objects of the same type. Must return a signed integer that indicates the relative values of first param A and second param B. Value Less than 0 : A is less than B.Value 0 : A equals B.Value Greater than 0 : A is greater than B.It can also be a function that takes 1 parameter and returns a string or number.</nowiki>}} | ||
|Description=<nowiki>Sorts the elements of a sequence in ascending order by using a specified comparer.</nowiki>}} | |Description=<nowiki>Sorts the elements of a sequence in ascending order by using a specified comparer.</nowiki>}} | ||
Line 39: | Line 50: | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>value</nowiki>|Description=<nowiki>Formatted value</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>countryIso</nowiki>|Description=<nowiki>Iso code of the country the number is in</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>value</nowiki>|Description=<nowiki>Formatted value</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>countryIso</nowiki>|Description=<nowiki>Iso code of the country the number is in</nowiki>}} | ||
|Description=<nowiki>Parse number from formatted value</nowiki>}} | |Description=<nowiki>Parse number from formatted value</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Randomize</nowiki>|Description=<nowiki>Randomize the order of the elements in the current array.</nowiki>}} | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Randomize</nowiki>|Inherited=array|Obsolete=1 |
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Reverse</nowiki>|Description=<nowiki>Returns an array with all the elements in the opposite order.</nowiki>}} | + | |Description=<nowiki>[Obsolete] Randomize the order of the elements in the current array. Multiple calls to this may return the same randomization, use a Random object to preserve randomization over multiple calls</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Select</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Randomize</nowiki>|Inherited=array|Parameters= |
+ | {{CGscriptParameters_Template|Type=Random|Name=<nowiki>random</nowiki>|Description=<nowiki>Random object</nowiki>}} | ||
+ | |Description=<nowiki>Randomize the order of the elements in the current array.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Reverse</nowiki>|Inherited=array|Description=<nowiki>Returns an array with all the elements in the opposite order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Select</nowiki>|Inherited=array|Parameters= | ||
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to apply to each element.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to apply to each element.</nowiki>}} | ||
|Description=<nowiki>Projects each element of a sequence into a new form.</nowiki>}} | |Description=<nowiki>Projects each element of a sequence into a new form.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>SelectMany</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>SelectMany</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to get each sub array.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to get each sub array.</nowiki>}} | ||
|Description=<nowiki>Projects each array element of a sequence into a new form.</nowiki>}} | |Description=<nowiki>Projects each array element of a sequence into a new form.</nowiki>}} | ||
Line 50: | Line 65: | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}} | ||
|Description=<nowiki>Backward-compatible indexer</nowiki>}} | |Description=<nowiki>Backward-compatible indexer</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Skip</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Skip</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to skip</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to skip</nowiki>}} | ||
|Description=<nowiki>Get all but the n first elements.</nowiki>}} | |Description=<nowiki>Get all but the n first elements.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Take</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Take</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to take</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to take</nowiki>}} | ||
|Description=<nowiki>Get the n first elements.</nowiki>}} | |Description=<nowiki>Get the n first elements.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>}} | ||
|Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | |Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Inherited=array|Parameters= |
{{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Function|Name=<nowiki>valueSelector</nowiki>|Description=<nowiki>A transform function to get the value of each element.</nowiki>}} | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Function|Name=<nowiki>valueSelector</nowiki>|Description=<nowiki>A transform function to get the value of each element.</nowiki>}} | ||
|Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | |Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}} | + | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=Array|Description=<nowiki>The string representation of the object.</nowiki>}} |
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>UpdateNumber</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>UpdateNumber</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>areaCode</nowiki>|Description=<nowiki>New areacode</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>number</nowiki>|Description=<nowiki>New number</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>areaCode</nowiki>|Description=<nowiki>New areacode</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>number</nowiki>|Description=<nowiki>New number</nowiki>}} | ||
|Description=<nowiki>Update number from formatted value</nowiki>}} | |Description=<nowiki>Update number from formatted value</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Where</nowiki>|Parameters= | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Where</nowiki>|Inherited=array|Parameters= |
− | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array and return true/false</nowiki>}} | + | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index and return true/false</nowiki>}} |
|Description=<nowiki>Filters a sequence of values based on a predicate.</nowiki>}} | |Description=<nowiki>Filters a sequence of values based on a predicate.</nowiki>}} | ||
|Properties= | |Properties= | ||
− | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Average</nowiki>|HasGetter=1|Description=<nowiki>Average of the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Average</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Average of the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} |
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>CountryCallingCode</nowiki>|HasGetter=1|Description=<nowiki>Digit(s) dial after the +</nowiki>}} | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>CountryCallingCode</nowiki>|HasGetter=1|Description=<nowiki>Digit(s) dial after the +</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>CountryIso</nowiki>|HasGetter=1|Description=<nowiki>Iso code of the country the number is in</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>CountryIso</nowiki>|HasGetter=1|Description=<nowiki>Iso code of the country the number is in</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Extension</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Extension part of the phonenumber</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Extension</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Extension part of the phonenumber</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>FormattedNumber</nowiki>|HasGetter=1|Description=<nowiki>Number formatted for display</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>FormattedNumber</nowiki>|HasGetter=1|Description=<nowiki>Number formatted for display</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Max</nowiki>|HasGetter=1|Description=<nowiki>Largest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Max</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Largest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Min</nowiki>|HasGetter=1|Description=<nowiki>Smallest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Min</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Smallest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} |
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Sum</nowiki>|HasGetter=1|Description=<nowiki>Sum of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Sum</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Sum of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} |
}} | }} | ||
+ | |||
=== <span style="color:#DF8621">'''Examples'''</span> === | === <span style="color:#DF8621">'''Examples'''</span> === | ||
<source lang="javascript"> | <source lang="javascript"> | ||
− | //Add new | + | //Add phonenumber for user by new Phonenumber |
− | User user = User_getUserByResourceId( | + | User user = User_getUserByResourceId(userId); |
− | user.PhoneNumbers = {{PhoneNumber_Type_NotIdentified, " | + | user.PhoneNumbers = { |
+ | new Phonenumber({PhoneNumber_Type_Mobile1, "88888888",empty,"dk"}), | ||
+ | new Phonenumber({PhoneNumber_Type_Mobile2, "88888888",45}), | ||
+ | }; | ||
+ | user.Save(); | ||
+ | </source> | ||
+ | <source lang="javascript"> | ||
+ | //Add phonenumber for user by Phonenumber aray | ||
+ | User user = User_getUserByResourceId(UserId); | ||
+ | user.PhoneNumbers = { | ||
+ | {PhoneNumber_Type_NotIdentified, "88888888", 45} | ||
+ | }; | ||
user.Save(); | user.Save(); | ||
− | print(user.PhoneNumbers[0].FormattedNumber);// | + | print(user.PhoneNumbers[0].FormattedNumber);//88888888 |
print(user.PhoneNumbers[0].CountryCallingCode);//45 | print(user.PhoneNumbers[0].CountryCallingCode);//45 | ||
print(user.PhoneNumbers[0].CountryIso);//dk | print(user.PhoneNumbers[0].CountryIso);//dk | ||
Line 95: | Line 122: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
//ParseNumber | //ParseNumber | ||
− | User user = User_getUserByResourceId( | + | User user = User_getUserByResourceId(UserId); |
if (user.PhoneNumbers.Count > 0) | if (user.PhoneNumbers.Count > 0) | ||
{ | { | ||
− | + | string formattedNumber = "88888888"; | |
− | string formattedNumber = " | ||
string countryIso = "vn"; | string countryIso = "vn"; | ||
− | user.PhoneNumbers[0].ParseNumber(formattedNumber, countryIso); | + | number CountryCallingCode = 84; |
+ | //user.PhoneNumbers[0].ParseNumber(formattedNumber, countryIso); | ||
+ | user.PhoneNumbers[0].ParseNumber(formattedNumber, CountryCallingCode); | ||
user.PhoneNumbers[0].Extension = "1"; | user.PhoneNumbers[0].Extension = "1"; | ||
user.Save(); | user.Save(); | ||
− | print(user.PhoneNumbers[0].FormattedNumber);// | + | print(user.PhoneNumbers[0].FormattedNumber);//88888888#1 |
print(user.PhoneNumbers[0].CountryCallingCode);//84 | print(user.PhoneNumbers[0].CountryCallingCode);//84 | ||
print(user.PhoneNumbers[0].CountryIso);//vn | print(user.PhoneNumbers[0].CountryIso);//vn | ||
Line 113: | Line 141: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
//UpdateNumber | //UpdateNumber | ||
− | User user = User_getUserByResourceId( | + | User user = User_getUserByResourceId(UserId); |
if (user.PhoneNumbers.Count > 0) | if (user.PhoneNumbers.Count > 0) | ||
{ | { | ||
string areaCode = "2"; | string areaCode = "2"; | ||
− | string formattedNumber = " | + | string formattedNumber = "88888888"; |
user.PhoneNumbers[0].UpdateNumber(areaCode,formattedNumber); | user.PhoneNumbers[0].UpdateNumber(areaCode,formattedNumber); | ||
user.Save(); | user.Save(); | ||
− | print(user.PhoneNumbers[0].FormattedNumber);// | + | print(user.PhoneNumbers[0].FormattedNumber);//288888888#1 |
print(user.PhoneNumbers[0].CountryCallingCode);//84 | print(user.PhoneNumbers[0].CountryCallingCode);//84 | ||
print(user.PhoneNumbers[0].CountryIso);//vn | print(user.PhoneNumbers[0].CountryIso);//vn | ||
print(user.PhoneNumbers[0].Extension);//1 | print(user.PhoneNumbers[0].Extension);//1 | ||
} | } | ||
+ | </source> | ||
+ | <source lang="javascript"> | ||
+ | //Set empty phone for user | ||
+ | User user = User_getUserByResourceId(UserId); | ||
+ | user.PhoneNumbers = {}; | ||
+ | user.Save(); | ||
</source> | </source> |
Latest revision as of 04:58, 26 June 2024
Phonenumber
A phonenumber
Parent class
Inherits from Array
Constructors
- (array phoneArray "Array of type, number, call-prefix[, country isocode]") - Create new phonenumber
Methods
- (From array) bool Any(Function predicate "A function that takes 1 parameter of the types in the array, and return true/false") - Return true if the array contains the element using the given function.
- (From array) Empty Clear() - Remove all items in array
- (From array) bool Contains(object element "Element to check for") - Return true if the array contains the element using the normal equal operator.
- (From array) array Except(array elements "Elements to remove") - Return all elements that does not exist in the other collection.
- (From array) object First(Function selector "A function to test each element for a condition.") - Returns the first element in a sequence that satisfies a specified condition.
- (From array) object FirstOrDefault(Function selector "A function to test each element for a condition.") - Returns the first element in a sequence that satisfies a specified condition or empty if not found.
- (From array) Empty Foreach(Function function "A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index") - Filters a sequence of values based on a predicate.
- (From array) int Frequency(number number "The number to search for") - Counts the number of times a given Number object exists in the Array. Can only use if all the elements are of type Number
- object this[] { get; }(int index "Index") - Backward-compatible indexer
- (From array) int IndexOf(object element "Element to search for") - Return index of the given element using ==, or -1.
- (From array) int IndexOfObject(object element "Element to search for") - Return index of the given element using references, or -1.
- (From array) bool IsCharacterArray() - check if array is an array of characters
- (From array) bool IsNumericArray() - check if array is an array of integer numbers
- (From array) bool IsStringArray() - check if array is an array of string
- (From array) array OrderBy(Function comparer "Function that compares two objects of the same type. Must return a signed integer that indicates the relative values of first param A and second param B. Value Less than 0 : A is less than B.Value 0 : A equals B.Value Greater than 0 : A is greater than B.It can also be a function that takes 1 parameter and returns a string or number.") - Sorts the elements of a sequence in ascending order by using a specified comparer.
- Empty ParseNumber(string value "Formatted value", int CountryCallingCode "Digit(s) dial after the +") - Parse number from formatted value
- Empty ParseNumber(string value "Formatted value", string countryIso "Iso code of the country the number is in") - Parse number from formatted value
- (From array) Empty Randomize() - [Obsolete] Randomize the order of the elements in the current array. Multiple calls to this may return the same randomization, use a Random object to preserve randomization over multiple calls
- (From array) Empty Randomize(Random random "Random object") - Randomize the order of the elements in the current array.
- (From array) array Reverse() - Returns an array with all the elements in the opposite order.
- (From array) array Select(Function selector "A transform function to apply to each element.") - Projects each element of a sequence into a new form.
- (From array) array SelectMany(Function selector "A transform function to get each sub array.") - Projects each array element of a sequence into a new form.
- Empty this[] { set; }(int index "Index", object value "Value to set") - Backward-compatible indexer
- (From array) array Skip(int n "How many elements to skip") - Get all but the n first elements.
- (From array) array Take(int n "How many elements to take") - Get the n first elements.
- (From array) Dictionary ToDictionary(Function keySelector "A transform function to get the key of each element.") - Return a dictionary with the elements of the array.
- (From array) Dictionary ToDictionary(Function keySelector "A transform function to get the key of each element.", Function valueSelector "A transform function to get the value of each element.") - Return a dictionary with the elements of the array.
- (From Array) string ToString() - The string representation of the object.
- Empty UpdateNumber(string areaCode "New areacode", string number "New number") - Update number from formatted value
- (From array) array Where(Function predicate "A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index and return true/false") - Filters a sequence of values based on a predicate.
Properties
- (From array) number Average { get; } - Average of the objects in the Array object. Can only use if all the elements are of type Number
- int CountryCallingCode { get; } - Digit(s) dial after the +
- string CountryIso { get; } - Iso code of the country the number is in
- string Extension { get; set; } - Extension part of the phonenumber
- string FormattedNumber { get; } - Number formatted for display
- (From array) number Max { get; } - Largest of all the objects in the Array object. Can only use if all the elements are of type Number
- (From array) number Min { get; } - Smallest of all the objects in the Array object. Can only use if all the elements are of type Number
- string ObjectTypeName { get; } - The name of the type of object.
- (From array) number Sum { get; } - Sum of all the objects in the Array object. Can only use if all the elements are of type Number
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
Examples
//Add phonenumber for user by new Phonenumber
User user = User_getUserByResourceId(userId);
user.PhoneNumbers = {
new Phonenumber({PhoneNumber_Type_Mobile1, "88888888",empty,"dk"}),
new Phonenumber({PhoneNumber_Type_Mobile2, "88888888",45}),
};
user.Save();
//Add phonenumber for user by Phonenumber aray
User user = User_getUserByResourceId(UserId);
user.PhoneNumbers = {
{PhoneNumber_Type_NotIdentified, "88888888", 45}
};
user.Save();
print(user.PhoneNumbers[0].FormattedNumber);//88888888
print(user.PhoneNumbers[0].CountryCallingCode);//45
print(user.PhoneNumbers[0].CountryIso);//dk
print(user.PhoneNumbers[0].Extension);// empty
//ParseNumber
User user = User_getUserByResourceId(UserId);
if (user.PhoneNumbers.Count > 0)
{
string formattedNumber = "88888888";
string countryIso = "vn";
number CountryCallingCode = 84;
//user.PhoneNumbers[0].ParseNumber(formattedNumber, countryIso);
user.PhoneNumbers[0].ParseNumber(formattedNumber, CountryCallingCode);
user.PhoneNumbers[0].Extension = "1";
user.Save();
print(user.PhoneNumbers[0].FormattedNumber);//88888888#1
print(user.PhoneNumbers[0].CountryCallingCode);//84
print(user.PhoneNumbers[0].CountryIso);//vn
print(user.PhoneNumbers[0].Extension);//1
}
//UpdateNumber
User user = User_getUserByResourceId(UserId);
if (user.PhoneNumbers.Count > 0)
{
string areaCode = "2";
string formattedNumber = "88888888";
user.PhoneNumbers[0].UpdateNumber(areaCode,formattedNumber);
user.Save();
print(user.PhoneNumbers[0].FormattedNumber);//288888888#1
print(user.PhoneNumbers[0].CountryCallingCode);//84
print(user.PhoneNumbers[0].CountryIso);//vn
print(user.PhoneNumbers[0].Extension);//1
}
//Set empty phone for user
User user = User_getUserByResourceId(UserId);
user.PhoneNumbers = {};
user.Save();