Implements the OpenWire protocol.
Наследование: IWireFormat
Пример #1
0
 public virtual void TightUnmarshal(
     OpenWireFormat wireFormat,
     Object o,
     BinaryReader dataIn,
     BooleanStream bs)
 {
 }
Пример #2
0
 protected virtual int TightMarshalNestedObject1(
     OpenWireFormat wireFormat,
     DataStructure o,
     BooleanStream bs)
 {
     return wireFormat.TightMarshalNestedObject1(o, bs);
 }
Пример #3
0
 protected virtual DataStructure TightUnmarshalNestedObject(
     OpenWireFormat wireFormat,
     BinaryReader dataIn,
     BooleanStream bs)
 {
     return wireFormat.TightUnmarshalNestedObject(dataIn, bs);
 }
Пример #4
0
 public virtual void TightMarshal2(
     OpenWireFormat wireFormat,
     Object o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
 }
Пример #5
0
 protected virtual void TightMarshalNestedObject2(
     OpenWireFormat wireFormat,
     DataStructure o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     wireFormat.TightMarshalNestedObject2(o, dataOut, bs);
 }
Пример #6
0
 protected virtual void LooseMarshalObjectArray(
     OpenWireFormat wireFormat,
     DataStructure[] objects,
     BinaryWriter dataOut)
 {
     dataOut.Write(objects!=null);
     if (objects!=null)
     {
         dataOut.Write((short) objects.Length);
         for (int i = 0; i < objects.Length; i++)
         {
             LooseMarshalNestedObject(wireFormat, objects[i], dataOut);
         }
     }
 }
Пример #7
0
 protected virtual BrokerError LooseUnmarshalBrokerError(
     OpenWireFormat wireFormat,
     BinaryReader dataIn)
 {
     if (dataIn.ReadBoolean())
     {
         BrokerError answer = new BrokerError();
         
         answer.ExceptionClass = LooseUnmarshalString(dataIn);
         answer.Message = LooseUnmarshalString(dataIn);
         if (wireFormat.StackTraceEnabled)
         {
             short length = dataIn.ReadInt16();
             StackTraceElement[] stackTrace = new StackTraceElement[length];
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = new StackTraceElement();
                 element.ClassName = LooseUnmarshalString(dataIn);
                 element.MethodName = LooseUnmarshalString(dataIn);
                 element.FileName = LooseUnmarshalString(dataIn);
                 element.LineNumber = dataIn.ReadInt32();
                 stackTrace[i] = element;
             }
             answer.StackTraceElements = stackTrace;
             answer.Cause = LooseUnmarshalBrokerError(wireFormat, dataIn);
         }
         return answer;
     }
     else
     {
         return null;
     }
 }
Пример #8
0
 public virtual int TightMarshalLong1(OpenWireFormat wireFormat, long o, BooleanStream bs)
 {
     if (o == 0L)
     {
         bs.WriteBoolean(false);
         bs.WriteBoolean(false);
         return 0;
     }
     else
     {
         ulong ul = (ulong) o;
         if ((ul & 0xFFFFFFFFFFFF0000ul) == 0L)
         {
             bs.WriteBoolean(false);
             bs.WriteBoolean(true);
             return 2;
         }
         else if ((ul & 0xFFFFFFFF00000000ul) == 0L)
         {
             bs.WriteBoolean(true);
             bs.WriteBoolean(false);
             return 4;
         }
         else
         {
             bs.WriteBoolean(true);
             bs.WriteBoolean(true);
             return 8;
         }
     }
 }
Пример #9
0
 public virtual long LooseUnmarshalLong(OpenWireFormat wireFormat, BinaryReader dataIn)
 {
     return dataIn.ReadInt64();
 }
Пример #10
0
        public override void BeforeMarshall(OpenWireFormat wireFormat)
        {
            if (body == null)
            {
                Content = null;
            }
            else
            {
                MemoryStream stream = new MemoryStream();
                Formatter.Serialize(stream, body);
                Content = stream.ToArray();
            }

            //Console.WriteLine("BeforeMarshalling, content is: " + Content);

            base.BeforeMarshall(wireFormat);
        }
Пример #11
0
        public override void BeforeMarshall(OpenWireFormat wireFormat)
        {
            if(body == null)
            {
                Content = null;
            }
            else
            {
                MemoryStream buffer = new MemoryStream();
                Stream target = buffer;

                if(this.Connection != null && this.Connection.UseCompression)
                {
                    target = this.Connection.CompressionPolicy.CreateCompressionStream(target);
                    this.Compressed = true;
                }

                this.body.Marshal(target);
                target.Close();

                this.Content = buffer.ToArray();
            }

            Tracer.Debug("BeforeMarshalling, content is: " + Content);

            base.BeforeMarshall(wireFormat);
        }
Пример #12
0
 protected void LooseMarshalBrokerError(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut)
 {
     dataOut.Write(o!=null);
     if (o!=null)
     {
         LooseMarshalString(o.ExceptionClass, dataOut);
         LooseMarshalString(o.Message, dataOut);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 LooseMarshalString(element.ClassName, dataOut);
                 LooseMarshalString(element.MethodName, dataOut);
                 LooseMarshalString(element.FileName, dataOut);
                 dataOut.Write(element.LineNumber);
             }
             LooseMarshalBrokerError(wireFormat, o.Cause, dataOut);
         }
     }
 }
Пример #13
0
 public virtual long TightUnmarshalLong(OpenWireFormat wireFormat, BinaryReader dataIn, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             return dataIn.ReadInt64(); // dataIn.ReadInt64();
         }
         else
         {
             return dataIn.ReadInt32();
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             return dataIn.ReadInt16();
         }
         else
         {
             return 0;
         }
     }
 }
Пример #14
0
 public virtual void LooseUnmarshal(
     OpenWireFormat wireFormat,
     Object o,
     BinaryReader dataIn)
 {
 }
Пример #15
0
 protected virtual DataStructure LooseUnmarshalNestedObject(
     OpenWireFormat wireFormat,
     BinaryReader dataIn)
 {
     return wireFormat.LooseUnmarshalNestedObject(dataIn);
 }
Пример #16
0
 public virtual void LooseMarshal(
     OpenWireFormat wireFormat,
     Object o,
     BinaryWriter dataOut)
 {
 }
Пример #17
0
 protected void TightMarshalBrokerError2(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         TightMarshalString2(o.ExceptionClass, dataOut, bs);
         TightMarshalString2(o.Message, dataOut, bs);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 TightMarshalString2(element.ClassName, dataOut, bs);
                 TightMarshalString2(element.MethodName, dataOut, bs);
                 TightMarshalString2(element.FileName, dataOut, bs);
                 dataOut.Write(element.LineNumber);
             }
             TightMarshalBrokerError2(wireFormat, o.Cause, dataOut, bs);
         }
     }
 }
Пример #18
0
 protected int TightMarshalBrokerError1(OpenWireFormat wireFormat, BrokerError o, BooleanStream bs)
 {
     if (o == null)
     {
         bs.WriteBoolean(false);
         return 0;
     }
     else
     {
         int rc = 0;
         bs.WriteBoolean(true);
         rc += TightMarshalString1(o.ExceptionClass, bs);
         rc += TightMarshalString1(o.Message, bs);
         if (wireFormat.StackTraceEnabled)
         {
             rc += 2;
             StackTraceElement[] stackTrace = o.StackTraceElements;
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 rc += TightMarshalString1(element.ClassName, bs);
                 rc += TightMarshalString1(element.MethodName, bs);
                 rc += TightMarshalString1(element.FileName, bs);
                 rc += 4;
             }
             rc += TightMarshalBrokerError1(wireFormat, o.Cause, bs);
         }
         
         return rc;
     }
 }
Пример #19
0
 protected virtual void TightMarshalObjectArray2(
     OpenWireFormat wireFormat,
     DataStructure[] objects,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         dataOut.Write((short) objects.Length);
         for (int i = 0; i < objects.Length; i++)
         {
             TightMarshalNestedObject2(wireFormat, objects[i], dataOut, bs);
         }
     }
 }
Пример #20
0
 protected virtual int TightMarshalObjectArray1(
     OpenWireFormat wireFormat,
     DataStructure[] objects,
     BooleanStream bs)
 {
     if (objects != null)
     {
         int rc = 0;
         bs.WriteBoolean(true);
         rc += 2;
         for (int i = 0; i < objects.Length; i++)
         {
             rc += TightMarshalNestedObject1(wireFormat, objects[i], bs);
         }
         return rc;
     }
     else
     {
         bs.WriteBoolean(false);
         return 0;
     }
 }
Пример #21
0
 protected virtual void LooseMarshalNestedObject(
     OpenWireFormat wireFormat,
     DataStructure o,
     BinaryWriter dataOut)
 {
     wireFormat.LooseMarshalNestedObject(o, dataOut);
 }
Пример #22
0
 public virtual void TightMarshalLong2(
     OpenWireFormat wireFormat,
     long o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write(o);
         }
         else
         {
             dataOut.Write((int)o);
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write((short)o);
         }
     }
 }
Пример #23
0
 protected virtual DataStructure LooseUnmarshalCachedObject(
     OpenWireFormat wireFormat,
     BinaryReader dataIn)
 {
     /*
      if (wireFormat.isCacheEnabled()) {
      if (bs.ReadBoolean()) {
      short index = dataIndataIn.ReadInt16()Int16();
      DataStructure value = wireFormat.UnmarshalNestedObject(dataIn, bs);
      wireFormat.setInUnmarshallCache(index, value);
      return value;
      } else {
      short index = dataIn.ReadInt16();
      return wireFormat.getFromUnmarshallCache(index);
      }
      } else {
      return wireFormat.UnmarshalNestedObject(dataIn, bs);
      }
      */
     return wireFormat.LooseUnmarshalNestedObject(dataIn);
 }
Пример #24
0
 protected virtual void LooseMarshalCachedObject(
     OpenWireFormat wireFormat,
     DataStructure o,
     BinaryWriter dataOut)
 {
     /*
      if (wireFormat.isCacheEnabled()) {
      Short index = wireFormat.getMarshallCacheIndex(o);
      if (bs.ReadBoolean()) {
      dataOut.Write(index.shortValue(), dataOut);
      wireFormat.Marshal2NestedObject(o, dataOut, bs);
      } else {
      dataOut.Write(index.shortValue(), dataOut);
      }
      } else {
      wireFormat.Marshal2NestedObject(o, dataOut, bs);
      }
      */
     wireFormat.LooseMarshalNestedObject(o, dataOut);
 }
Пример #25
0
        public ITransport CompositeConnect(Uri location, SetTransport setTransport)
        {
            // Extract query parameters from broker Uri
            StringDictionary map = URISupport.ParseQuery(location.Query);

            // Set transport. properties on this (the factory)
            URISupport.SetProperties(this, map, "transport.");

            // See if there is a local address and port specified
            string localAddress = null;
            int localPort = -1;

            if(!String.IsNullOrEmpty(location.AbsolutePath) && !location.AbsolutePath.Equals("/"))
            {
                int index = location.AbsolutePath.IndexOf(':');
                try
                {
                    localPort = Int16.Parse(location.AbsolutePath.Substring(index + 1));
                    localAddress = location.AbsolutePath.Substring(1, index - 1);
                    Tracer.DebugFormat("Binding Socket to {0} on port: {1}", localAddress, localPort);
                }
                catch
                {
                    Tracer.Warn("Invalid Port value on URI for local bind option, ignoring.");
                }
            }

            Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port);
            Socket socket = DoConnect(location.Host, location.Port, localAddress, localPort );

            #if !NETCF
            socket.ReceiveBufferSize = ReceiveBufferSize;
            socket.SendBufferSize = SendBufferSize;
            socket.ReceiveTimeout = ReceiveTimeout;
            socket.SendTimeout = SendTimeout;
            #endif

            OpenWireFormat wireformat = new OpenWireFormat();
            // Set wireformat. properties on the wireformat owned by the tcpTransport
            URISupport.SetProperties(wireformat.PreferredWireFormatInfo, map, "wireFormat.");
            ITransport transport = DoCreateTransport(location, socket, wireformat);

            wireformat.Transport = transport;

            if(UseLogging)
            {
                transport = new LoggingTransport(transport);
            }

            if(UseInactivityMonitor)
            {
               transport = new InactivityMonitor(transport);
            }

            transport = new WireFormatNegotiator(transport, wireformat);
            if(setTransport != null)
            {
                setTransport(transport, location);
            }

            return transport;
        }
Пример #26
0
 public virtual void LooseMarshalLong(
     OpenWireFormat wireFormat,
     long o,
     BinaryWriter dataOut)
 {
     dataOut.Write(o);
 }
Пример #27
0
 public WireFormatNegotiator(ITransport next, OpenWireFormat wireFormat)
     : base(next)
 {
     this.wireFormat = wireFormat;
 }
Пример #28
0
 public virtual int TightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
 {
     return 0;
 }
Пример #29
0
 public override void BeforeMarshall(OpenWireFormat wireFormat)
 {
     MarshalledProperties = null;
     if(properties != null)
     {
         MarshalledProperties = properties.Marshal();
     }
 }
Пример #30
0
        public override void BeforeMarshall(OpenWireFormat wireFormat)
        {
            if (body == null)
            {
                Content = null;
            }
            else
            {
                MemoryStream result = new MemoryStream();
                Stream target = result;
                if(this.Connection != null && this.Connection.UseCompression)
                {
                    this.Compressed = true;
                    target = this.Connection.CompressionPolicy.CreateCompressionStream(target);                    
                }

                Formatter.Serialize(target, body);
                target.Close();
                Content = result.ToArray();
            }

            //Console.WriteLine("BeforeMarshalling, content is: " + Content);

            base.BeforeMarshall(wireFormat);
        }