-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
@oyzh888, |
@@ -98,11 +98,18 @@ public string SubscriptionKey | |||
set; | |||
} | |||
|
|||
public string SubscriptionEndPoint |
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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 Key
Please 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, |
There was a problem hiding this comment.
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.
related to endpoint
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Usually, C# function name follows PascalCase [1] rather than starting with lower case with underline as separator.
msg
is obscure, change it toendpoint
instead.- No
default
is necessary, details explained at other places. - Ordinary functions should locate after initialization function.
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Drop the
default
in function name and comments. - The variable name
msg
is obscure, let us make itendpoint
instead. - Function name should follows PascalCase.
/// <param name="endpoint"></param> | ||
public void SetSubscriptionEndpoint(string endpoint){ | ||
string subscriptionEndpoint = null; | ||
subscriptionEndpoint = GetSubscriptionEndpointFromIsolatedStorage(); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fulfill the doc here.
…is no legal endpoint value
@@ -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 ; |
There was a problem hiding this comment.
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
No description provided.