Exemplo n.º 1
0
 public void add(EndpointFactory factory)
 {
     lock (this)
     {
         foreach (EndpointFactory f in _factories)
         {
             if (f.type() == factory.type())
             {
                 Debug.Assert(false);
             }
         }
         _factories.Add(factory);
     }
 }
Exemplo n.º 2
0
 public EndpointFactory get(short type)
 {
     lock (this)
     {
         for (int i = 0; i < _factories.Count; i++)
         {
             EndpointFactory f = _factories[i];
             if (f.type() == type)
             {
                 return(f);
             }
         }
         return(null);
     }
 }
Exemplo n.º 3
0
 public void add(EndpointFactory factory)
 {
     lock (this)
     {
         for (int i = 0; i < _factories.Count; i++)
         {
             EndpointFactory f = _factories[i];
             if (f.type() == factory.type())
             {
                 Debug.Assert(false);
             }
         }
         _factories.Add(factory);
     }
 }
Exemplo n.º 4
0
 public void add(EndpointFactory factory)
 {
     lock(this)
     {
         for(int i = 0; i < _factories.Count; i++)
         {
             EndpointFactory f = (EndpointFactory)_factories[i];
             if(f.type() == factory.type())
             {
                 Debug.Assert(false);
             }
         }
         _factories.Add(factory);
     }
 }
Exemplo n.º 5
0
        public EndpointI read(BasicStream s)
        {
            lock (this)
            {
                short type = s.readShort();

                for (int i = 0; i < _factories.Count; i++)
                {
                    EndpointFactory f = (EndpointFactory)_factories[i];
                    if (f.type() == type)
                    {
                        return(f.read(s));
                    }
                }

                return(new OpaqueEndpointI(type, s));
            }
        }
Exemplo n.º 6
0
        public EndpointI create(string str, bool oaEndpoint)
        {
            lock (this)
            {
                string s = str.Trim();
                if (s.Length == 0)
                {
                    Ice.EndpointParseException e = new Ice.EndpointParseException();
                    e.str = "value has no non-whitespace characters";
                    throw e;
                }

                Regex p = new Regex("([ \t\n\r]+)|$");
                Match m = p.Match(s);
                Debug.Assert(m.Success);

                string protocol = s.Substring(0, m.Index);

                if (protocol.Equals("default"))
                {
                    protocol = instance_.defaultsAndOverrides().defaultProtocol;
                }

                for (int i = 0; i < _factories.Count; i++)
                {
                    EndpointFactory f = (EndpointFactory)_factories[i];
                    if (f.protocol().Equals(protocol))
                    {
                        return(f.create(s.Substring(m.Index + m.Length), oaEndpoint));

                        // Code below left in place for debugging.

                        /*
                         * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint);
                         * BasicStream bs = new BasicStream(instance_, true);
                         * e.streamWrite(bs);
                         * Buffer buf = bs.getBuffer();
                         * buf.b.position(0);
                         * short type = bs.readShort();
                         * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs);
                         * System.Console.Error.WriteLine("Normal: " + e);
                         * System.Console.Error.WriteLine("Opaque: " + ue);
                         * return e;
                         */
                    }
                }

                //
                // If the stringified endpoint is opaque, create an unknown endpoint,
                // then see whether the type matches one of the known endpoints.
                //
                if (protocol.Equals("opaque"))
                {
                    EndpointI ue = new OpaqueEndpointI(s.Substring(m.Index + m.Length));
                    for (int i = 0; i < _factories.Count; i++)
                    {
                        EndpointFactory f = (EndpointFactory)_factories[i];
                        if (f.type() == ue.type())
                        {
                            //
                            // Make a temporary stream, write the opaque endpoint data into the stream,
                            // and ask the factory to read the endpoint data from that stream to create
                            // the actual endpoint.
                            //
                            BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding, true);
                            ue.streamWrite(bs);
                            Buffer buf = bs.getBuffer();
                            buf.b.position(0);
                            bs.readShort(); // type
                            return(f.read(bs));
                        }
                    }
                    return(ue); // Endpoint is opaque, but we don't have a factory for its type.
                }
                return(null);
            }
        }