Skip to content

Commit

Permalink
upgrading the .net code to pyro5
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed May 14, 2020
1 parent ab9ffa8 commit 49333f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
22 changes: 7 additions & 15 deletions dotnet/Razorvine.Pyrolite/NamingExample/TestNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,25 @@ private static void Test() {
ns.set_metadata("Pyro.NameServer", metadata);


Console.WriteLine("\nobjects registered in the name server:");
var objects = ns.list(null, null);
foreach(string key in objects.Keys) {
Console.WriteLine(key + " --> " + objects[key]);
}

Console.WriteLine("\nobjects registered in the name server, with metadata:");
var objectsm = ns.list_with_meta(null, null);
var objectsm = ns.list(null, null);
foreach(string key in objectsm.Keys) {
var registration = objectsm[key];
Console.WriteLine(key + " --> " + registration.Item1);
Console.WriteLine(" metadata: " + string.Join(", ", registration.Item2));
}

Console.WriteLine("\nobjects registered having all metadata:");
objects = ns.list(null, null, new []{"blahblah", "class:Pyro5.naming.NameServer"}, null);
var objects = ns.yplookup(new []{"blahblah", "class:Pyro5.nameserver.NameServer"}, null);
foreach(string name in objects.Keys) {
Console.WriteLine(name + " --> " + objects[name]);
var entry = objectsm[name];
Console.WriteLine(name + " --> " + entry.Item1);
Console.WriteLine(" metadata: " + string.Join(", ", entry.Item2));
}

Console.WriteLine("\nobjects registered having any metadata:");
objects = ns.list(null, null, null, new []{"blahblah", "class:Pyro5.naming.NameServer"});
objects = ns.yplookup(null, new []{"blahblah", "class:Pyro5.nameserver.NameServer"});
foreach(string name in objects.Keys) {
Console.WriteLine(name + " --> " + objects[name]);
}
Console.WriteLine("\nobjects registered having any metadata (showing it too):");
objectsm = ns.list_with_meta(null, null, null, new []{"blahblah", "class:Pyro5.naming.NameServer"});
foreach(string name in objectsm.Keys) {
var entry = objectsm[name];
Console.WriteLine(name + " --> " + entry.Item1);
Console.WriteLine(" metadata: " + string.Join(", ", entry.Item2));
Expand Down
26 changes: 4 additions & 22 deletions dotnet/Razorvine.Pyrolite/Pyrolite/Pyro/NameServerProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,8 @@ public void set_metadata(string name, ISet<string> metadata) {
call("set_metadata", name, metadata);
}

public IDictionary<string,string> list(string prefix, string regex) {
IDictionary hash = (IDictionary) call("list", prefix, regex);
IDictionary<string,string> typed=new Dictionary<string,string>(hash.Count);
foreach(object name in hash.Keys) {
typed[(string)name]=(string)hash[name];
}
return typed;
}

public IDictionary<string,string> list(string prefix, string regex, IEnumerable<string> metadata_all, IEnumerable<string> metadata_any) {
IDictionary hash = (IDictionary) call("list", prefix, regex, metadata_all, metadata_any);
IDictionary<string,string> typed=new Dictionary<string,string>(hash.Count);
foreach(object name in hash.Keys) {
typed[(string)name]=(string)hash[name];
}
return typed;
}

public IDictionary<string, Tuple<string, ISet<string>>> list_with_meta(string prefix, string regex) {
IDictionary hash = (IDictionary) call("list", prefix, regex, null, null, true);
public IDictionary<string, Tuple<string, ISet<string>>> list(string prefix, string regex) {
IDictionary hash = (IDictionary) call("list", prefix, regex, true);
IDictionary<string, Tuple<string, ISet<string>>> typed=new Dictionary<string, Tuple<string, ISet<string>>>(hash.Count);
foreach(object name in hash.Keys) {
var o = (object[]) hash[name];
Expand All @@ -86,8 +68,8 @@ public IDictionary<string, Tuple<string, ISet<string>>> list_with_meta(string pr
return typed;
}

public IDictionary<string, Tuple<string, ISet<string>>> list_with_meta(string prefix, string regex, IEnumerable<string> metadata_all, IEnumerable<string> metadata_any) {
IDictionary hash = (IDictionary) call("list", prefix, regex, metadata_all, metadata_any, true);
public IDictionary<string, Tuple<string, ISet<string>>> yplookup(IEnumerable<string> meta_all, IEnumerable<string> meta_any) {
IDictionary hash = (IDictionary) call("yplookup", meta_all, meta_any, true);
IDictionary<string, Tuple<string, ISet<string>>> typed=new Dictionary<string, Tuple<string, ISet<string>>>(hash.Count);
foreach(object name in hash.Keys) {
var o = (object[]) hash[name];
Expand Down

0 comments on commit 49333f3

Please sign in to comment.