Created
July 10, 2021 00:50
-
-
Save aossey/02d793af9a1460f134a49a65eed97d12 to your computer and use it in GitHub Desktop.
AWS SDK (.NET) Example of Adding Custom User-Agent Value by Extending the AmazonEC2Config Class and Overriding the UserAgent Get Method
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 Amazon.EC2; | |
namespace aws_sdk_user_agent_header_examples_dotnet | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var uaconfig = new UaEC2Config("test-ua-header"); | |
AmazonEC2Client ec2 = new AmazonEC2Client(uaconfig); | |
} | |
} | |
class UaEC2Config: AmazonEC2Config | |
{ | |
private string _uaString; | |
public UaEC2Config(string UaValue): base(){ | |
_uaString = UaValue; | |
} | |
public override string UserAgent{ | |
get | |
{ | |
return string.Format("{0}, {1}", _uaString, base.UserAgent); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment