Skip to content

Commit

Permalink
Adjusted Input View and UWP-Text-Template
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasclaudiushuber committed May 13, 2016
1 parent 04ef961 commit bc7c512
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions EventHub.RestClientGenerator/Styles/Label.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Label">
<Setter Property="Foreground" Value="#DDDDDD"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public virtual string TransformText()
{
this.Write("using System;\r\nusing System.Net.Http;\r\nusing System.Text;\r\nusing System.Threading" +
".Tasks;\r\n\r\nnamespace YourNamespace\r\n{\r\n public class EventHubClient\r\n {\r\n c" +
"onst string SharedAccessSignature = ");
"onst string SharedAccessSignature = \"");

#line 15 "D:\temp2\EventHub.RestClientGenerator\EventHub.RestClientGenerator\UwpTextTemplate\EventHubClientTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(SharedAccessSignature));

#line default
#line hidden
this.Write(";\r\n const string Url = ");
this.Write("\";\r\n const string EventHubRestUri = \"");

#line 16 "D:\temp2\EventHub.RestClientGenerator\EventHub.RestClientGenerator\UwpTextTemplate\EventHubClientTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(EventHubRestUri));

#line default
#line hidden
this.Write(@"
this.Write(@""";
public async Task<bool> PostDataAsync(string jsonObjectToSend)
{
var httpClient = new HttpClient();
Expand All @@ -54,7 +54,7 @@ public async Task<bool> PostDataAsync(string jsonObjectToSend)
var content = new StringContent(jsonObjectToSend, Encoding.UTF8, ""application/json"");
content.Headers.Add(""ContentType"", ""application/json"");
var result = await httpClient.PostAsync(url, content);
var result = await httpClient.PostAsync(EventHubRestUri, content);
return result.IsSuccessStatusCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace YourNamespace
{
public class EventHubClient
{
const string SharedAccessSignature = <#=SharedAccessSignature#>;
const string Url = <#=EventHubRestUri#>
const string SharedAccessSignature = "<#=SharedAccessSignature#>";
const string EventHubRestUri = "<#=EventHubRestUri#>";
public async Task<bool> PostDataAsync(string jsonObjectToSend)
{
var httpClient = new HttpClient();
Expand All @@ -23,7 +23,7 @@ namespace YourNamespace
var content = new StringContent(jsonObjectToSend, Encoding.UTF8, "application/json");
content.Headers.Add("ContentType", "application/json");

var result = await httpClient.PostAsync(url, content);
var result = await httpClient.PostAsync(EventHubRestUri, content);

return result.IsSuccessStatusCode;
}
Expand Down
15 changes: 9 additions & 6 deletions EventHub.RestClientGenerator/View/InputView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="5" Text="Input" Background="#007ACC" Foreground="White" FontWeight="Bold" Padding="5"/>

<Label Grid.Row="1" Content="Event Hub Connection String"/>
<Label Grid.Row="1">
<TextBlock>Event Hub<LineBreak/>Connection String</TextBlock></Label>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4" Text="{Binding ConnectionString,UpdateSourceTrigger=PropertyChanged}" Height="50" TextWrapping="Wrap"/>

<Label Grid.Row="2" Content="Device name (optional)"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding PublisherName,UpdateSourceTrigger=PropertyChanged}" />

<Label Grid.Row="2" Grid.Column="2" Content="Token Lifetime"/>
<DockPanel Grid.Row="2" Grid.Column="3">
<Label Grid.Row="2" Content="Token Lifetime"/>
<DockPanel Grid.Row="2" Grid.Column="1">
<ComboBox DockPanel.Dock="Right" Margin="5" Background="Black"
ItemsSource="{Binding TokenLifeTimeUnits}"
SelectedItem="{Binding TokenLifeTimeUnit,Mode=TwoWay}" Width="70"/>
<TextBox Text="{Binding TokenLifeTime,UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>


<Label Grid.Row="2" Grid.Column="2" Content="Publisher/Device name (optional)"/>
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding PublisherName,UpdateSourceTrigger=PropertyChanged}" />

</Grid>
</UserControl>
5 changes: 5 additions & 0 deletions EventHub.RestClientGenerator/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ private void GenerateOutput()
ConnectionDetails = null;
_connectionString = "";
OnPropertyChanged(nameof(ConnectionString));
if(_errorsByPropertyName.ContainsKey(nameof(ConnectionString)))
{
_errorsByPropertyName.Remove(nameof(ConnectionString));
OnErrorsChanged(nameof(ConnectionString));
}
}
else
{
Expand Down

0 comments on commit bc7c512

Please sign in to comment.