本文整理汇总了C#中Ice.Identity类的典型用法代码示例。如果您正苦于以下问题:C# Identity类的具体用法?C# Identity怎么用?C# Identity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Identity类属于Ice命名空间,在下文中一共展示了Identity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: removeObject
removeObject(string oaName, string id, Ice.Current current)
{
Debug.Assert(_adapters.ContainsKey(oaName));
Ice.Identity identity = new Ice.Identity();
identity.name = id;
_adapters[oaName].remove(identity);
}
示例2: addObject
addObject(string oaName, string id, Ice.Current current)
{
Debug.Assert(_adapters.ContainsKey(oaName));
Ice.Identity identity = new Ice.Identity();
identity.name = id;
_adapters[oaName].add(new TestIntfI(), identity);
}
示例3: run
public override int run(string[] args)
{
if(args.Length > 0)
{
Console.Error.WriteLine(appName() + ": too many arguments");
return 1;
}
var server = CallbackSenderPrxHelper.checkedCast(communicator().propertyToProxy("CallbackSender.Proxy"));
if(server == null)
{
Console.Error.WriteLine("invalid proxy");
return 1;
}
var adapter = communicator().createObjectAdapter("");
var ident = new Ice.Identity();
ident.name = Guid.NewGuid().ToString();
ident.category = "";
adapter.add(new CallbackReceiverI(), ident);
adapter.activate();
server.ice_getConnection().setAdapter(adapter);
server.addClient(ident);
communicator().waitForShutdown();
return 0;
}
示例4: FileI
public FileI(string name, DirectoryI parent)
{
_name = name;
_parent = parent;
_destroyed = false;
_id = new Identity();
_id.name = Guid.NewGuid().ToString();
}
示例5: DirectoryI
// DirectoryI constructor
public DirectoryI(Ice.Communicator communicator, string name, DirectoryI parent)
{
_name = name;
_parent = parent;
//
// Create an identity. The root directory has the fixed identity "RootDir"
//
_id = new Ice.Identity();
_id.name = _parent != null ? System.Guid.NewGuid().ToString() : "RootDir";
}
示例6: FileI
// FileI constructor
public FileI(Ice.Communicator communicator, string name, DirectoryI parent)
{
_name = name;
_parent = parent;
Debug.Assert(_parent != null);
//
// Create an identity
//
_id = new Ice.Identity();
_id.name = System.Guid.NewGuid().ToString();
}
示例7: DirectoryI
// DirectoryI constructor. parent == null indicates root directory.
public DirectoryI(string name, DirectoryI parent)
{
_name = name;
_parent = parent;
_id = new Identity();
_destroyed = false;
_contents = new Dictionary<string, NodeI>();
if(parent == null)
{
_id.name = "RootDir";
}
else
{
_id.name = Guid.NewGuid().ToString();
}
}
示例8: run
public override int run(string[] args)
{
//
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
//
// Create an object adapter
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
"LifecycleFilesystem", "default -h localhost -p 10000");
//
// Create the root directory.
//
DirectoryI root = new DirectoryI();
Ice.Identity id = new Ice.Identity();
id.name = "RootDir";
adapter.add(root, id);
//
// All objects are created, allow client requests now.
//
adapter.activate();
//
// Wait until we are done.
//
communicator().waitForShutdown();
if(interrupted())
{
System.Console.Error.WriteLine(appName() + ": received signal, shutting down");
}
return 0;
}
示例9: ice_identity
/// <summary>
/// Creates a new proxy that is identical to this proxy, except for the per-proxy context.
/// <param name="newIdentity">The identity for the new proxy.</param>
/// <returns>The proxy with the new identity.</returns>
/// </summary>
public ObjectPrx ice_identity(Identity newIdentity)
{
if(newIdentity.name.Length == 0)
{
throw new IllegalIdentityException();
}
if(newIdentity.Equals(_reference.getIdentity()))
{
return this;
}
else
{
ObjectPrxHelperBase proxy = new ObjectPrxHelperBase();
proxy.setup(_reference.changeIdentity(newIdentity));
return proxy;
}
}
示例10: allTests
allTests(Ice.Communicator communicator)
{
Ice.ObjectAdapter oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
oa.activate();
Ice.Object servant = new MyObjectI();
//
// Register default servant with category "foo"
//
oa.addDefaultServant(servant, "foo");
//
// Start test
//
Console.Out.Write("testing single category... ");
Console.Out.Flush();
Ice.Object r = oa.findDefaultServant("foo");
test(r == servant);
r = oa.findDefaultServant("bar");
test(r == null);
Ice.Identity identity = new Ice.Identity();
identity.category = "foo";
string[] names = new string[] { "foo", "bar", "x", "y", "abcdefg" };
Test.MyObjectPrx prx = null;
for(int idx = 0; idx < 5; ++idx)
{
identity.name = names[idx];
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
prx.ice_ping();
test(prx.getName() == names[idx]);
}
identity.name = "ObjectNotExist";
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
try
{
prx.getName();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
identity.name = "FacetNotExist";
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.FacetNotExistException)
{
// Expected
}
try
{
prx.getName();
test(false);
}
catch(Ice.FacetNotExistException)
{
// Expected
}
identity.category = "bar";
for(int idx = 0; idx < 5; idx++)
{
identity.name = names[idx];
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
try
{
//.........这里部分代码省略.........
示例11: allTests
public static void allTests(Ice.Communicator communicator)
#endif
{
ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast(
communicator.stringToProxy("ServerManager :default -p 12010"));
test(manager != null);
TestLocatorPrx locator = TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator());
test(locator != null);
TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry());
test(registry != null);
Write("testing stringToProxy... ");
Flush();
Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter");
Ice.ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter");
Ice.ObjectPrx base3 = communicator.stringToProxy("test");
Ice.ObjectPrx base4 = communicator.stringToProxy("ServerManager");
Ice.ObjectPrx base5 = communicator.stringToProxy("test2");
Ice.ObjectPrx base6 = communicator.stringToProxy("test @ ReplicatedAdapter");
WriteLine("ok");
Write("testing ice_locator and ice_getLocator... ");
test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0);
Ice.LocatorPrx anotherLocator =
Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("anotherLocator"));
@base = @base.ice_locator(anotherLocator);
test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0);
communicator.setDefaultLocator(null);
@base = communicator.stringToProxy("test @ TestAdapter");
test(@base.ice_getLocator() == null);
@base = @base.ice_locator(anotherLocator);
test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0);
communicator.setDefaultLocator(locator);
@base = communicator.stringToProxy("test @ TestAdapter");
test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0);
//
// We also test ice_router/ice_getRouter (perhaps we should add a
// test/Ice/router test?)
//
test(@base.ice_getRouter() == null);
Ice.RouterPrx anotherRouter = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("anotherRouter"));
@base = @base.ice_router(anotherRouter);
test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), anotherRouter) == 0);
Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("dummyrouter"));
communicator.setDefaultRouter(router);
@base = communicator.stringToProxy("test @ TestAdapter");
test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), communicator.getDefaultRouter()) == 0);
communicator.setDefaultRouter(null);
@base = communicator.stringToProxy("test @ TestAdapter");
test(@base.ice_getRouter() == null);
WriteLine("ok");
Write("starting server... ");
Flush();
manager.startServer();
WriteLine("ok");
Write("testing checked cast... ");
Flush();
TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);
test(obj != null);
TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(base2);
test(obj2 != null);
TestIntfPrx obj3 = TestIntfPrxHelper.checkedCast(base3);
test(obj3 != null);
ServerManagerPrx obj4 = ServerManagerPrxHelper.checkedCast(base4);
test(obj4 != null);
TestIntfPrx obj5 = TestIntfPrxHelper.checkedCast(base5);
test(obj5 != null);
TestIntfPrx obj6 = TestIntfPrxHelper.checkedCast(base6);
test(obj6 != null);
WriteLine("ok");
Write("testing [email protected] indirect proxy... ");
Flush();
obj.shutdown();
manager.startServer();
try
{
obj2.ice_ping();
}
catch(Ice.LocalException)
{
test(false);
}
WriteLine("ok");
Write("testing [email protected] indirect proxy... ");
Flush();
obj.shutdown();
manager.startServer();
try
{
obj6.ice_ping();
}
catch(Ice.LocalException)
{
test(false);
}
//.........这里部分代码省略.........
示例12: run
public override int run(string[] args)
{
Ice.ObjectPrx routerBase;
{
Console.Out.Write("testing stringToProxy for router... ");
Console.Out.Flush();
routerBase = communicator().stringToProxy("Glacier2/router:default -p 12347");
Console.Out.WriteLine("ok");
}
Glacier2.RouterPrx router;
{
Console.Out.Write("testing checked cast for router... ");
Console.Out.Flush();
router = Glacier2.RouterPrxHelper.checkedCast(routerBase);
test(router != null);
Console.Out.WriteLine("ok");
}
{
Console.Out.Write("testing router finder... ");
Console.Out.Flush();
Ice.RouterFinderPrx finder = Ice.RouterFinderPrxHelper.uncheckedCast(
communicator().stringToProxy("Ice/RouterFinder:default -p 12347"));
test(finder.getRouter().ice_getIdentity().Equals(router.ice_getIdentity()));
Console.Out.WriteLine("ok");
}
{
Console.Out.Write("installing router with communicator... ");
Console.Out.Flush();
communicator().setDefaultRouter(router);
Console.Out.WriteLine("ok");
}
{
Console.Out.Write("getting the session timeout... ");
Console.Out.Flush();
long timeout = router.getSessionTimeout();
test(timeout == 30);
Console.Out.WriteLine("ok");
}
Ice.ObjectPrx @base;
{
Console.Out.Write("testing stringToProxy for server object... ");
Console.Out.Flush();
@base = communicator().stringToProxy("c1/callback:tcp -p 12010");
Console.Out.WriteLine("ok");
}
{
Console.Out.Write("trying to ping server before session creation... ");
Console.Out.Flush();
try
{
@base.ice_ping();
test(false);
}
catch(Ice.ConnectionLostException)
{
Console.Out.WriteLine("ok");
}
catch(Ice.SocketException)
{
test(false);
}
}
{
Console.Out.Write("trying to create session with wrong password... ");
Console.Out.Flush();
try
{
router.createSession("userid", "xxx");
test(false);
}
catch(Glacier2.PermissionDeniedException)
{
Console.Out.WriteLine("ok");
}
catch(Glacier2.CannotCreateSessionException)
{
test(false);
}
}
{
Console.Out.Write("trying to destroy non-existing session... ");
Console.Out.Flush();
try
{
router.destroySession();
test(false);
}
//.........这里部分代码省略.........
示例13: createProxy
public ObjectPrx createProxy(Identity ident)
{
//
// Create a reference and return a reverse proxy for this
// reference.
//
return _instance.proxyFactory().referenceToProxy(_instance.referenceFactory().create(ident, this));
}
示例14: identityToString
/// <summary>
/// Converts an object identity to a string.
/// </summary>
/// <param name="ident">The object identity to convert.</param>
/// <returns>The string representation of the object identity.</returns>
public static string identityToString(Identity ident)
{
if(ident.category == null || ident.category.Length == 0)
{
return IceUtilInternal.StringUtil.escapeString(ident.name, "/");
}
else
{
return IceUtilInternal.StringUtil.escapeString(ident.category, "/") + '/' +
IceUtilInternal.StringUtil.escapeString(ident.name, "/");
}
}
示例15: stringToIdentity
/// <summary>
/// Converts a string to an object identity.
/// </summary>
/// <param name="s">The string to convert.</param>
/// <returns>The converted object identity.</returns>
public static Identity stringToIdentity(string s)
{
Identity ident = new Identity();
//
// Find unescaped separator; note that the string may contain an escaped
// backslash before the separator.
//
int slash = -1, pos = 0;
while((pos = s.IndexOf((System.Char) '/', pos)) != -1)
{
int escapes = 0;
while(pos - escapes > 0 && s[pos - escapes - 1] == '\\')
{
escapes++;
}
//
// We ignore escaped escapes
//
if(escapes % 2 == 0)
{
if(slash == -1)
{
slash = pos;
}
else
{
//
// Extra unescaped slash found.
//
IdentityParseException ex = new IdentityParseException();
ex.str = "unescaped backslash in identity `" + s + "'";
throw ex;
}
}
pos++;
}
if(slash == -1)
{
ident.category = "";
try
{
ident.name = IceUtilInternal.StringUtil.unescapeString(s, 0, s.Length);
}
catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
ex.str = "invalid identity name `" + s + "': " + e.Message;
throw ex;
}
}
else
{
try
{
ident.category = IceUtilInternal.StringUtil.unescapeString(s, 0, slash);
}
catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
ex.str = "invalid category in identity `" + s + "': " + e.Message;
throw ex;
}
if(slash + 1 < s.Length)
{
try
{
ident.name = IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.Length);
}
catch(System.ArgumentException e)
{
IdentityParseException ex = new IdentityParseException();
ex.str = "invalid name in identity `" + s + "': " + e.Message;
throw ex;
}
}
else
{
ident.name = "";
}
}
return ident;
}