-
Notifications
You must be signed in to change notification settings - Fork 314
Fix | Adding type convertor support for SqlConnectionEncryptOption #2057
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
Merged
Kaur-Parminder
merged 25 commits into
dotnet:main
from
arellegue:SqlConnectionEncryptOption
Jul 6, 2023
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5c505a1
Add SqlConnectionEncryptOptionConverter class which is used to conver…
arellegue 9b9af7e
Merge branch 'main' of https://github.com/arellegue/SqlClient
arellegue 4ebaabd
Removed added blank line.
arellegue 39a7ea8
Removed redundant InLineData from ConnectionStringFromJsonTests.
arellegue 0a0768e
Fix issues found in PR request.
arellegue ab6a469
Changed SqlConnectionEnryptOptionConverter from public to internal.
arellegue 892625c
Applied Davoud's suggestions for changes.
arellegue 789670e
Update src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnecti…
DavoudEshtehari 5455314
Update tools/props/Versions.props
DavoudEshtehari e07547a
Add more SqlConnectionEncryptOptionConverter unit tests.
arellegue 7197981
Add assessment of exception thrown in ExecuteConnectionStringFromJson…
arellegue d7f0058
Added blank line.
arellegue 7dee649
Apply suggestions from code review
DavoudEshtehari c9d115c
Removed unnecessary XML file for internal class SqlConnectionEncryptO…
arellegue 4b5f86d
Use ADP.ConvertFailed helper function in SqlConnectionEncryptOptionCo…
arellegue 14ac22f
Resolved merged conflict.
arellegue 9a42b07
Apply suggestions from code review
DavoudEshtehari 809bbe8
Add message to show more information if CanCanConvert returns false.
arellegue 20170ee
Fixed grammar error in the message to show more information if CanCon…
arellegue 06b3536
Removed entry for EncryptOptionConverter XML.
arellegue 99d1243
Revert "Removed entry for EncryptOptionConverter XML."
arellegue 766d859
Remove EncryptOptionConverter xml in MDS solution.
arellegue 1040674
Add more messages to show more information if CanConvertFrom and CanC…
arellegue f54d699
Change messages to show the expections when CanConvertFrom and CanCon…
arellegue 7415ec1
Fix CanConvertTo messages.
arellegue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...rosoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionEncryptOptionConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
using System; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using Microsoft.Data.Common; | ||
|
||
namespace Microsoft.Data.SqlClient | ||
{ | ||
internal class SqlConnectionEncryptOptionConverter : TypeConverter | ||
{ | ||
// Overrides the CanConvertFrom method of TypeConverter. | ||
// The ITypeDescriptorContext interface provides the context for the | ||
// conversion. Typically, this interface is used at design time to | ||
// provide information about the design-time container. | ||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) | ||
{ | ||
if (sourceType == typeof(string)) | ||
{ | ||
return true; | ||
} | ||
return base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
// Overrides the CanConvertTo method of TypeConverter. | ||
public override bool CanConvertTo(ITypeDescriptorContext context, Type sourceType) | ||
{ | ||
if (sourceType == typeof(string)) | ||
{ | ||
return true; | ||
} | ||
return base.CanConvertTo(context, sourceType); | ||
} | ||
|
||
// Overrides the ConvertFrom method of TypeConverter. | ||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) | ||
{ | ||
if (value is string) | ||
{ | ||
return SqlConnectionEncryptOption.Parse(value.ToString()); | ||
} | ||
throw ADP.ConvertFailed(value.GetType(), typeof(SqlConnectionEncryptOption), null); | ||
} | ||
|
||
// Overrides the ConvertTo method of TypeConverter. | ||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) | ||
{ | ||
if (destinationType == typeof(string)) | ||
{ | ||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
throw ADP.ConvertFailed(value.GetType(), typeof(SqlConnectionEncryptOption), null); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.