1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
//===============================================
// ARTIFACT: code_snippet.cpp
#include "code_snippet.h"
#include <system/scope_guard.h>
#include <system/exceptions.h>
RTTI_INFO_IMPL_HASH(2786099534u, ::UseIP, ThisTypeBaseTypesInfo);
System::String UseIP::get_IP()
{
return pr_IP;
}
void UseIP::set_IP(System::String value)
{
pr_IP = value;
}
UseIP::UseIP(System::String IP)
{
//Self Reference+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
System::Details::ThisProtector __local_self_ref(this);
//---------------------------------------------------------Self Reference
this->set_IP(IP);
}
System::SharedPtr<HttpWebRequest> UseIP::CreateWebRequest(System::SharedPtr<Uri> uri)
{
System::SharedPtr<ServicePoint> servicePoint = ServicePointManager->FindServicePoint(uri);
servicePoint->BindIPEndPointDelegate = System::MakeObject<BindIPEndPoint>(Bind);
return System::StaticCast_noexcept<_UnknownType_>(WebRequest->Create(uri));
}
System::SharedPtr<IPEndPoint> UseIP::Bind(System::SharedPtr<ServicePoint> servicePoint, System::SharedPtr<IPEndPoint> remoteEndPoint, int32_t retryCount)
{
System::SharedPtr<IPAddress> address = IPAddress->Parse(this->get_IP());
return System::MakeObject<IPEndPoint>(address, 0);
}
//===============================================
// ARTIFACT: code_snippet.h
#pragma once
#include <system/string.h>
#include <cstdint>
class UseIP : public System::Object
{
typedef UseIP ThisType;
typedef System::Object BaseType;
typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
RTTI_INFO_DECL();
public:
System::String get_IP();
UseIP(System::String IP);
System::SharedPtr<HttpWebRequest> CreateWebRequest(System::SharedPtr<Uri> uri);
private:
System::String pr_IP;
void set_IP(System::String value);
System::SharedPtr<IPEndPoint> Bind(System::SharedPtr<ServicePoint> servicePoint, System::SharedPtr<IPEndPoint> remoteEndPoint, int32_t retryCount);
}; |
Partager