Skip to content

Commit f2bf62b

Browse files
KoenZomersVesaJuvonen
authored andcommitted
Added usage samples (SharePoint#573)
* Added usage sample * Added sample * Added validate sample
1 parent 6ac7c7e commit f2bf62b

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

reference/spfx/sp-core-library/log.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ The Log class provides static methods for logging messages at different levels (
2222
|[`verbose(source,message,scope)`](verbose-log.md) | `public, static` | `void` | Logs a verbose message |
2323
|[`warn(source,message,scope)`](warn-log.md) | `public, static` | `void` | Logs a warning |
2424

25-
26-
27-
28-
25+
## Sample
26+
```ts
27+
import {
28+
Log
29+
} from '@microsoft/sp-core-library';
30+
31+
// ...
32+
Log.error("sample", new Error("error message"));
33+
Log.info("sample", "informational message");
34+
Log.warn("sample", "warning message");
35+
Log.verbose("sample", "verbose message");
36+
// ...
37+
```

reference/spfx/sp-core-library/urlqueryparametercollection.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ None
3232
|[`getValue(param)`](getvalue-urlqueryparametercollection.md) | `public` | `string` | Returns the value of the first matching query parameter or undefined if the key doesn't exist. Examples: this._queryParameterList = [ {key: TEST, value: done}, {key: DEBUG, value: false}, {key: TEST, value: notdone}] getValue('TEST') ---> 'done' getValue('debug') ---> 'false' getValue('lost') ---> undefined |
3333
|[`getValues(param)`](getvalues-urlqueryparametercollection.md) | `public` | `string[]` | Returns the values of all of the matching query parameters or undefined if the key doesn't exist. Examples: this._queryParameterList = [ {key: TEST, value: done}, {key: DEBUG, value: false}, {key: TEST, value: notdone}] getValues('TEST') ---> ['done', 'notdone'] getValues('debug') ---> ['false'] getValues('lost') ---> undefined |
3434

35-
35+
## Sample
36+
37+
```ts
38+
import {
39+
UrlQueryParameterCollection
40+
} from '@microsoft/sp-core-library';
41+
42+
// ...
43+
let queryParameterCollection = new UrlQueryParameterCollection(document.URL);
44+
let idValue = queryParameterCollection.getValue("id");
45+
// ...
46+
```
3647

3748

3849

reference/spfx/sp-core-library/validate.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ This class implements provides a standard way to validate properties and functio
2121
|[`isNotNullOrUndefined(value,variableName)`](isnotnullorundefined-validate.md) | `public, static` | `void` | Throws an exception if the specified value is null or undefined. |
2222
|[`isTrue(value,variableName)`](istrue-validate.md) | `public, static` | `void` | Throws an exception if the specified value is not true. |
2323

24-
25-
26-
27-
24+
## Sample
25+
```ts
26+
import {
27+
Validate
28+
} from '@microsoft/sp-core-library';
29+
30+
Validate.isNonemptyString(idValue, "idValue");
31+
Validate.isNotNullOrUndefined(idValue, "idValue");
32+
Validate.isTrue((idValue !== undefined), "idValue");
33+
```

0 commit comments

Comments
 (0)