This file contains 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
/// <summary> | |
/// This is an example of how to implement | |
/// an string enum. | |
/// </summary> | |
public enum MyStringEnum | |
{ | |
[StringValue("This is the string value 1.")] | |
Member1, | |
[StringValue("This is the string value 1.")] | |
Member2, |
This file contains 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
/// <summary> | |
/// Provides the tools needed to get in a easy, fast way | |
/// the string value of an enumerator member assigned | |
/// with <see cref="StringValueAttribute"/>. | |
/// </summary> | |
/// <typeparam name="E">The type of the enumerator.</typeparam> | |
public static class StringEnum<E> | |
{ | |
/// <summary> | |
/// Gets the enumerator member's string value. |
This file contains 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
/// <summary> | |
/// This attribute allows to attach to any | |
/// class, method, property or enumerator member | |
/// a string value. | |
/// </summary> | |
public class StringValueAttribute : Attribute | |
{ | |
/// <summary> | |
/// Returns the attached string value. | |
/// </summary> |
This file contains 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
public enum MyStringEnum | |
{ | |
Text1 = "My text 1", | |
} |
This file contains 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
static void Main(string[] args) | |
{ | |
Service1Client client = null; | |
try | |
{ | |
// Create the client | |
// It will use the settings in the app.config file | |
client = new Service1Client(); | |
// Set credentials | |
client.ClientCredentials.UserName.UserName = "USER_PASSWORD"; |
This file contains 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
<client> | |
<endpoint address="YOUR_SERVICE_URL" | |
binding="netTcpBinding" | |
bindingConfiguration="NetTcpBinding_YOUR_REFERENCED_SERVICE_INTERFACE" | |
contract="YOUR_REFERENCED_SERVICE.YOUR_REFERENCED_SERVICE_INTERFACE" | |
name="NetTcpBinding_YOUR_REFERENCED_SERVICE_INTERFACE"> | |
<identity> | |
<dns value="dev_cert_2"/> | |
<certificate encodedValue="..." /> | |
</identity> |
This file contains 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
<behaviors> | |
<serviceBehaviors> | |
<behavior name ="beh_auth"> | |
<serviceMetadata/> | |
<serviceCredentials> | |
<userNameAuthentication | |
userNamePasswordValidationMode="Custom" | |
customUserNamePasswordValidatorType="YOUR_HOST_NAMESPACE.YOUR_CUSTOM_VALIDATOR, YOUR_ASSEMBLY_NAME"/> | |
<serviceCertificate | |
findValue="YOUR_CERT_NAME" |
This file contains 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
<bindings> | |
<netTcpBinding> | |
<binding name="tcp_auth" | |
portSharingEnabled="false"> | |
<security mode="Message"> | |
<message clientCredentialType="UserName"/> | |
</security> | |
</binding> | |
</netTcpBinding> | |
</bindings> |
This file contains 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
public class CustomValidator : UserNamePasswordValidator | |
{ | |
public override void Validate(string user_name, string password) | |
{ | |
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(password)) | |
throw new SecurityTokenException("Username and password required"); | |
if (!(user_name == "test" && password == "test")) | |
throw new SecurityTokenException("Wrong username or password."); | |
// Not throwing exceptions indicates |
This file contains 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
using System; | |
using System.ServiceModel; | |
using Client_Service_with_callbacks_via_tcp.<YOUR_SERVICE_NAME>; | |
namespace Client_Service_with_callbacks_via_tcp | |
{ | |
class Program | |
{ | |
/// <summary> | |
/// Handles the callbacks from the server following |