Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the endpoint input function. #8

Merged
merged 9 commits into from
Jun 2, 2017

Conversation

oyzh888
Copy link
Contributor

@oyzh888 oyzh888 commented May 26, 2017

No description provided.

@msftclas
Copy link

@oyzh888,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@@ -98,11 +98,18 @@ public string SubscriptionKey
set;
}

public string SubscriptionEndPoint
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint is one single word, so let us change EndPoint to Endpoint instead. Also for other places.

<TextBox VerticalAlignment="Stretch" Grid.Column="1" Padding="2" Text="{Binding SubscriptionKey, Mode=TwoWay}" Margin="0,5,0,5" Grid.ColumnSpan="2"/>
<Label VerticalAlignment="Center" Grid.Row="1" Content="EndPoint:" Margin="0,2" Height="26"/>
<TextBox VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="1" Padding="2" Text="{Binding SubscriptionEndPoint, Mode=TwoWay}" Margin="0,5,0,5" Grid.ColumnSpan="2"/>
<Button Click="SaveKey_Click" Grid.Row="2" Margin="78,7,73,6" Padding="5, 0, 5, 0" VerticalAlignment="Center" Height="18" Content="Save Key" Grid.Column="1" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Key in the function name and the Save Key label are misleading, let us change the function name to SaveSettings_Click with label Save Settings. Also apply this to delete.

private readonly string _defaultSubscriptionKeyPromptMessage = "Paste your subscription key here firstly";
private readonly string _defaultSubscriptionEndPointPromptMessage = "Paste your EndPoint here to start";

private static string s_subscriptionKey, s_subscriptionEndPoint;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split them to two lines.

@@ -158,11 +231,13 @@ private void SaveKey_Click(object sender, RoutedEventArgs e)
try
{
SaveSubscriptionKeyToIsolatedStorage(SubscriptionKey);
MessageBox.Show("Subscription key is saved in your disk.\nYou do not need to paste the key next time.", "Subscription Key");
SaveSubscriptionEndPointToIsolatedStorage(SubscriptionEndPoint);
//MessageBox.Show(SubscriptionKey + '\n' + SubscriptionEndPoint);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment.

MessageBox.Show("Subscription key is saved in your disk.\nYou do not need to paste the key next time.", "Subscription Key");
SaveSubscriptionEndPointToIsolatedStorage(SubscriptionEndPoint);
//MessageBox.Show(SubscriptionKey + '\n' + SubscriptionEndPoint);
MessageBox.Show("Subscription key and endpoint is saved in your disk.\nYou do not need to paste the key next time.", "Subscription Key");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous title of the messagebox Subscription KeyPlease change to Settings.

}
catch (System.Exception exception)
{
MessageBox.Show("Fail to save subscription key. Error message: " + exception.Message,
MessageBox.Show("Fail to save subscription & endpoint key. Error message: " + exception.Message,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fail to save subscription key & endpoint.

Copy link

@huxuan huxuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just finish the last piece changes and make your first pull request fire off!

{
try
{
using (var iStreamForEndPoint = new IsolatedStorageFileStream(_isolatedStorageSubscriptionEndpointFileName, FileMode.Open, isoStore))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/EndPoint/Endpoint/g

{
using (var iStreamForEndPoint = new IsolatedStorageFileStream(_isolatedStorageSubscriptionEndpointFileName, FileMode.Open, isoStore))
{
using (var readerForEndPoint = new StreamReader(iStreamForEndPoint))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/EndPoint/Endpoint/g

{
using (var readerForEndPoint = new StreamReader(iStreamForEndPoint))
{
subscriptionEndpoint = readerForEndPoint.ReadLine();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

SaveSubscriptionKeyToIsolatedStorage("");
MessageBox.Show("Subscription key is deleted from your disk.", "Subscription Key");
MessageBox.Show("Subscription setting is deleted from your disk.", "Subscription Key");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title also needs change.

}
catch (System.Exception exception)
{
MessageBox.Show("Fail to save subscription key. Error message: " + exception.Message,
MessageBox.Show("Fail to save subscription key & endpoint . Error message: " + exception.Message,
Copy link

@huxuan huxuan May 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the messagebox title here. Also for other places.

@@ -104,6 +104,11 @@ public string SubscriptionEndpoint
set;
}

public void set_subscriptionPage_defaultEndpoint(string msg)
Copy link

@huxuan huxuan May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Usually, C# function name follows PascalCase [1] rather than starting with lower case with underline as separator.
  2. msg is obscure, change it to endpoint instead.
  3. No default is necessary, details explained at other places.
  4. Ordinary functions should locate after initialization function.

[1] https://en.wikipedia.org/wiki/PascalCase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1,2,4 are accepted.
"Default" is to differentiate the setter of endpoint and the default value of endpoint

@@ -49,7 +49,7 @@ public partial class SubscriptionKeyPage : Page, INotifyPropertyChanged
private readonly string _isolatedStorageSubscriptionEndpointFileName = "SubscriptionEndpoint.txt";

private readonly string _defaultSubscriptionKeyPromptMessage = "Paste your subscription key here firstly";
private readonly string _defaultSubscriptionEndpointPromptMessage = "Paste your endpoint here to start";
private string _defaultSubscriptionEndpointPromptMessage = "Paste your endpoint here to start";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to change the default endpoint setting. Just set the endpoint should be enough. Just make the default default.

public void setDefaultSubscriptionEndpoint(string msg){
_defaultSubscriptionEndpointPromptMessage = msg;
s_subscriptionEndpoint = msg;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant empty line. They should never exist in any circumstances.

/// Set a default endpoint when there is no legal endpoint value
/// </summary>
/// <param name="msg"></param>
public void setDefaultSubscriptionEndpoint(string msg){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Drop the default in function name and comments.
  2. The variable name msg is obscure, let us make it endpoint instead.
  3. Function name should follows PascalCase.

/// <param name="endpoint"></param>
public void SetSubscriptionEndpoint(string endpoint){
string subscriptionEndpoint = null;
subscriptionEndpoint = GetSubscriptionEndpointFromIsolatedStorage();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, I've tried, but we cannot simply set the public string SubscriptionEndpoint, if I change the setter function, it throws a null pointer exception(may be caused by binding). It's a big problem and I use my own way to handle this.

/// Handles the Click event of the subscription key save button.
/// Saves the subscription endpoint to isolated storage.
/// </summary>
/// <param name="subscriptionEndpoint">The subscription key.</param>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the doc here.

/// <summary>
/// Set a default endpoint when there is no legal endpoint value
/// </summary>
/// <param name="endpoint"></param>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fulfill the doc here.

@@ -65,7 +65,7 @@ public partial class SampleScenarios : UserControl
public static DependencyProperty SampleScenarioListProperty =
DependencyProperty.Register("SampleScenarioList", typeof(Scenario[]), typeof(SampleScenarios));

private SubscriptionKeyPage _subscriptionPage;
private SubscriptionKeyPage _subscriptionPage ;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the redundant empty space here.

 Pleas enter the commit message for your changes. Lines starting
@huxuan huxuan merged commit 4320248 into microsoft:master Jun 2, 2017
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants