public WWCP_Net_JSON_IO_Tests() { HTTPAPI = new HTTPServer<RoamingNetworks, RoamingNetwork>( TCPPort: IPPort.Parse(8000), DefaultServerName: "GraphDefined WWCP Unit Tests", DNSClient: new DNSClient(SearchForIPv6DNSServers: false) ); HTTPAPI.AttachTCPPort(IPPort.Parse(8001)); //WWCPAPI = OpenChargingCloudAPI.AttachToHTTPAPI(HTTPAPI); HTTPAPI.Start(); //var RN_1 = WWCPAPI.CreateNewRoamingNetwork(RoamingNetworkId: RoamingNetwork_Id.Parse("TEST_RN1"), // Description: I18NString.Create(Languages.de, "Test Roaming Netz 1"). // Add(Languages.en, "Test roaming network 1")); //var RN_2 = WWCPAPI.CreateNewRoamingNetwork(Hostname: HTTPHostname.Parse("virtualhost"), // RoamingNetworkId: RoamingNetwork_Id.Parse("TEST_RN2"), // Description: I18NString.Create(Languages.de, "Test Roaming Netz 2"). // Add(Languages.en, "Test roaming network 2")); //var CPO_1 = RN_1.CreateNewEVSEOperator(EVSEOperatorId: EVSEOperator_Id.Parse("DE*GEF"), // Name: I18NString.Create(Languages.de, "GraphDefined"), // Description: I18NString.Create(Languages.de, "GraphDefined Test EVSE Operator"), // Configurator: evseoperator => { // evseoperator.DataLicense = DataLicenses.OpenDatabaseLicense; // }); //var Pool_1 = CPO_1.CreateNewChargingPool(ChargingPoolId: ChargingPool_Id.Parse(CPO_1.Id, "1111"), // Configurator: pool => { // pool.Address = new Address(Country.Germany, // "07749", // I18NString.Create(Languages.de, "Jena"), // "Biberweg", "18"); // }); //var Pool_2 = CPO_1.CreateNewChargingPool(ChargingPoolId: ChargingPool_Id.Parse(CPO_1.Id, "2222"), // Configurator: pool => { // pool.Address = new Address(Country.Germany, // "07749", // I18NString.Create(Languages.de, "Jena"), // "Biberweg", "18"); // }); //var Pool_3 = CPO_1.CreateNewChargingPool(ChargingPoolId: ChargingPool_Id.Parse(CPO_1.Id, "3333"), // Configurator: pool => { // pool.Address = new Address(Country.Germany, // "07749", // I18NString.Create(Languages.de, "Jena"), // "Biberweg", "18"); // }); //var Sta1_P1 = Pool_1.CreateNewStation(ChargingStationId: ChargingStation_Id.Parse(CPO_1.Id, "11115678"), // Configurator: station => { // }); }
/// <summary> /// Load list of buttons. /// </summary> private void Load() { if (File.Exists("rdp_buttons.xml")) { XElement rdp = XElement.Load("rdp_buttons.xml"); foreach (var item in rdp.Elements())//<Button> { Buttons.Add(new RDPbutton() { group = item.Element("group").Value, caption = item.Element("caption").Value, hint = item.Element("hint").Value, ipport = IPPort.Parse(item.Element("ipport").Value), parameters = item.Element("parameters").Value, rdplogin = new LoginRDP(item.Element("rdplogin").Element("user").Value, Base64.DecodeBase64(item.Element("rdplogin").Element("pass").Value)), vpnlogin = new LoginVPN(item.Element("vpnlogin").Element("name").Value, item.Element("vpnlogin").Element("user").Value, Base64.DecodeBase64(item.Element("vpnlogin").Element("pass").Value)) }); } } else { Debug.WriteLine("Not found file 'rdp_buttons.xml'"); } }
/// <summary> /// Load all defined VPNs. /// </summary> /// <param name="path">rasphone.pbk file path</param> public void Open(string path) { List <Rasphone> lt = new List <Rasphone>(); const string pattern = @"\[(.*?)\]"; //var matches = Regex.Matches(System.IO.File.ReadAllText(path), pattern);//only name using (StreamReader sr = File.OpenText(path)) { string tmp_name = null, tmp_ip = null; string s = String.Empty; while ((s = sr.ReadLine()) != null) { if (Regex.IsMatch(s, pattern)) { tmp_name = s.Replace("[", "").Replace("]", ""); } if (s.IndexOf("PhoneNumber=") == 0) { tmp_ip = s.Remove(0, 12);//s.IndexOf('=') + 1 } if (!string.IsNullOrEmpty(tmp_name) && !string.IsNullOrEmpty(tmp_ip)) { lt.Add(new Rasphone(tmp_name, IPPort.Parse(tmp_ip))); tmp_name = tmp_ip = null; } } } Entries = lt.ToArray(); }
public void SetupEachTest() { var folder = "UsersAPI_NotificationTests"; // C:\Users\...\AppData\Local\Temp\UsersAPI_NotificationTests try { Directory.Delete(folder, true); } catch { } usersAPI = new UsersAPI( ExternalDNSName: "example.cloud", HTTPServerPort: IPPort.Parse(81), APIRobotEMailAddress: new EMailAddress( "Users API Unit Tests", SimpleEMailAddress.Parse("*****@*****.**") ), AdminOrganizationId: Organization_Id.Parse("admins"), SMTPClient: new NullMailer(), SMSClient: new NullSMSAPI(), LoggingPath: folder, Autostart: true );; nullMailer = usersAPI.SMTPClient as NullMailer; nullSMSClient = usersAPI.SMSClient as NullSMSAPI; usersAPI.AddOrganization(new Organization( Organization_Id.Parse("admins"), I18NString.Create(Languages.en, "Admins") )).Wait(); #region / //_HTTPServer.AddMethodCallback(HTTPHostname.Any, // HTTPMethod.GET, // HTTPPath.Root, // HTTPDelegate: Request => Task.FromResult( // new HTTPResponse.Builder(Request) { // HTTPStatusCode = HTTPStatusCode.OK, // Server = "Test Server", // Date = DateTime.UtcNow, // AccessControlAllowOrigin = "*", // AccessControlAllowMethods = "GET", // AccessControlAllowHeaders = "Content-Type, Accept, Authorization", // ContentType = HTTPContentType.TEXT_UTF8, // Content = "Hello World!".ToUTF8Bytes(), // Connection = "close" // }.AsImmutable)); #endregion }
/// <summary> /// Create a new HTTPClient using the given optional parameters. /// </summary> /// <param name="RemoteHost">The remote hostname to connect to.</param> /// <param name="RemoteCertificateValidator">A delegate to verify the remote TLS certificate.</param> /// <param name="ClientCert">The TLS client certificate to use.</param> /// <param name="RemotePort">An optional remote IP port to connect to [default: 443].</param> /// <param name="DNSClient">An optional DNS client.</param> public HTTPSClient(String RemoteHost, RemoteCertificateValidationCallback RemoteCertificateValidator, X509Certificate ClientCert = null, IPPort RemotePort = null, DNSClient DNSClient = null) : base(RemoteHost, RemotePort != null ? RemotePort : IPPort.Parse(443), RemoteCertificateValidator, ClientCert, DNSClient) { }
protected ATests() { _DNSClient = new DNSClient(SearchForIPv6DNSServers: false); if (RemoteAddress == IPv4Address.Localhost) { //HTTPAPI = new HTTPServer<RoamingNetworks, RoamingNetwork>( // TCPPort: RemotePort, // DefaultServerName: "GraphDefined WWCP Unit Tests", // DNSClient: _DNSClient // ); OpenChargingCloudAPI = new OpenChargingCloudAPI(LocalPort: IPPort.Parse(8001)); //WWCPAPI.Attach_GeoJSON_IO(); OpenChargingCloudAPI.Start(); } }
/// <summary> /// Create a new HTTPClient using the given optional parameters. /// </summary> /// <param name="RemoteHost">The remote hostname to connect to.</param> /// <param name="RemotePort">The remote IP port to connect to.</param> /// <param name="ClientCert">The TLS client certificate to use.</param> /// <param name="RemoteCertificateValidator">A delegate to verify the remote TLS certificate.</param> /// <param name="DNSClient">An optional DNS client.</param> public HTTPClient(String RemoteHost, IPPort RemotePort = null, RemoteCertificateValidationCallback RemoteCertificateValidator = null, X509Certificate ClientCert = null, DNSClient DNSClient = null) { this.Hostname = RemoteHost; this.RemotePort = RemotePort != null ? RemotePort : IPPort.Parse(80); this.RemoteCertificateValidator = RemoteCertificateValidator; this.ClientCert = ClientCert; this.DNSClient = DNSClient != null ? DNSClient : new DNSClient(); }
public static Boolean TryParse(JObject JSON, out HTTPSNotification Notification) { var url = JSON["URL"]?.Value <String>(); if (JSON["@context"]?.Value <String>() == JSONLDContext && url.IsNotNullOrEmpty()) { Notification = new HTTPSNotification(JSON["URL"]?.Value <String>(), JSON["method"] != null ? HTTPMethod.ParseString(JSON["method"].Value <String>()) : HTTPMethod.POST, JSON["TCPPort"] != null ? IPPort.Parse(JSON["TCPPort"].Value <String>()) : IPPort.HTTPS, JSON["basicAuth"]?["login"]?.Value <String>(), JSON["basicAuth"]?["password"]?.Value <String>(), JSON["APIKey"]?.Value <String>(), JSON["RequestTimeout"] != null ? TimeSpan.FromSeconds((Double)JSON["RequestTimeout"]?.Value <Int32>()) : new TimeSpan?(), (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())), JSON["description"]?.Value <String>()); return(true); } Notification = null; return(false); }
private void button_Click(object sender, RoutedEventArgs e) { //var book = new RemoteDesktop.Net.VPN.RasphoneBook(); //book.Open(book.RasphonePath); //var list = book.Entries; //var ras = new RemoteDesktop.Net.VPN.Rasdial(); //var output = ras.IsConnectedVPN("TARAN"); //ras.Connect("TARAN3", "jpietras", "Vfr4Mju73#"); //RemoteDesktop.Net.VPN.Rasdial.LaunchVPN(); var rdp = new Mstsc(); rdp.ShowArgumentHelp(); rdp.Connect("10.250.9.12"); var mc = Mstsc.OpenedMstsc(); RdpFile rf = new RdpFile() { FullAddress = IPPort.Parse("192.168.0.1"), UserName = "******", Password = "******" }; rf.Save("Test0.rdp"); var upr = RemoteDesktop.Encoding.CryptRDP.Unprotect("01000000D08C9DDF0115D1118C7A00C04FC297EB01000000D929C49724C9FB41857598688D6890E60000000002000000000003660000C000000010000000028AEC0FBBCE9F9C0385F9E887AAD8140000000004800000A000000010000000A033394A302FBDF474F8F7D6F55C1071180000005FE6AC5ADA5AD53F718AACE44EF290A3E8CFE69471FA5E3414000000EED74EAD563C64DCF62784AE9312DDB6CD2C6343"); //mw.FindNewProcess("Button");//dodanie do kontrolki przycisku ID procesu. RDP_Buttons but = new RDP_Buttons(); but.Buttons.Add(new RDPbutton("Grupa", "caption", "hin", IPPort.Parse("192.168.0.154"), "/admin", new LoginRDP("jpietras", "RGPlus123#"), new LoginVPN("TARAN", "jpietras", "RGPlus123#"))); but.Buttons.Add(new RDPbutton("grup", "cap", "hint", IPPort.Parse("192.168.34.154:80"), "", new LoginRDP("jpietras11", "RGPlus11"), new LoginVPN("Jastrzębie", "jpietras", "RGPlus123#"))); but.Buttons.Add(new RDPbutton("grup", "cap", "hint", IPPort.Parse("192.168.34.154:80"), "", new LoginRDP("jpietras12", "RGPlus12"), new LoginVPN())); //but.Save(); }
/// <summary> /// Initialize the GraphDevroom HTTP API using IPAddress.Any, http port 8080 and start the server. /// </summary> /// <param name="IPPort">The IP listing port.</param> public GraphDevroomHTTPAPI(IPPort IPPort = null, String DefaultServerName = __DefaultServerName, String HTTPRoot = __DefaultHTTPRoot, String URIPrefix = "", IGenericPropertyGraph<UInt64, Int64, GDVertexLabel, String, Object, UInt64, Int64, GDEdgeLabel, String, Object, UInt64, Int64, GDMultiEdgeLabel, String, Object, UInt64, Int64, GDHyperEdgeLabel, String, Object> Graph = null, String ServerThreadName = null, ThreadPriority ServerThreadPriority = ThreadPriority.AboveNormal, Boolean ServerThreadIsBackground = true, ConnectionIdBuilder ConnectionIdBuilder = null, ConnectionThreadsNameBuilder ConnectionThreadsNameBuilder = null, ConnectionThreadsPriorityBuilder ConnectionThreadsPriorityBuilder = null, Boolean ConnectionThreadsAreBackground = true, TimeSpan? ConnectionTimeout = null, UInt32 MaxClientConnections = TCPServer.__DefaultMaxClientConnections, IEnumerable<Assembly> CallingAssemblies = null, Boolean Autostart = false) : base((IPPort != null) ? IPPort : IPPort.Parse(8080), "", DefaultServerName, //ServerThreadName, //ServerThreadPriority, //ServerThreadIsBackground, // //ConnectionIdBuilder, //ConnectionThreadsNameBuilder, //ConnectionThreadsPriorityBuilder, //ConnectionThreadsAreBackground, // //ConnectionTimeout, //MaxClientConnections, Autostart: false) { this._Graph = (Graph != null) ? Graph : GraphDevroomGraphFactory.Create(1, "FOSDEM GraphDevroom Graph"); this._HTTPRoot = HTTPRoot; //this._Logger = Logger; #region / (HTTPRoot) //this.RegisterResourcesFolder(URIPrefix + "/", // _HTTPRoot, // DefaultFilename: "index.html"); // Redirect to GitHub pages this.RegisterMovedTemporarilyHandler("/", "http://graphdevroom.github.io"); #endregion #region /raw this.AddMethodCallback(HTTPMethod.GET, "/raw", HTTPContentType.HTML_UTF8, HTTPRequest => { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, ContentType = HTTPContentType.TEXT_UTF8, Content = HTTPRequest.RawHTTPHeader.ToString().ToUTF8Bytes(), CacheControl = "private", //Expires = "Mon, 25 Jun 2015 21:31:12 GMT", Connection = "close" }; }); #endregion #region ~/{Year}/{Event}/schedule #region GET ~/{Year}/{Event}/schedule #region HTML_UTF8 // ----------------------------------------------------------------------------- // curl -v -H "Accept: text/html" http://127.0.0.1:8080/{Year}/{Event}/schedule // ----------------------------------------------------------------------------- this.AddMethodCallback(HTTPMethod.GET, "/{Year}/{Event}/schedule", HTTPContentType.HTML_UTF8, HTTPDelegate: HTTPRequest => { #region Parse Year UInt16 Year; if (HTTPRequest.ParsedURIParameters.Length < 1) { Log.Timestamp("Bad request: Missing year query parameter!"); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.BadRequest, ContentType = HTTPContentType.JSON_UTF8, Content = new JObject(new JProperty("@context", "http://emi3group.org/contexts/BadRequest.jsonld"), new JProperty("Description", "Missing year query parameter!")). ToString().ToUTF8Bytes() }; } if (!UInt16.TryParse(HTTPRequest.ParsedURIParameters[0], out Year)) { Log.Timestamp("Bad request: Invalid year query parameter!"); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.BadRequest, ContentType = HTTPContentType.JSON_UTF8, Content = new JObject(new JProperty("@context", "http://emi3group.org/contexts/BadRequest.jsonld"), new JProperty("Value", HTTPRequest.ParsedURIParameters[0]), new JProperty("Description", "Invalid year query parameter!")). ToString().ToUTF8Bytes() }; } #endregion var Content = "lala"; return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, Server = this.DefaultServerName, ETag = "1", ContentType = HTTPContentType.HTML_UTF8, Content = Content.ToUTF8Bytes(), CacheControl = "no-cache" }; }); #endregion #endregion #endregion this.AddEventSource(EventIdentification: "Semantics.DebugLog", MaxNumberOfCachedEvents: 100, RetryIntervall: TimeSpan.FromSeconds(5), URITemplate: URIPrefix + "/DebugLog"); // HTTP ACCEPT TYPE != HTTP CONTENT TYPE !!! if (Autostart) this.Start(); }
public void Test_ChargingPools() { var HTTPClient = new HTTPClient(IPv4Address.Localhost, RemotePort: IPPort.Parse(8000), DNSClient: HTTPAPI.DNSClient); var RN = OpenChargingCloudAPI.CreateNewRoamingNetwork(Id: RoamingNetwork_Id.Parse("TEST_RN1"), Name: I18NString.Create(Languages.deu, "Test Roaming Netz 1"). Add(Languages.eng, "Test roaming network 1")); var CPO = RN.CreateChargingStationOperator(ChargingStationOperatorId: ChargingStationOperator_Id.Parse("DE*GEF"), Name: I18NString.Create(Languages.deu, "GraphDefined"), Description: I18NString.Create(Languages.deu, "GraphDefined EVSE Operator"), Configurator: evseoperator => { evseoperator.AddDataLicense(DataLicense.OpenDatabaseLicense); }); #region Verify GET /RNs/TEST_RN1/ChargingPools var URI = HTTPPath.Parse("/RNs/TEST_RN1/ChargingPools"); using (var HTTPTask = HTTPClient.Execute(client => client.GET(URI, requestbuilder => { requestbuilder.Host = HTTPHostname.Localhost; requestbuilder.ContentType = HTTPContentType.JSON_UTF8; requestbuilder.Accept.Add(HTTPContentType.JSON_UTF8); }), RequestTimeout: Timeout, CancellationToken: new CancellationTokenSource().Token)) { HTTPTask.Wait(Timeout); using (var HTTPResult = HTTPTask.Result) { Assert.AreEqual(HTTPStatusCode.OK, HTTPResult.HTTPStatusCode, "'GET " + URI + "' failed!"); Assert.AreEqual(new JArray().ToString(), JArray.Parse(HTTPResult.HTTPBody.ToUTF8String()).ToString(), "Invalid response for 'GET " + URI + "'!"); } } #endregion #region Verify COUNT /RNs/TEST_RN1/ChargingPools using (var HTTPTask = HTTPClient.Execute(client => client.COUNT(URI, requestbuilder => { requestbuilder.Host = HTTPHostname.Localhost; requestbuilder.ContentType = HTTPContentType.JSON_UTF8; requestbuilder.Accept.Add(HTTPContentType.JSON_UTF8); }), RequestTimeout: Timeout, CancellationToken: new CancellationTokenSource().Token)) { HTTPTask.Wait(Timeout); using (var HTTPResult = HTTPTask.Result) { Assert.AreEqual(HTTPStatusCode.OK, HTTPResult.HTTPStatusCode, "'GET " + URI + "' failed!"); Assert.AreEqual(new JObject(new JProperty("count", 0)).ToString(), JObject.Parse(HTTPResult.HTTPBody.ToUTF8String()).ToString(), "Invalid response for 'COUNT " + URI + "'!"); } } #endregion var Pool_1 = CPO.CreateChargingPool(ChargingPool_Id.Parse(CPO.Id, "1111"), pool => { pool.Address = Address.Create(Country.Austria, "07741", I18NString.Create(Languages.deu, "Wien"), "Hofplatz", "17"); }); var Pool_2 = CPO.CreateChargingPool(ChargingPool_Id.Parse(CPO.Id, "2222"), pool => { pool.Address = Address.Create(Country.Germany, "07749", I18NString.Create(Languages.deu, "Jena"), "Biberweg", "18"); }); var Pool_3 = CPO.CreateChargingPool(ChargingPool_Id.Parse(CPO.Id, "3333"), pool => { pool.Address = Address.Create(Country.Belgium, "07758", I18NString.Create(Languages.bgn, "Brussels"), "Avenue", "19"); }); #region Verify GET /RNs/TEST_RN1/ChargingPools URI = HTTPPath.Parse("/RNs/TEST_RN1/ChargingPools"); using (var HTTPTask = HTTPClient.Execute(client => client.GET(URI, requestbuilder => { requestbuilder.Host = HTTPHostname.Localhost; requestbuilder.ContentType = HTTPContentType.JSON_UTF8; requestbuilder.Accept.Add(HTTPContentType.JSON_UTF8); }), RequestTimeout: Timeout, CancellationToken: new CancellationTokenSource().Token)) { HTTPTask.Wait(Timeout); using (var HTTPResult = HTTPTask.Result) { Assert.AreEqual(HTTPStatusCode.OK, HTTPResult.HTTPStatusCode, "'GET " + URI + "' failed!"); Assert.AreEqual(new JArray( new JObject(new JProperty("ChargingPoolId", "DE*GEF*P1111"), new JProperty("OperatorId", "DE*GEF"), new JProperty("Address", new JObject(new JProperty("houseNumber", "17"), new JProperty("street", "Hofplatz"), new JProperty("postalCode", "07741"), new JProperty("city", new JObject(new JProperty("de", "Wien")) ), new JProperty("country", new JObject(new JProperty("en", "Austria")) ) )), new JProperty("ChargingStations", new JArray()) ), new JObject(new JProperty("ChargingPoolId", "DE*GEF*P2222"), new JProperty("OperatorId", "DE*GEF"), new JProperty("Address", new JObject(new JProperty("houseNumber", "18"), new JProperty("street", "Biberweg"), new JProperty("postalCode", "07749"), new JProperty("city", new JObject(new JProperty("de", "Jena") )), new JProperty("country", new JObject( new JProperty("en", "Germany"), new JProperty("de", "Deutschland") ) ) )), new JProperty("ChargingStations", new JArray()) ), new JObject(new JProperty("ChargingPoolId", "DE*GEF*P3333"), new JProperty("OperatorId", "DE*GEF"), new JProperty("Address", new JObject(new JProperty("houseNumber", "19"), new JProperty("street", "Avenue"), new JProperty("postalCode", "07758"), new JProperty("city", new JObject(new JProperty("be", "Brussels")) ), new JProperty("country", new JObject(new JProperty("en", "Belgium")) ) )), new JProperty("ChargingStations", new JArray()) ) ).ToString(), JArray.Parse(HTTPResult.HTTPBody.ToUTF8String()).ToString(), "Invalid response for 'GET " + URI + "'!"); } } #endregion #region Verify COUNT /RNs/TEST_RN1/ChargingPools using (var HTTPTask = HTTPClient.Execute(client => client.COUNT(URI, requestbuilder => { requestbuilder.Host = HTTPHostname.Localhost; requestbuilder.ContentType = HTTPContentType.JSON_UTF8; requestbuilder.Accept.Add(HTTPContentType.JSON_UTF8); }), RequestTimeout: Timeout, CancellationToken: new CancellationTokenSource().Token)) { HTTPTask.Wait(Timeout); using (var HTTPResult = HTTPTask.Result) { Assert.AreEqual(HTTPStatusCode.OK, HTTPResult.HTTPStatusCode, "'GET " + URI + "' failed!"); Assert.AreEqual(new JObject(new JProperty("count", 3)).ToString(), JObject.Parse(HTTPResult.HTTPBody.ToUTF8String()).ToString(), "Invalid response for 'COUNT " + URI + "'!"); } } #endregion }
/// <summary> /// Create a new DNS cache. /// </summary> /// <param name="CleanUpEvery">How often to remove outdated entries from DNS cache.</param> public DNSCache(TimeSpan?CleanUpEvery = null) { _DNSCache = new Dictionary <String, DNSCacheEntry>(); _CleanUpTimer = new Timer(RemoveExpiredCacheEntries, null, CleanUpEvery.HasValue ? CleanUpEvery.Value : TimeSpan.FromMinutes(1), // delay one round! CleanUpEvery.HasValue ? CleanUpEvery.Value : TimeSpan.FromMinutes(1)); _DNSCache.Add("localhost", new DNSCacheEntry(RefreshTime: DateTime.Now, EndOfLife: DateTime.Now + TimeSpan.FromDays(3650), DNSInfo: new DNSInfo(Origin: new IPSocket(IPv4Address.Parse("127.0.0.1"), IPPort.Parse(53)), QueryId: 0, IsAuthorativeAnswer: true, IsTruncated: false, RecursionDesired: false, RecursionAvailable: false, ResponseCode: DNSResponseCodes.NoError, Answers: new ADNSResourceRecord[] { new A("localhost", DNSQueryClasses.IN, TimeSpan.FromDays(3650), IPv4Address.Parse("127.0.0.1")), new AAAA("localhost", DNSQueryClasses.IN, TimeSpan.FromDays(3650), IPv6Address.Parse("::1")) }, Authorities: new ADNSResourceRecord[0], AdditionalRecords: new ADNSResourceRecord[0]) )); _DNSCache.Add("loopback", new DNSCacheEntry(RefreshTime: DateTime.Now, EndOfLife: DateTime.Now + TimeSpan.FromDays(3650), DNSInfo: new DNSInfo(Origin: new IPSocket(IPv4Address.Parse("127.0.0.1"), IPPort.Parse(53)), QueryId: 0, IsAuthorativeAnswer: true, IsTruncated: false, RecursionDesired: false, RecursionAvailable: false, ResponseCode: DNSResponseCodes.NoError, Answers: new ADNSResourceRecord[] { new A("loopback", DNSQueryClasses.IN, TimeSpan.FromDays(3650), IPv4Address.Parse("127.0.0.1")), new AAAA("loopback", DNSQueryClasses.IN, TimeSpan.FromDays(3650), IPv6Address.Parse("::1")) }, Authorities: new ADNSResourceRecord[0], AdditionalRecords: new ADNSResourceRecord[0]) )); }
/// <summary> /// Run the tutorial. /// </summary> public void Run() { // graph1 -> *SerializerArrow -> UDPMulticastSenderArrow ==[IP MULTICAST]=> UDPMulticastReceiverArrow -> -> graph2 // Create two independend graphs var graph1 = GraphFactory.CreateGenericPropertyGraph(1); var graph2 = GraphFactory.CreateGenericPropertyGraph(2); // Create an arrow sending all messages to UDP multicast var UDPMulticastSenderArrow = new UDPMulticastSenderArrow <String>("224.100.0.1", IPPort.Parse(9001)); var GraphSerializer = graph1.NewGraphMLSerializer(IncludePropertyTypes: true); var VertexSerializerArrow = GraphSerializer.NewVertexSerializerArrow(UDPMulticastSenderArrow); var EdgeSerializerArrow = GraphSerializer.NewEdgeSerializerArrow(UDPMulticastSenderArrow); var GraphSerializerArrow = GraphSerializer.NewGraphSerializerArrow(UDPMulticastSenderArrow); // Connect the graph1 vertex/edge added events to the serializers //graph1.OnVertexAdded += VertexSerializerArrow.ReceiveMessage; //graph1.OnEdgeAdded += EdgeSerializerArrow.ReceiveMessage; // Create an arrow receiving messages from UDP multicast var UDPMulticastReceiverArrow = new UDPMulticastReceiverArrow <String>("224.100.0.1", IPPort.Parse(9001)); UDPMulticastReceiverArrow.OnMessageAvailable += (Sender, Message) => Console.WriteLine(Sender.Address + ":" + Sender.Port + " => " + Message); // Populate the graph var v1 = graph1.AddVertex(v => v.SetProperty("graph", 1)); var v2 = graph1.AddVertex(v => v.SetProperty("graph", 1)); var v3 = graph1.AddVertex(v => v.SetProperty("graph", "1")); var v4 = graph1.AddVertex(v => v.SetProperty("graph", "2")); var e1 = graph1.AddEdge(v1, "links", v2, e => e.SetProperty("weight", 0.34)); var e2 = graph1.AddEdge(v2, "links", v3); GraphSerializerArrow.ReceiveMessage(graph1); while (true) { Thread.Sleep(100); } }