Example #1
0
        /// <summary>
        ///
        /// </summary>
        internal Clan0x7E0_Action0x30_Ack(long iClientId, long iClanRank, Clan clan)
            : base(0x7E0, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            WriterStream.Write((byte)0x30);        //
            WriterStream.Write((ushort)iClientId); //
            WriterStream.Write((ushort)0x0100);    //
            WriterStream.Write((ushort)clan.Back); // clan background
            WriterStream.Write((ushort)clan.Logo); // clanlogo
            WriterStream.Write((byte)0x01);        //clan grade
            WriterStream.Write((byte)iClanRank);   // clan rank

            for (int iIndex = 0; iIndex < 146; iIndex++)
            {
                WriterStream.Write((byte)0x00);   // clan skills
            }
            WriterStream.WriteAsciiNull(clan.ClanName);
            WriterStream.Write((byte)0x00);           //
            WriterStream.Write((ushort)0x0000);       //
            WriterStream.Write((ushort)0x0000);       //
            WriterStream.Write((ushort)0x0000);       //
            WriterStream.Write((ushort)0x0000);       //
            WriterStream.WriteAsciiNull(clan.Slogan); // clan slogan


            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        internal Clan0x7E0_Action0x72_Ack(ClanMember[] clanMembers)
            : base(0x7E0, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            if (clanMembers == null && clanMembers.Length == 0)
            {
                WriterStream.Write((byte)0x0F);
                WriterStream.Write((uint)0x00000001);
            }
            else
            {
                WriterStream.Write((byte)0x72);     // Send clan members

                foreach (ClanMember clanMember in clanMembers)
                {
                    WriterStream.Write((byte)clanMember.ClanRank);    //clan rank
                    WriterStream.Write((byte)clanMember.ServerGuid);  //channel (0xff = offline) //channel (0x01 = channel 1)
                    WriterStream.Write((ushort)0x0000);
                    WriterStream.Write((ushort)0x0000);
                    WriterStream.Write((ushort)clanMember.Level);
                    WriterStream.Write((ushort)clanMember.ClassId);
                    WriterStream.WriteAsciiNull(clanMember.CharacterName);
                }
            }


            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        internal MessengerChatAck(long charid, string strName, string strMessage)
            : base(0x7E2, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            WriterStream.Write((ushort)charid);
            WriterStream.Write((ushort)0x0000);

            long beginPosition = WriterStream.Position;

            WriterStream.WriteAsciiNull(strName);

            long endPosition = WriterStream.Position;

            long nameSize = endPosition - beginPosition;

            for (int iIndex = 0; iIndex < 31 - nameSize; iIndex++)
            {
                WriterStream.Write((byte)0x00);
            }

            WriterStream.WriteAsciiNull(strMessage);   //


            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);
        }
        public async Task StartExecuteReturnsOkAndAddsHandlerIfPayloadIsValid()
        {
            var message = new ServerRegistration
            {
                Hostname = "testServer",
                Port     = 867,
            };
            ByteArrayContent payload;

            using (var ms = new MemoryStream())
                using (var writerStream = new WriterStream(ms))
                {
                    writerStream.CreateCompactBinaryWriter().Write(message);
                    payload = new ByteArrayContent(ms.GetBuffer());
                }

            var response = await
                           this.httpClient.PostAsync(TestUtils.GetUri(this.server,
                                                                      RegistrationClient.RegistrationEndpoint,
                                                                      string.Empty),
                                                     payload);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(this.server.ServerList["testServer"]);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        internal Friend0x7E1_Action0x06_Ack(Friend[] friendListArray)
            : base(0x7E1, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            WriterStream.Write((byte)0x06);
            WriterStream.Write((byte)friendListArray.Length);

            foreach (Friend friendList in friendListArray)
            {
                WriterStream.Write((ushort)friendList.FriendGuid);
                WriterStream.Write((ushort)0x0000);

                if (friendList.IsOnline == true)      // is Online ??
                {
                    WriterStream.Write((byte)0x07);   // Online
                }
                else
                {
                    WriterStream.Write((byte)0x08);             // Offline
                }
                WriterStream.WriteAsciiNull(friendList.FriendName);
            }

            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);
        }
        public void CanTranscode()
        {
            using (var stream1 = new MemoryStream())
                using (var stream2 = new MemoryStream())
                    using (var writerStream1 = new WriterStream(stream1))
                        using (var writerStream2 = new WriterStream(stream2))
                        {
                            // write into compact binary protocol first
                            var writer = writerStream1.CreateCompactBinaryWriter();
                            writer.Write(this.testObject);
                            stream1.Position = 0;
                            using (var readerStream1 = ReaderStream.FromMemoryStreamBuffer(stream1, null))
                            {
                                var reader = readerStream1.CreateCompactBinaryReader();
                                // re-write as simple protocol
                                var writer2 = writerStream2.CreateSimpleBinaryWriter();
                                Transcode.FromTo(reader, writer2);
                                stream2.Position = 0;

                                using (var readerStream2 = new ReaderStream(stream2))
                                {
                                    var reader2       = readerStream2.CreateSimpleBinaryReader();
                                    var anotherObject = reader2.Read <AnotherDerivedThing>();

                                    Assert.IsTrue(Comparer.Equal(anotherObject, this.testObject));
                                }
                            }
                        }
        }
Example #7
0
        public virtual int RequiredBytes(
            FrameContent frameContent,
            bool desynchronization,
            Reader.UnsyncMode unsyncMode)
        {
            if (unsyncMode == Reader.UnsyncMode.CountIncludesUnsyncBytes)
            {
                using (Writer writer = new Writer())
                {
                    writer.Unsynchronization = desynchronization;

                    using (WriterStream stream = new WriterStream(writer))
                    {
                        frameContent.Codec.Write(stream, frameContent);
                    }

                    writer.Flush();

                    return((int)writer.Length);
                }
            }
            else if (unsyncMode == Reader.UnsyncMode.CountExcludesUnsyncBytes)
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    frameContent.Codec.Write(stream, frameContent);

                    return((int)stream.Length);
                }
            }
            else
            {
                throw new NotSupportedException("Unknown unsync mode");
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        internal GetServerNameListAck(ServerInfo[] serverInfo, int iChannelGuid)
            : base(0x704, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            WriterStream.Write((int)iChannelGuid);
            WriterStream.Write((sbyte)serverInfo.Length);

            for (int iIndex = 0; iIndex < serverInfo.Length; iIndex++)
            {
                WriterStream.Write((ushort)serverInfo[iIndex].ServerGuid);

                WriterStream.Write((sbyte)0x0);
                WriterStream.Write((ushort)0x0);

                WriterStream.WriteAsciiNull(serverInfo[iIndex].ServerName);
            }


            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);
        }
Example #9
0
        //internal class AuthLogonChallenge_Result
        //{
        //    public byte m_iCommand = (byte)RealmListOpCode.CMSG_AUTH_CHALLENGE_RESULT; // 0x00 CMD_AUTH_LOGON_CHALLENGE
        //    public byte m_iError = 0;		           // 0 - ok
        //    public byte m_iUnk = 0;		           // 0x00
        //    public byte[] m_iB = new byte[32];
        //    public byte m_iGLen = 1;		           // 0x01
        //    public byte[] m_iG = new byte[1];
        //    public byte m_iNLen = 32;		           // 0x20
        //    public byte[] m_iN = new byte[32];
        //    public byte[] m_iS = new byte[32];
        //    public byte[] m_iUnk2 = new byte[16];
        //    public byte m_iUnk3 = 0;
        //}

        /// <summary>
        /// 等于 AuthLogonChallenge_Result 结构
        /// </summary>
        public Auth_AuthChallengeResult(SecureRemotePassword srp)
            : base((long)AuthOpCode.CMSG_AUTH_CHALLENGE_RESULT, 0)
        {
            WriterStream.Write((byte)AuthOpCode.CMSG_AUTH_CHALLENGE_RESULT);
            WriterStream.Write((byte)LogineErrorInfo.LOGIN_SUCCESS);
            //////////////////////////////////////////////////////////////////////////

            WriterStream.Write((byte)0);

            WriterStream.Write(srp.PublicEphemeralValueB.GetBytes(32), 0, 32);

            WriterStream.Write((byte)1);
            WriterStream.Write(srp.Generator.GetBytes(1), 0, 1);

            WriterStream.Write((byte)32);
            WriterStream.Write(srp.Modulus.GetBytes(32), 0, 32);

            WriterStream.Write(srp.Salt.GetBytes(32), 0, 32);

            BigInteger unknown = new BigInteger();

            unknown.GenRandomBits(128 /* 16 * 8 */, new Random(10));     /* 随机数 16字节 */
            WriterStream.Write(unknown.GetBytes(16), 0, 16);

            WriterStream.Write((byte)0);
        }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 public Auth_AuthChallengeResultError(LogineErrorInfo iErrorInfo)
     : base((long)AuthOpCode.CMSG_AUTH_CHALLENGE_RESULT, 3)
 {
     WriterStream.Write((byte)AuthOpCode.CMSG_AUTH_CHALLENGE_RESULT);
     WriterStream.Write((byte)0);
     WriterStream.Write((byte)iErrorInfo);   //  错误信息
 }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        internal AccountLoginAck(ServerInfo[] serverInfo)
            : base(0x708, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)0 /*6 + ?*/);        // ×ֶδóС
            WriterStream.Write((ushort)base.PacketID);      // ×ֶαàºÅ
            WriterStream.Write((ushort)0x00);               // ×ֶα£Áô
            //////////////////////////////////////////////////////////////////////////


            WriterStream.Write((uint)0x0C000000);
            WriterStream.Write((sbyte)0x0);

            // дÈëChannelsÐÅÏ¢
            for (int iIndex = 0; iIndex < serverInfo.Length; iIndex++)
            {
                WriterStream.Write((sbyte)(48 + iIndex));
                WriterStream.WriteAsciiNull(serverInfo[iIndex].ServerName);
                WriterStream.Write((int)serverInfo[iIndex].ServerGuid);
            }


            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)WriterStream.Length);       // ×ֶδóС
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        public Word_AuthResponse(bool bIsTBC)
            : base((long)WordOpCode.SMSG_AUTH_RESPONSE, 0)
        {
            WriterStream.Write((ushort)ByteOrder.NetToHost(13) /* 2 + 11 */); // Size
            WriterStream.Write((ushort)WordOpCode.SMSG_AUTH_RESPONSE);        // ID
            //////////////////////////////////////////////////////////////////////////

            WriterStream.Write((byte)ResponseCodes.AUTH_OK);

            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);

            WriterStream.Write((byte)0x02);

            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);
            WriterStream.Write((byte)0x00);

            if (bIsTBC)
            {
                WriterStream.Write((byte)0x01);
            }
            else
            {
                WriterStream.Write((byte)0x00);
            }
        }
        public void CanReadAndWritePrimitives()
        {
            const string test = "tacos";
            const float  a    = float.MinValue;
            const int    b    = int.MaxValue;
            const ulong  c    = ulong.MaxValue;
            const double d    = double.NegativeInfinity;

            using (var str = new MemoryStream())
                using (var writer = new WriterStream(str))
                {
                    writer.WriteString(Encoding.UTF8, test, test.Length);
                    writer.WriteFloat(a);
                    writer.WriteUInt32(b);
                    writer.WriteUInt64(c);
                    writer.WriteDouble(d);
                    writer.WriteVarUInt32(b);
                    writer.WriteVarUInt64(c);
                    str.Position = 0;

                    using (var reader = new ReaderStream(str))
                    {
                        Assert.AreEqual(reader.ReadString(Encoding.UTF8, test.Length), test);
                        Assert.AreEqual(reader.ReadFloat(), a);
                        Assert.AreEqual(reader.ReadUInt32(), b);
                        Assert.AreEqual(reader.ReadUInt64(), c);
                        Assert.AreEqual(reader.ReadDouble(), d);
                        Assert.AreEqual(reader.ReadVarUInt32(), b);
                        Assert.AreEqual(reader.ReadVarUInt64(), c);
                    }
                }
        }
Example #14
0
 /// <summary>
 ///
 /// </summary>
 public Realm_Ping()
     : base((long)RealmOpCode.SMSG_PING, 0 /* 3 + 0 */)
 {
     WriterStream.Write((byte)RealmOpCode.SMSG_PING);
     WriterStream.Write((ushort)0);
     //////////////////////////////////////////////////////////////////////////
 }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_LoginZoneClusterResult(bool isLogin)
            : base((long)ZoneClusterOpCodeToZone.SMSG_LOGIN_ZONE_RESULT, 5 /*4 + 1*/)
        {
            WriterStream.Write((ushort)5 /*4 + 1*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((bool)isLogin);
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_NotifyAddZoneClusterResult()
            : base((long)ZoneClusterOpCodeToDomain.SMSG_ADD_CURRENT_ZONE_CLUSTER_RESULT, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_PingDomain()
            : base((long)ZoneClusterOpCodeToDomain.CMSG_PING_DOMAIN, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_NotifyRemoveZone()
            : base((long)ZoneClusterOpCodeToZone.CMSG_NOTIFY_REMOVE_ZONE, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        public Zone_LoginZoneResult()
            : base((long)ZoneOpCodeToZoneCluster.CMSG_LOGIN_ZONE_CLUSTER, 4 /*4 + 0*/)
        {
            WriterStream.Write((ushort)4 /*4 + 0*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            // ...
        }
 public void Dispose()
 {
     if (this.sourceStreamWriter != null)
     {
         this.sourceStreamWriter.Dispose();
         this.sourceStreamWriter = null;
     }
 }
Example #21
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_RemoveZoneCluster()
            : base((long)ZoneClusterOpCodeToDomain.CMSG_REMOVE_CURRENT_ZONE_CLUSTER, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_PingZone()
            : base((long)ZoneClusterOpCodeToZone.CMSG_PING_ZONE, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)7 /*6 + 1*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #23
0
        /// <summary>
        ///
        /// </summary>
        public Zone_NotifyRemoveZoneResult()
            : base((long)ZoneOpCodeToZoneCluster.SMSG_REMOVE_CURRENT_ZONE_RESULT, 4 /*4 + 0*/)
        {
            WriterStream.Write((ushort)4 /*4 + 0*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            // ...
        }
Example #24
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_AddZoneResult()
            : base((long)ZoneClusterOpCodeToZone.SMSG_NOTIFY_ADD_ZONE_RESULT, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        public ZoneCluster_LoginZone()
            : base((long)ZoneClusterOpCodeToZone.CMSG_LOGIN_ZONE, 0 /*4 + ?*/)
        {
            WriterStream.Write((ushort)7 /*4 + ?*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write((byte)0x00);
        }
Example #26
0
        /// <summary>
        ///
        /// </summary>
        public Zone_LoginZoneClusterResult(bool isCheckPass)
            : base((long)ZoneOpCodeToZoneCluster.SMSG_LOGIN_ZONE_CLUSTER_RESULT, 0 /*4 + 1*/)
        {
            WriterStream.Write((ushort)5 /*4 + 1*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号

            WriterStream.Write(isCheckPass);
        }
Example #27
0
        /// <summary>
        ///
        /// </summary>
        public Realm_RegisterRealmResult(long iRealmID)
            : base((long)RealmOpCode.CMSG_REGISTER_REALM_RESULT, 7 /* ProcessNet.REALM_HEAD_SIZE + 4 */)
        {
            WriterStream.Write((byte)RealmOpCode.CMSG_REGISTER_REALM_RESULT);      // ×ֶαàºÅ
            WriterStream.Write((ushort)4);                                         // ×Ö¶ÎÊ£Óà´óС

            WriterStream.Write((uint)iRealmID);
        }
Example #28
0
        private async void StartRegistration()
        {
            IPAddress[] addresses;
            try
            {
                addresses =
                    await Task <IPAddress[]> .Factory.FromAsync(Dns.BeginGetHostAddresses, Dns.EndGetHostAddresses,
                                                                this.destinationHostname, null);
            }
            catch (SocketException e)
            {
                Events.Write.RegistrationDestinationResolutionFailed(this.destinationHostname, e.Message);
                return;
            }

            var serverRegistration = new ServerRegistration
            {
                Hostname        = this.sourceHostname,
                Port            = this.sourcePort,
                MachineFunction = this.sourceMachineFunction,
                Datacenter      = this.sourceDatacenter,
            };

            foreach (var counter in this.dataManager.Counters)
            {
                serverRegistration.Counters.Add(
                    new CounterInfo
                {
                    Name       = counter.Name,
                    Type       = counter.Type,
                    Dimensions = counter.Dimensions.ToList(),
                    StartTime  = counter.StartTime.ToMillisecondTimestamp(),
                    EndTime    = counter.EndTime.ToMillisecondTimestamp(),
                });
            }

            byte[] payload;
            using (var ms = new MemoryStream())
                using (var writerStream = new WriterStream(ms, this.dataManager.MemoryStreamManager))
                {
                    var writer = writerStream.CreateCompactBinaryWriter();
                    writer.Write(serverRegistration);
                    payload = ms.ToArray();
                }

            foreach (var address in addresses)
            {
                this.RegisterWithAddress(address, payload);
            }

            lock (this)
            {
                if (this.registrationTimer != null)
                {
                    this.registrationTimer.Change(this.registrationInterval, TimeSpan.Zero);
                }
            }
        }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        public Domain_RemoveCurrentZoneClusterResult()
            : base((long)DomainOpCodeFromZoneCluster.CMSG_REMOVE_CURRENT_ZONE_CLUSTER_RESULT, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)7 /*6 + 1*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号
            WriterStream.Write((ushort)0x00);               // 字段保留

            WriterStream.Write((byte)0x00);
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        public Domain_PongDomain()
            : base((long)DomainOpCodeFromZoneCluster.CMSG_PONG_DOMAIN, 0 /*6 + ?*/)
        {
            WriterStream.Write((ushort)7 /*6 + 1*/);        // 字段大小
            WriterStream.Write((ushort)base.PacketID);      // 字段编号
            WriterStream.Write((ushort)0x00);               // 字段保留

            WriterStream.Write((byte)0x00);
        }
Example #31
0
        internal ReadWriteStreamManager()
#endif
        {

            ReaderFirstBufferPosition = 0;
            WriterFirstBufferPosition = 0;
            ReaderBufferArrayList = new ArrayList();
            WriterBufferArrayList = new ArrayList();

            _writerStream = new WriterStream(this);
            _readerStream = new ReaderStream(this);

            _bufferLock = new ReaderWriterLock();
        }
 internal WsdlParser(TextReader input, string outputDir, ArrayList outCodeStreamList, string locationURL, bool bWrappedProxy, string proxyNamespace)
 {
     this._readerStreamsWsdl = new ReaderStream(locationURL);
     this._readerStreamsWsdl.InputStream = input;
     this._writerStreams = null;
     this._outputDir = outputDir;
     this._outCodeStreamList = outCodeStreamList;
     this._bWrappedProxy = bWrappedProxy;
     if ((proxyNamespace == null) || (proxyNamespace.Length == 0))
     {
         this._proxyNamespace = "InteropNS";
     }
     else
     {
         this._proxyNamespace = proxyNamespace;
     }
     if (outputDir == null)
     {
         outputDir = ".";
     }
     int length = outputDir.Length;
     if (length > 0)
     {
         char ch = outputDir[length - 1];
         if ((ch != '\\') && (ch != '/'))
         {
             this._outputDir = this._outputDir + '\\';
         }
     }
     this._URTNamespaces = new ArrayList();
     this._blockDefault = SchemaBlockType.ALL;
     this._primedNametable = CreatePrimedNametable();
 }
Example #33
0
            internal static void Flush(WriterStream writerStream)
            {
                while (writerStream != null)
                {
                    writerStream._writer.Flush();
                    writerStream = writerStream._next;
                }

                return;
            }
Example #34
0
 internal static void Close(WriterStream outputStreams)
 {
     WriterStream output = outputStreams;
     while (output != null)
     {
         output._writer.Close();
         output = output._next;
     }
 }
Example #35
0
            // Prints all the types in the namespace
            internal void PrintCSC(WriterStream writerStream)
            {
                Util.Log("URTNamespace.PrintCSC Entry "+Name);               
                Debug.Assert(!IsEmpty, "Empty namespace " + Name + " being printed");
                TextWriter textWriter = writerStream.OutputStream;
                // Check to see if there is anything to print for this namespace
                bool bprint = false;
                if (_numURTComplexTypes > 0)
                {
                    for (int i=0;i<_URTComplexTypes.Count;i++)
                    {
                        URTComplexType type = (URTComplexType) _URTComplexTypes[i];
                        if (type != null && type.IsPrint)
                            bprint = true;
                    }
                }

                if (_numURTSimpleTypes > 0)
                {
                    for (int i=0;i<_URTSimpleTypes.Count;i++)
                    {
                        URTSimpleType type = (URTSimpleType) _URTSimpleTypes[i];
                        if (type != null)
                            bprint = true;
                    }
                }

                if (_URTInterfaces.Count > 0)
                    bprint = true;


                if (!bprint)
                    return;
                // End of check to see if there is anything to print


                String indentation = String.Empty;

                Stream stream = ((StreamWriter)textWriter).BaseStream;
                if (!writerStream.GetWrittenTo())
                {
                    // Only print when new output file is used
                    textWriter.WriteLine("using System;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Messaging;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Metadata;");
                    textWriter.WriteLine("using System.Runtime.Remoting.Metadata.W3cXsd2001;");
                    textWriter.WriteLine("using System.Runtime.InteropServices;");
                    writerStream.SetWrittenTo();
                }

                if ((Namespace != null) &&
                    (Namespace.Length != 0))
                {
                    textWriter.Write("namespace ");
                    textWriter.Write(WsdlParser.IsValidCS(EncodedNS));
                    textWriter.WriteLine(" {");
                    indentation = "    ";
                }


                StringBuilder sb = new StringBuilder(256);
                if (_numURTComplexTypes > 0)
                {
                    for (int i=0;i<_URTComplexTypes.Count;i++)
                    {
                        URTComplexType type = (URTComplexType) _URTComplexTypes[i];
                        if (type != null && type.IsPrint)
                        {
                            Util.Log("URTNamespace.PrintCSC Invoke Complex type PrintCSC");                                                                                                             
                            type.PrintCSC(textWriter, indentation, _encodedNS, sb);
                        }
                    }
                }

                if (_numURTSimpleTypes > 0)
                {
                    for (int i=0;i<_URTSimpleTypes.Count;i++)
                    {
                        URTSimpleType type = (URTSimpleType) _URTSimpleTypes[i];
                        if (type != null)
                        {
                            Util.Log("URTNamespace.PrintCSC Invoke Simple type PrintCSC");                                                                                                                                          
                            type.PrintCSC(textWriter, indentation, _encodedNS, sb);
                        }
                    }
                }

                for (int i=0;i<_URTInterfaces.Count;i++)
                {
                    Util.Log("URTNamespace.PrintCSC Invoke Interfaces PrintCSC");                                                                                                                                   
                    ((URTInterface)_URTInterfaces[i]).PrintCSC(textWriter, indentation, _encodedNS, sb);
                }

                if ((Namespace != null) &&
                    (Namespace.Length != 0))
                    textWriter.WriteLine('}');

                return;
            }
Example #36
0
            internal static WriterStream GetWriterStream(ref WriterStream outputStreams, String outputDir, String fileName, ref String completeFileName)
            {
                Util.Log("WriterStream.GetWriterStream "+fileName);                             
                WriterStream output = outputStreams;
                while (output != null)
                {
                    if (output._fileName == fileName)
                        return(output);
                    output = output._next;
                }

                String diskFileName = fileName;
                if (diskFileName.EndsWith(".exe", StringComparison.Ordinal) || diskFileName.EndsWith(".dll", StringComparison.Ordinal))
                    diskFileName = diskFileName.Substring(0, diskFileName.Length - 4);
                String _completeFileName = outputDir + diskFileName + ".cs";
                completeFileName = _completeFileName;
                //TextWriter textWriter = new StreamWriter(outputDir + fileName + ".cs", false);
                TextWriter textWriter = new StreamWriter(_completeFileName, false, new UTF8Encoding(false));
                output = new WriterStream(fileName, textWriter);
                output._next = outputStreams;
                outputStreams = output;
                Util.Log("WriterStream.GetWriterStream in fileName "+fileName+" completeFileName "+_completeFileName);                              
                return(output);
            }