Skip to content

Commit 81eb685

Browse files
Merge pull request #4 from sql-bi/develop
Updated README.md highlighting code blocks
2 parents 16f1d2e + ddbe9cb commit 81eb685

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

README.md

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,46 @@
22
# Dax Formatter [![NuGet](https://github.com/sql-bi/DaxFormatter/actions/workflows/dotnet.yml/badge.svg)](https://github.com/sql-bi/DaxFormatter/actions/workflows/dotnet.yml)
33

44
DAX Formatter is a service available at https://www.daxformatter.com
5-
The service receives DAX expressions and format them according to rules for [DAX code formatting](https://www.sqlbi.com/articles/rules-for-dax-code-formatting/)
5+
The service receives DAX expressions and format them according to rules for [DAX code formatting](https://www.sqlbi.com/articles/rules-for-dax-code-formatting/).
66
The NuGet package contains a client library to invoke the serivce from your .NET application.
77
All the requests are designed to be asynchronous.
8-
You should minimize the requests made to the service: to format multiple expressions, use a single API call providing the DaxFormatterMultipleRequest structure.
8+
You should minimize the requests made to the service: to format multiple expressions, use a single API call providing the `DaxFormatterMultipleRequest` structure.
99

1010
# Quick guide
11-
Create an instance of DaxFormatterClient.
12-
Invoke the FormatAsync method for each request.
13-
Possibly, use the DaxFormatterMultipleRequest structure to provide more statistical details about the database and the server (all the names are anonymized and used only to count the number of unique servers/databases serviced).
14-
11+
Create an instance of `DaxFormatterClient`.
12+
Invoke the `FormatAsync` method for each request.
13+
Possibly, use the `DaxFormatterMultipleRequest` structure to provide more statistical details about the database and the server (all the names are anonymized and used only to count the number of unique servers/databases serviced).
1514

1615
# DaxFormatterClient
1716

1817
The default constructor creates an instance of the client using the current assembly name and version to identify the client. You can specify an application name and version in the constructor arguments.
1918
The client instance resolve the server endpoint just once and reuse it in following requests.
2019
It is suggested to reuse the same instance in multiple requests to minimize the latency.
21-
`var formatter = new DaxFormatterClient();
22-
var response1 = await formatter.FormatAsync( "evaluate('Table') order by 'Table'[Column]" );`
23-
20+
```csharp
21+
var formatter = new DaxFormatterClient();
22+
var response1 = await formatter.FormatAsync( "evaluate('Table') order by 'Table'[Column]" );
23+
```
2424
# DaxFormatterMultipleRequest
25-
Use the DaxFormatterMultipleRequest class to send multiple DAX expressions in a single API call.
26-
```var formatter = new DaxFormatterClient();
25+
Use the `DaxFormatterMultipleRequest` class to send multiple DAX expressions in a single API call.
26+
```csharp
27+
var formatter = new DaxFormatterClient();
2728
var request = new DaxFormatterMultipleRequest
28-
{
29-
DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
30-
ServerName = "MyServerName", // The name will be anonymized by the client library
31-
32-
// Format arguments (you can skip all of them to keep the default values)
33-
ListSeparator = ',',
34-
DecimalSeparator = '.',
35-
MaxLineLenght = DaxFormatterLineStyle.LongLine,
36-
SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,
37-
38-
// Identify the server type using the corresponding enum values
39-
ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
40-
ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
41-
ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
42-
ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
43-
};
29+
{
30+
DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
31+
ServerName = "MyServerName", // The name will be anonymized by the client library
32+
33+
// Format arguments (you can skip all of them to keep the default values)
34+
ListSeparator = ',',
35+
DecimalSeparator = '.',
36+
MaxLineLenght = DaxFormatterLineStyle.LongLine,
37+
SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,
38+
39+
// Identify the server type using the corresponding enum values
40+
ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
41+
ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
42+
ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
43+
ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
44+
};
4445

4546
// Add the code to format
4647
request.Dax.Add( "evaluate('Table') order by 'Table'[Column]" );
@@ -55,36 +56,33 @@ foreach (var response in responses)
5556
Console.WriteLine(response.Formatted);
5657
}
5758
```
58-
59-
6059
# DaxFormatterSingleRequest
61-
Use the DaxFormatterSingleRequest class to send one DAX expressions in a single API call.
62-
```var formatter = new DaxFormatterClient();
60+
Use the `DaxFormatterSingleRequest` class to send one DAX expressions in a single API call.
61+
```csharp
62+
var formatter = new DaxFormatterClient();
6363
var request = new DaxFormatterSingleRequest
64-
{
65-
Dax = "evaluate('Table') order by 'Table'[Column]",
66-
67-
DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
68-
ServerName = "MyServerName", // The name will be anonymized by the client library
69-
70-
// Format arguments (you can skip all of them to keep the default values)
71-
ListSeparator = ',',
72-
DecimalSeparator = '.',
73-
MaxLineLenght = DaxFormatterLineStyle.LongLine,
74-
SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,
75-
76-
// Identify the server type using the corresponding enum values
77-
ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
78-
ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
79-
ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
80-
ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
81-
};
82-
64+
{
65+
Dax = "evaluate('Table') order by 'Table'[Column]",
66+
67+
DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
68+
ServerName = "MyServerName", // The name will be anonymized by the client library
69+
70+
// Format arguments (you can skip all of them to keep the default values)
71+
ListSeparator = ',',
72+
DecimalSeparator = '.',
73+
MaxLineLenght = DaxFormatterLineStyle.LongLine,
74+
SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,
75+
76+
// Identify the server type using the corresponding enum values
77+
ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
78+
ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
79+
ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
80+
ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
81+
};
82+
8383
// Send the request and wait the result
8484
var response = await formatter.FormatAsync(request);
8585

8686
// Display the result
8787
Console.WriteLine(response.Formatted);
8888
```
89-
90-

0 commit comments

Comments
 (0)