Exemplo n.º 1
0
        public void GetSet_Headers_Equal(Data data, HeaderData headerData, string value)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var test = new Message(data);

            var messageContextDataFactory = fixture.Create<IMessageContextDataFactory>();

            var property = messageContextDataFactory.Create(value, headerData);
            test.SetHeader(property, headerData);

            var headerData2 = test.GetHeader(property);
            Assert.Equal(headerData2, headerData);
        }
        public void GetSet_InternalHeader(Data data, Dictionary<string, object> headers, HeaderData headerData)
        {
            var factory = Create();
            var test = factory.Create(data, headers);

            var messageContextDataFactory = CreateDataFactory();

            var property = messageContextDataFactory.Create("Test", headerData);
            test.SetInternalHeader(property, headerData);

            var headerData2 = test.GetInternalHeader(property);
            Assert.Equal(headerData2, headerData);
        }
Exemplo n.º 3
0
        private void Build()
        {
            var buffer = File.GetData();

            var baseOffset = 0;

            this.Header = buffer.ToStructure<HeaderData>(ref baseOffset);
            if (Header.Magic1 != 0x3142474C || Header.Magic2 != 0x3150474C)     // LGB1 & LGP1
                throw new System.IO.InvalidDataException();

            Groups = new LgbGroup[Header.GroupCount];
            for (int i = 0; i < Header.GroupCount; ++i) {
                var groupOffset = baseOffset + BitConverter.ToInt32(buffer, baseOffset + i * 4);
                Groups[i] = new LgbGroup(this, buffer, groupOffset);
            }
        }
Exemplo n.º 4
0
    //패킷의 헤더 생성
    byte[] CreateHeader <T>(Packet <T> data)
    {
        byte[] msg = data.GetPacketData();

        HeaderData       headerData       = new HeaderData();
        HeaderSerializer headerSerializer = new HeaderSerializer();

        headerData.length = (short)msg.Length;
        headerData.source = (byte)NetworkManager.Source.ClientSource;
        headerData.id     = (byte)data.GetPacketId();

        headerSerializer.Serialize(headerData);
        byte[] header = headerSerializer.GetSerializedData();

        return(header);
    }
        public void GetHeader(string value)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var message = CreateMessage();
            var test = new ReceivedMessage<FakeMessage>(message);

            var messageContextDataFactory = fixture.Create<IMessageContextDataFactory>();

            var headerData = new HeaderData();
            messageContextDataFactory.Create(value, headerData)
                .Returns(new MessageContextData<HeaderData>(value, headerData));

            var property = messageContextDataFactory.Create(value, headerData);

            Assert.Equal(test.GetHeader(property), headerData);
        }
Exemplo n.º 6
0
    //패킷의 헤더 부분을 생성하는 메소드
    byte[] CreateHeader <T>(IPacket <T> data, P2PPacketId Id)
    {
        byte[] msg = data.GetPacketData();

        HeaderData       headerData       = new HeaderData();
        HeaderSerializer headerSerializer = new HeaderSerializer();

        headerData.Id     = (byte)Id;
        headerData.source = (byte)DataHandler.Source.ClientSource;
        headerData.length = (short)msg.Length;

        headerSerializer.Serialize(headerData);
        byte[] header = headerSerializer.GetSerializedData();

        return(header);
    }
Exemplo n.º 7
0
        public PackageCreatez(MainForm xParent, PackType xThisType)
        {
            this.MdiParent = xParent;
            xparent        = xParent;
            InitializeComponent();
            List <PackageType> y = new List <PackageType>();

            if (xThisType == PackType.STFS)
            {
                xsession = new CreateSTFS();
                PackageType[] x = (PackageType[])Enum.GetValues(typeof(PackageType));
                y.AddRange(x);
                y.RemoveAll(new Predicate <PackageType>(ptcheck));
                node1.DataKey             = (ushort)0xFFFF;
                node1.NodeClick          += new EventHandler(xReturn_NodeClick);
                comboBoxEx1.SelectedIndex = 0;
                comboBoxEx4.DataSource    = Enum.GetValues(typeof(SphereColor));
                comboBoxEx4.SelectedIndex = 0;
                comboBoxEx5.DataSource    = Enum.GetValues(typeof(DashStyle));
                comboBoxEx5.SelectedIndex = 0;
                numericUpDown4.Value      = xsession.ThemeSettings.AvatarLightingAmbient;
                numericUpDown7.Value      = xsession.ThemeSettings.AvatarLightingDirectional3;
                numericUpDown8.Value      = xsession.ThemeSettings.AvatarLightingDirectional0;
                numericUpDown9.Value      = xsession.ThemeSettings.AvatarLightingDirectional1;
                numericUpDown10.Value     = xsession.ThemeSettings.AvatarLightingDirectional2;
                advTree1.SelectedIndex    = 0;
                tabItem7.Visible          = false;
            }
            else
            {
                y.Add(PackageType.OriginalXboxGame);
                y.Add(PackageType.HDDInstalledGame);
                y.Add(PackageType.GamesOnDemand);
                y.Add(PackageType.SocialTitle);
                tabItem6.Visible    = false;
                xhead               = new HeaderData();
                tabItem5.Visible    = false;
                tabItem4.Visible    = false;
                comboBoxEx1.Visible = false;
            }
            xtype = xThisType;
            comboBoxEx2.DataSource    = y.ToArray();
            comboBoxEx2.SelectedIndex = 0;
            comboBoxEx3.DataSource    = Enum.GetValues(typeof(Languages));
            comboBoxEx3.SelectedIndex = 0;
            SetText();
        }
        public void GetHeader(string value)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var message = CreateMessage();
            var test    = new ReceivedMessage <FakeMessage>(message);

            var messageContextDataFactory = fixture.Create <IMessageContextDataFactory>();

            var headerData = new HeaderData();

            messageContextDataFactory.Create(value, headerData)
            .Returns(new MessageContextData <HeaderData>(value, headerData));

            var property = messageContextDataFactory.Create(value, headerData);

            Assert.Equal(test.GetHeader(property), headerData);
        }
Exemplo n.º 9
0
    //Tcp 데이터 수신
    void TcpReceiveDataCallback(IAsyncResult asyncResult)
    {
        AsyncData asyncData = (AsyncData)asyncResult.AsyncState;
        Socket    tcpSock   = asyncData.sock;

        try
        {
            asyncData.msgSize = (short)tcpSock.EndReceive(asyncResult);
        }
        catch
        {
            Debug.Log("NetworkManager::HandleAsyncDataReceive.EndReceive 에러");
            tcpSock.Close();
            return;
        }

        if (asyncData.msgSize >= NetworkManager.packetId)
        {
            Array.Resize(ref asyncData.msg, asyncData.msgSize + NetworkManager.packetSource + NetworkManager.packetId);
            Debug.Log(asyncData.msg.Length);

            HeaderData       headerData       = new HeaderData();
            HeaderSerializer headerSerializer = new HeaderSerializer();
            headerSerializer.SetDeserializedData(asyncData.msg);
            headerSerializer.Deserialize(ref headerData);

            DataPacket packet = new DataPacket(headerData, asyncData.msg);

            lock (receiveLock)
            {
                try
                {   //큐에 삽입
                    Debug.Log("Enqueue Message Length : " + packet.msg.Length);
                    msgs.Enqueue(packet);
                }
                catch
                {
                    Console.WriteLine("NetworkManager::HandleAsyncDataReceive.Enqueue 에러");
                }
            }
        }

        //재 수신
        asyncData = new AsyncData(tcpSock);
        tcpSock.BeginReceive(asyncData.msg, 0, NetworkManager.packetLength, SocketFlags.None, new AsyncCallback(TcpReceiveLengthCallback), asyncData);
    }
Exemplo n.º 10
0
        private void Build()
        {
            const int BaseOffset = 0x14;

            var buffer = File.GetData();

            this.Header = buffer.ToStructure<HeaderData>(0);
            if (Header.Magic1 != 0x31424753 || Header.Magic2 != 0x314E4353)     // LGB1 & SCN1
                throw new System.IO.InvalidDataException();

            var data = new List<ISgbData>();

            data.Add(new SgbGroup(this, buffer, BaseOffset + Header.SharedOffset));
            data.Add(new SgbGroup(this, buffer, BaseOffset + Header.Offset1C));

            this.Data = data.ToArray();
        }
Exemplo n.º 11
0
    public bool Serialize(HeaderData data)
    {
        // 기존 데이터를 클리어한다.
        Clear();

        // 각 요소를 차례로 시리얼라이즈한다.
        bool ret = true;

        ret &= Serialize(data.length);
        ret &= Serialize(data.Id);

        if (ret == false)
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 12
0
        public void GetSet_HeaderInternal_Default_Value(Data data, HeaderData headerData, string value)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var test    = new Message(data);

            var messageContextDataFactory = fixture.Create <IMessageContextDataFactory>();

            messageContextDataFactory.Create(value, headerData).Returns(new MessageContextData <HeaderData>(value, headerData));

            var property    = messageContextDataFactory.Create(value, headerData);
            var headerData2 = test.GetInternalHeader(property);

            Assert.Equal(headerData2, headerData);

            var headerData3 = test.GetInternalHeader(property);

            Assert.Equal(headerData2, headerData3);
        }
Exemplo n.º 13
0
        public Header()
        {
            InitializeComponent();
            /*** provisional hasta implementar la lectura de la maquina desde VIEW MODEL ***/
            HeaderData modelHeader = new HeaderData();

            this.txtBPM.Content       = modelHeader.BPM;
            this.txtMold.Content      = modelHeader.Mold;
            this.txtNombre.Content    = modelHeader.FullName;
            this.txtVReal.Content     = modelHeader.VReal;
            this.txtVTeorico.Content  = modelHeader.VTeorico;
            this.txtVSeccion.Content  = modelHeader.VSeccion;
            this.txtCicloReal.Content = modelHeader.VCicloReal;
            this.txtCicloTeo.Content  = modelHeader.CicloTeo;
            this.txtSecOper.Content   = modelHeader.SecOper;
            this.txtTime.Content      = modelHeader.Time;
            this.txtDate.Content      = modelHeader.Date;
        }
Exemplo n.º 14
0
        private static bool GetHeaderData(string fileName, ref HeaderData headerData)
        {
            bool result = true;

            headerData.ArchiveName = archiveFile;
            headerData.FileName    = fileName;
            try {
                FileInfo fi = new FileInfo(Path.Combine(Path.GetDirectoryName(archiveFile), fileName));
                headerData.UnpackedSize   = (ulong)fi.Length;
                headerData.PackedSize     = (ulong)fi.Length;
                headerData.FileTime       = fi.LastWriteTime;
                headerData.FileAttributes = fi.Attributes;
            } catch {
                headerData.UnpackedSize = unchecked (0xFFFFFFFFFFFFFFFF);
                headerData.FileTime     = DateTime.MinValue;
                result = false;
            }
            return(result);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Create an instance of this project
 /// </summary>
 /// <param name="Image">Image to build from</param>
 /// <param name="OutFolder">Save location</param>
 /// <param name="HeaderInfo">Header info</param>
 public CreateSVOD(GDFImage Image, string OutFolder, HeaderData HeaderInfo)
 {
     if (!Image.Valid)
     {
         return;
     }
     BaseImage   = Image;
     OutLocation = OutFolder;
     xHeader     = HeaderInfo;
     if (Image.Deviation == 0 && Image.baseoffset != 0)
     {
         Deviation = (uint)((Image.baseoffset / 0x1000) + 1);
     }
     else
     {
         Deviation = Image.Deviation;
     }
     xActive = false;
 }
Exemplo n.º 16
0
        /// <summary>
        /// DeSerialize this Collection's Meta Info
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="reader"></param>
        public virtual void Unpack(IInternalPersistent parent, System.IO.BinaryReader reader)
        {
            long da = reader.ReadInt64();

            if (da >= 0)
            {
                DataAddress = da;
            }
            DataBlockSize  = (DataBlockSize)reader.ReadInt32();
            Name           = reader.ReadString();
            HintSizeOnDisk = reader.ReadInt32();
            long l = reader.ReadInt64();

            if (l >= 0)
            {
                DataBlockDriver.SetId(this.DiskBuffer, l);
            }
            bool hasHeader = reader.ReadBoolean();

            if (hasHeader)
            {
                if (HeaderData == null)
                {
                    HeaderData = new HeaderData();
                }
                HeaderData.Unpack(parent, reader);
            }

            MruMinCapacity = ((CollectionOnDisk)parent).File.Profile.MruMinCapacity;
            MruMaxCapacity = ((CollectionOnDisk)parent).File.Profile.MruMaxCapacity;

            bool hasDeletedBlocks = reader.ReadBoolean();

            if (hasDeletedBlocks)
            {
                _deletedBlocksAddress = reader.ReadInt64();
            }
            else if (deletedBlocks != null)
            {
                deletedBlocks = null;
            }
        }
Exemplo n.º 17
0
    public void DataHandle()
    {
        while (true)
        {
            if (receiveMsgs.Count > 0)
            {
                DataPacket packet = new DataPacket();

                //패킷을 Dequeue 한다 패킷 : 메시지 타입 + 메시지 내용, 소켓
                lock (receiveLock)
                {
                    try
                    {
                        packet = receiveMsgs.Dequeue();
                    }
                    catch
                    {
                        Console.WriteLine("DataHandler::DataHandle.Dequeue 에러");
                    }
                }

                HeaderData       headerData       = new HeaderData();
                HeaderSerializer headerSerializer = new HeaderSerializer();
                headerSerializer.SetDeserializedData(packet.msg);
                headerSerializer.Deserialize(ref headerData);

                ResizeByteArray(0, UnityServer.packetSource + UnityServer.packetId, ref packet.msg);

                //Dictionary에 등록된 델리게이트 메소드에서 PacketId를 반환받는다.
                if (m_notifier.TryGetValue(headerData.id, out recvNotifier))
                {
                    recvNotifier(packet);
                }
                else
                {
                    Console.WriteLine("DataHandler::DataHandle.TryGetValue 에러 ");
                    Console.WriteLine("패킷 출처 : " + headerData.source);
                    Console.WriteLine("패킷 ID : " + headerData.id);
                }
            }
        }
    }
Exemplo n.º 18
0
        public async Task <ActionResult> RegisterSafetyFirstCheck([FromBody] HeaderData headerData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var res = await _reportActivities.CreateReport(headerData.ReportHeader, headerData.SafetyFirstCheck);

                return(Ok(res));
            }
            catch (Exception ex)
            {
                _logger.LogError($"{nameof(RegisterSafetyFirstCheck)} - Error", ex);
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  new { data = "Error occurred, Please contact admin" }));
            }
        }
Exemplo n.º 19
0
        public List <HeaderData> GenerateHeaderList(IStickyGridHeadersSimpleAdapter adapter)
        {
            Dictionary <long, HeaderData> mapping = new Dictionary <long, HeaderData>();
            List <HeaderData>             headers = new List <HeaderData>();

            for (int i = 0; i < adapter.Count; i++)
            {
                long       headerId = adapter.GetHeaderId(i);
                HeaderData headerData;
                if (!mapping.TryGetValue(headerId, out headerData))
                {
                    headerData = new HeaderData(this, i);
                    headers.Add(headerData);
                }
                headerData.IncrementCount();
                mapping[headerId] = headerData;
            }

            return(headers);
        }
Exemplo n.º 20
0
    public void GameExit()
    {
        //No Packet
        Debug.Log("게임종료");
        HeaderData       headerData       = new HeaderData();
        HeaderSerializer HeaderSerializer = new HeaderSerializer();

        headerData.Id = (int)ClientPacketId.GameClose;
        HeaderSerializer.Serialize(headerData);
        byte[] msg = HeaderSerializer.GetSerializedData();

        try
        {
            clientSock.Send(msg);
        }
        catch
        {
            Debug.Log("서버와의 연결이 끊겼습니다.");
        }
    }
Exemplo n.º 21
0
        public async Task <IActionResult> Get()
        {
            long currentTimestamp    = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();
            long minOneHourTimestamp = ((DateTimeOffset)DateTime.UtcNow.AddHours(-24)).ToUnixTimeSeconds();

            var headerData = new HeaderData();

            var orderByBlock = Builders <Caladan.Models.Block> .Sort.Descending("block_number");

            var getLastBlock = _blockRepository.GetAsync(null, orderByBlock);

            var builder         = Builders <Caladan.Models.Block> .Filter;
            var filter          = builder.Where(x => x.Timestamp > (ulong)minOneHourTimestamp);
            var orderByBlockAsc = Builders <Caladan.Models.Block> .Sort.Ascending("timestamp");

            var getOldBlock = _blockRepository.GetAsync(filter, orderByBlockAsc);

            var priceBuilder = Builders <Caladan.Models.Price> .Filter;
            var priceFilter  = priceBuilder.Where(x => x.Symbol == _configuration["AppSettings:MainCurrencySymbol"]);
            var orderByPrice = Builders <Caladan.Models.Price> .Sort.Descending("last_updated");

            var getLastPrice = _priceRepository.GetAsync(priceFilter, orderByPrice);

            await Task.WhenAll(getLastBlock, getLastPrice, getOldBlock);

            long averageBlockTime = 0;

            if (getOldBlock.Result != null)
            {
                averageBlockTime = (currentTimestamp - (long)getOldBlock.Result.Timestamp) / ((long)getLastBlock.Result.BlockNumber - (long)getOldBlock.Result.BlockNumber);
            }

            return(Ok(new HeaderData()
            {
                Found = true,
                LatestBlockNumber = getLastBlock.Result != null ? getLastBlock.Result.BlockNumber : 0,
                MarketCap = getLastPrice.Result != null ? getLastPrice.Result.MarketCapUsd : 0,
                Price = getLastPrice.Result != null ? getLastPrice.Result.PriceUsd : 0,
                AverageBlockTime = averageBlockTime
            }));
        }
Exemplo n.º 22
0
    //Udp 데이터 수신
    public void UdpReceiveDataCallback(IAsyncResult asyncResult)
    {
        AsyncData asyncData = (AsyncData)asyncResult.AsyncState;

        udpSock = asyncData.sock;

        try
        {
            Debug.Log("메시지 받음");
            asyncData.msgSize = (short)udpSock.EndReceive(asyncResult);
            Debug.Log(asyncData.EP);
        }
        catch (Exception e)
        {
            Debug.Log("연결 끊김 :" + e.Message);
            udpSock.Close();
        }

        if (asyncData.msgSize > 0)
        {
            byte[] msgSize = ResizeByteArray(0, NetworkManager.packetLength, ref asyncData.msg);
            Array.Resize(ref asyncData.msg, BitConverter.ToInt16(msgSize, 0) + NetworkManager.packetSource + NetworkManager.packetId);

            HeaderData       headerData       = new HeaderData();
            HeaderSerializer headerSerializer = new HeaderSerializer();
            headerSerializer.SetDeserializedData(asyncData.msg);
            headerSerializer.Deserialize(ref headerData);

            DataPacket packet = new DataPacket(headerData, asyncData.msg, asyncData.EP);

            lock (receiveLock)
            {   //큐에 삽입
                Debug.Log("Enqueue Message Length : " + asyncData.msg.Length);
                msgs.Enqueue(packet);
            }

            //다시 수신 준비
            asyncData = new AsyncData(udpSock, asyncData.EP);
            udpSock.BeginReceiveFrom(asyncData.msg, 0, AsyncData.msgMaxSize, SocketFlags.None, ref asyncData.EP, new AsyncCallback(UdpReceiveDataCallback), asyncData);
        }
    }
Exemplo n.º 23
0
    public bool Deserialize(ref HeaderData serialized)
    {
        // 디시리얼라이즈하는 데이터를 설정한다.
        bool ret = (GetDataSize() > 0) ? true : false;

        if (ret == false)
        {
            return(false);
        }

        // 데이터의 요소별로 디시리얼라이즈한다.
        short packetLength = 0;
        byte  packetId     = 0;

        ret &= Deserialize(ref packetLength);
        ret &= Deserialize(ref packetId);
        serialized.length = packetLength;
        serialized.Id     = packetId;

        return(ret);
    }
Exemplo n.º 24
0
    public bool Deserialize(ref HeaderData element)
    {
        // 디시리얼라이즈하는 데이터를 설정한다.
        bool ret = (GetDataSize() > 0) ? true : false;

        if (ret == false)
        {
            return(false);
        }

        // 데이터의 요소별로 디시리얼라이즈한다.
        byte source = 0;
        byte id     = 0;

        ret           &= Deserialize(ref source);
        ret           &= Deserialize(ref id);
        element.source = source;
        element.id     = id;

        return(ret);
    }
    public bool Deserialize(ref HeaderData serialized)
    {
        // 디시리얼라이즈하는 데이터를 설정한다.
        bool ret = (GetDataSize() > 0) ? true : false;

        if (ret == false)
        {
            return(false);
        }

        // 데이터의 요소별로 디시리얼라이즈한다.
        byte source   = 0;
        byte packetId = 0;

        ret &= Deserialize(ref source);
        ret &= Deserialize(ref packetId);
        serialized.source = source;
        serialized.id     = packetId;

        return(ret);
    }
Exemplo n.º 26
0
        private static T[] GetRangeData <T>(BinaryReader reader, HeaderData header)
        {
            var result     = new T[header.records];
            int sizeArray  = Marshal.SizeOf(typeof(T)) * header.records;
            var readBuffer = new byte[sizeArray];

            readBuffer = reader.ReadBytes(sizeArray);
            GCHandle handle     = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
            var      structSize = Marshal.SizeOf(typeof(T));
            var      pointer    = handle.AddrOfPinnedObject();

            // TODO: для увеличения скорости загрузки, также можно избавиться от цикла
            for (int i = 0; i < header.records; i++)
            {
                result[i] = (T)Marshal.PtrToStructure(pointer, typeof(T));
                pointer  += structSize;
            }
            handle.Free();

            return(result);
        }
Exemplo n.º 27
0
        public List <DataEntry> LoadCache(string path, string directory)
        {
            clearVFS();
            var    header      = new HeaderData();
            string tempFileExt = Path.GetExtension(path);
            var    cachePath   = Path.ChangeExtension(path, ".shdcache");

            //using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open)))
            //{

            //Load .shdcache file
            try
            {
                using (FileStream reader = new FileStream(directory + "\\" + Path.GetFileName(cachePath), FileMode.Open))
                {
                    BinaryFormatter bf = new BinaryFormatter();

                    var serializeStuff = new DataCollectorClass
                    {
                        header = DataCollector.header,
                        Files  = DataCollector.Files
                    };

                    object o = bf.Deserialize(reader);
                    var    deserializeStuff = (DataCollectorClass)o;
                    DataCollector.header = deserializeStuff.header;
                    DataCollector.Files  = deserializeStuff.Files;
                    System.Diagnostics.Debug.WriteLine("Previous instance loaded...");
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Something broke...");
            }

            //}

            UpdateGUI();
            return(DataCollector.Files);
        }
Exemplo n.º 28
0
        public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(float treeViewWidth)
        {
            var columnList = new List <MultiColumnHeaderState.Column>();

            HeaderData[] headerData = new HeaderData[]
            {
                new HeaderData("Group", "Thread Group", 200, 100, true, false),
                new HeaderData("Thread", "Thread Name", 350, 100, true, false),
                new HeaderData("Show", "Check to show this thread in the analysis views", 40, 100, false, false),
            };
            foreach (var header in headerData)
            {
                columnList.Add(new MultiColumnHeaderState.Column
                {
                    headerContent         = header.content,
                    headerTextAlignment   = TextAlignment.Left,
                    sortedAscending       = true,
                    sortingArrowAlignment = TextAlignment.Left,
                    width                 = header.width,
                    minWidth              = header.minWidth,
                    autoResize            = header.autoResize,
                    allowToggleVisibility = header.allowToggleVisibility
                });
            }
            ;
            var columns = columnList.ToArray();

            Assert.AreEqual(columns.Length, Enum.GetValues(typeof(MyColumns)).Length, "Number of columns should match number of enum values: You probably forgot to update one of them.");

            var state = new MultiColumnHeaderState(columns);

            state.visibleColumns = new int[]
            {
                (int)MyColumns.GroupName,
                (int)MyColumns.ThreadName,
                (int)MyColumns.State,
            };
            return(state);
        }
Exemplo n.º 29
0
        public override PackerResult ReadHeader(ref object arcData, out HeaderData headerData)
        {
            headerData = null;
            ZipFile     zf      = (ZipFile)arcData;
            IEnumerator arcEnum = (IEnumerator)zf;

            if (arcEnum.MoveNext())
            {
                object current = arcEnum.Current;
                if (current is ZipEntry)
                {
                    headerData = new HeaderData();
                    GetHeaderData((ZipEntry)current, ref headerData);
                }
                else if (current != null)
                {
                    throw new InvalidOperationException("Unknown type in FindNext: " + current.GetType().FullName);
                }
            }

            return(PackerResult.NotSupported);
        }
Exemplo n.º 30
0
    public void DataHandle()
    {
        while (true)
        {
            if (receiveMsgs.Count != 0)
            {
                //패킷을 Dequeue 한다 패킷 : 메시지 타입 + 메시지 내용
                lock (receiveLock)
                {
                    tcpPacket = receiveMsgs.Dequeue();
                }

                //타입과 내용을 분리한다
                byte Id = tcpPacket.msg[0];
                msg = new byte[tcpPacket.msg.Length - 1];
                Array.Copy(tcpPacket.msg, 1, msg, 0, msg.Length);

                HeaderData headerData = new HeaderData();

                //Dictionary에 등록된 델리게이트형 메소드에서 msg를 반환받는다.
                if (m_notifier.TryGetValue(Id, out recvNotifier))
                {
                    ServerPacketId packetId = recvNotifier(msg);
                    //send 할 id를 반환받음
                    if (packetId != ServerPacketId.None)
                    {
                        tcpPacket = new TcpPacket(msg, tcpPacket.client);
                        sendMsgs.Enqueue(tcpPacket);
                    }
                }
                else
                {
                    Console.WriteLine("DataHandler::TryGetValue 에러 " + Id);
                    headerData.Id = (byte)ServerPacketId.None;
                }
            }
        }
    }
 public SMesh(Transform parent, string meshName, int meshInstanceID, bool isEnabled)
 {
     header = new HeaderData();
     header.activeInHierarchy = isEnabled;
     header.meshName = meshName;
     header.meshInstanceID = meshInstanceID;
     header.parentName = parent.name;
     header.goInstanceID = parent.gameObject.GetInstanceID();
     header.matrix = new SMatrix4x4(parent.localToWorldMatrix);
 }
Exemplo n.º 32
0
        public void MotHeadReader(string file)
        {
            s = File.OpenReader(file + ".bin");
            s.RI32();
            Header = new HeaderData();

            int offset = s.RI32();

            if (offset < 0x10)
            {
                goto RETURN;
            }
            s.O = offset;
            s.P = 0;

            Header.MotionSetID     = s.RI32();
            Header.StartMotionID   = s.RI32();
            Header.EndMotionID     = s.RI32();
            Header.SubHeaderOffset = s.RI32();

            if (Header.SubHeaderOffset < 0x10)
            {
                goto RETURN;
            }
            i0 = Header.EndMotionID - Header.StartMotionID;
            if (i0 < 0)
            {
                goto RETURN;
            }

            s.P         = Header.SubHeaderOffset;
            Header.Data = new HeaderData.Sub[++i0];
            for (i = 0; i < Header.Data.Length; i++)
            {
                Header.Data[i].Offset = s.RI32();
            }
            for (i = 0; i < Header.Data.Length; i++)
            {
                if (Header.Data[i].Offset < 0x10)
                {
                    continue;
                }

                s.P = Header.Data[i].Offset;

                Header.Data[i].MotionID = Header.StartMotionID + i;
                Header.Data[i].SomeData = s.RI32();
                s.RI64();
                s.RI64();
                Header.Data[i].Offset2          = s.RI32();
                Header.Data[i].DataHeaderOffset = s.RI32();

                if (Header.Data[i].DataHeaderOffset < 0x10)
                {
                    goto RETURN;
                }
                s.P = Header.Data[i].DataHeaderOffset;
                i0  = 0;
                while (s.RI32() != -1)
                {
                    s.RI32(); s.RI32(); i0++;
                }
                s.P = Header.Data[i].DataHeaderOffset;

                Header.Data[i].Array = new HeaderData.Sub.Data[i0];
                for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
                {
                    Header.Data[i].Array[i0].Type   = s.RI32();
                    Header.Data[i].Array[i0].Frame  = s.RI32();
                    Header.Data[i].Array[i0].Offset = s.RI32();
                }
            }

            for (i = 0; i < Header.Data.Length; i++)
            {
                if (Header.Data[i].Offset2 > 0x10)
                {
                    s.P = Header.Data[i].Offset2;
                    i0  = 0;
                    while (s.RI32() != -1)
                    {
                        s.RI32(); i0++;
                    }
                    s.P = Header.Data[i].Offset2;

                    Header.Data[i].Array2 = new HeaderData.Sub.Data2[i0];
                    for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
                    {
                        Header.Data[i].Array2[i0].Frame  = s.RI32();
                        Header.Data[i].Array2[i0].Offset = s.RI32();
                    }

                    for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
                    {
                        if (Header.Data[i].Array2[i0].Offset < 0x10)
                        {
                            goto RETURN;
                        }
                        s.P = Header.Data[i].Array2[i0].Offset;
                        Header.Data[i].Array2[i0].Array = new int[7];
                        for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length; i1++)
                        {
                            Header.Data[i].Array2[i0].Array[i1] = s.RI32();
                        }
                    }
                }

                if (Header.Data[i].Array == null || Header.Data[i].Array.Length < 1)
                {
                    continue;
                }

                for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
                {
                    ref HeaderData.Sub.Data Data = ref Header.Data[i].Array[i0];
                    if ((i1 = GetSize(Data.Type)) < 1)
                    {
                        continue;
                    }


                    if (Data.Offset > 0)
                    {
                        s.P = Data.Offset;
                        if (i1 == 0x01)
                        {
                            Data.Array = new int[] { s.RU8() }
                        }
                        ;
                        else if (i1 == 0x02)
                        {
                            Data.Array = new int[] { s.RU16() }
                        }
                        ;
                        else
                        {
                            Data.Array = new int[i1 / 4];
                            for (i1 = 0; i1 < Data.Array.Length; i1++)
                            {
                                Data.Array[i1] = s.RI32();
                            }
                        }
                    }
                }
            }
Exemplo n.º 33
0
        public void GetSet_InternalHeader(Data data, Dictionary <string, object> headers, HeaderData headerData)
        {
            var factory = Create();
            var test    = factory.Create(data, headers);

            var messageContextDataFactory = CreateDataFactory();

            var property = messageContextDataFactory.Create("Test", headerData);

            test.SetInternalHeader(property, headerData);

            var headerData2 = test.GetInternalHeader(property);

            Assert.Equal(headerData2, headerData);
        }
        /// <summary>
        /// 実行
        /// </summary>
        public void run()
        {
            var header = new HeaderData() {
                Status = HeaderStatus.Ste
            };
            UInt32 status = 891;

            var sendData = sendMessage(header, status);
            byte data1 = 0x1;
            var a = new byte[3] { data1, 0x22, 0x33 };
            var b = new byte[3] { 0x11, 0x22, 0x33 };
            if(a.IsSame(b)) {
            }

            if (a.IsSame(0x112233))
            {
            }
        }
Exemplo n.º 35
0
 private static string Save_Header(string saveContent)
 {
     //Returns a string to be used in savefiles
     return(HeaderData.Save(saveContent));
 }
Exemplo n.º 36
0
 public static string GET(string url, HeaderData[] headers)
 {
     return SendData("GET", url, null, null, headers);
 }
Exemplo n.º 37
0
 public static string GET(string url, HeaderData[] headers, string userAgent)
 {
     return SendData("GET", url, null, null, headers, userAgent);
 }
Exemplo n.º 38
0
 public static string GET(string url, HeaderData[] headers, string userAgent, NetworkCredential credential)
 {
     return SendData("GET", url, null, null, headers, userAgent, credential);
 }
Exemplo n.º 39
0
 public static string PUT(string url, PostContentData[] postContentData, HeaderData[] headers, string userAgent)
 {
     return SendData("PUT", url, postContentData, null, headers, userAgent);
 }
Exemplo n.º 40
0
        private static ResponseInfo SendData(
            bool returnBytes,
            string method,
            string url,
            PostContentData[] postDatas = null,
            FileContentData[] fileDatas = null,
            HeaderData[] headers = null,
            string userAgent = null,
            NetworkCredential credential = null,
            ProxySettings proxySettings = null,
            int timeout = TIMEOUT,
            int maxAttempts = CONNECTION_ATTEMPTS,
            bool getResponse = true
            )
        {
            ResponseInfo result = null;

            int attempts = 0;
            bool success = false;
            string message = null;

            // Try to send data for number of connectionAttempts
            while (attempts < maxAttempts && !success)
            {
                attempts += 1;

                try
                {
                    // Create HTTP request and define Header info
                    var request = (HttpWebRequest)WebRequest.Create(url);

                    string boundary = String_Functions.RandomString(10);

                    request.Timeout = timeout;
                    request.ReadWriteTimeout = timeout;
                    if (method == "POST") request.ContentType = "multipart/form-data; boundary=" + boundary;
                    else request.ContentType = "application/x-www-form-urlencoded";

                    // Set the Method
                    request.Method = method;

                    // Set the UserAgent
                    if (userAgent != null) request.UserAgent = userAgent;
                    else request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

                    // Add Header data to request stream (if present)
                    if (headers != null)
                    {
                        foreach (var header in headers)
                        {
                            request.Headers[header.Id] = header.Text;
                        }
                    }

                    // set NetworkCredentials
                    if (credential != null)
                    {
                        request.Credentials = credential;
                        request.PreAuthenticate = true;
                    }

                    // Get Default System Proxy (Windows Internet Settings -> Proxy Settings)
                    var proxy = WebRequest.GetSystemWebProxy();

                    // Get Custom Proxy Settings from Argument (overwrite default proxy settings)
                    if (proxySettings != null)
                    {
                        if (proxySettings.Address != null && proxySettings.Port > 0)
                        {
                            var customProxy = new WebProxy(proxySettings.Address, proxySettings.Port);
                            customProxy.BypassProxyOnLocal = false;
                            proxy = customProxy;
                        }
                    }

                    request.Proxy = proxy;

                    var bytes = new List<byte>();

                    // Add Post Name/Value Pairs
                    if (postDatas != null)
                    {
                        string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";

                        foreach (var postData in postDatas)
                        {
                            string formitem = string.Format(formdataTemplate, postData.Name, postData.Value);

                            bytes.AddRange(GetBytes("\r\n--" + boundary + "\r\n"));
                            bytes.AddRange(GetBytes(formitem));
                        }
                    }

                    // Add File data
                    if (fileDatas != null)
                    {
                        bytes.AddRange(GetFileContents(fileDatas, boundary));
                    }

                    if (bytes.Count > 0)
                    {
                        // Write Trailer Boundary
                        string trailer = "\r\n--" + boundary + "--\r\n";
                        bytes.AddRange(GetBytes(trailer));

                        var byteArray = bytes.ToArray();

                        // Write Data to Request Stream
                        request.ContentLength = byteArray.Length;

                        using (var requestStream = request.GetRequestStream())
                        {
                            requestStream.Write(byteArray, 0, byteArray.Length);
                        }
                    }

                    // Get Response Message from HTTP Request
                    if (getResponse)
                    {
                        result = new ResponseInfo();

                        using (var response = (HttpWebResponse)request.GetResponse())
                        {
                            // Get HTTP Response Body
                            using (var responseStream = response.GetResponseStream())
                            using (var memStream = new MemoryStream())
                            {
                                byte[] buffer = new byte[10240];

                                int read;
                                while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0)
                                {
                                    memStream.Write(buffer, 0, read);
                                }

                                result.Body = memStream.ToArray();

                                success = true;
                            }

                            var responseHeaders = new List<ReponseHeaderInfo>();

                            // Get HTTP Response Headers
                            foreach (var key in response.Headers.AllKeys)
                            {
                                var header = new ReponseHeaderInfo();
                                header.Key = key;
                                header.Value = response.Headers.Get(key);

                                responseHeaders.Add(header);
                            }

                            result.Headers = responseHeaders.ToArray();
                        }
                    }
                    else success = true;
                }
                catch (WebException wex) { message = wex.Message; }
                catch (Exception ex) { message = ex.Message; }

                if (!success) System.Threading.Thread.Sleep(500);
            }

            if (!success) Logger.Log("Send :: " + attempts.ToString() + " Attempts :: URL = " + url + " :: " + message);

            return result;
        }
Exemplo n.º 41
0
 public FileData()
 {
     headerData = new HeaderData();
 }
Exemplo n.º 42
0
 private static string SendData(
    string method,
    string url,
    PostContentData[] postDatas = null,
    FileContentData[] fileDatas = null,
    HeaderData[] headers = null,
    string userAgent = null,
    NetworkCredential credential = null,
    ProxySettings proxySettings = null,
    int timeout = TIMEOUT,
    int maxAttempts = CONNECTION_ATTEMPTS,
    bool getResponse = true)
 {
     var response = SendData(false, method, url, postDatas, fileDatas, headers, userAgent, credential, proxySettings, timeout, maxAttempts, getResponse);
     if (response != null && response.Body != null) return Encoding.ASCII.GetString(response.Body);
     else return null;
 }
Exemplo n.º 43
0
        private static HeaderData Load_Header(string header)
        {
            HeaderData headerData = HeaderData.Load(header);

            return(headerData);
        }
Exemplo n.º 44
0
        public void AddHeader(HeaderData header)
        {

        }
        /// <summary>
        /// メッセージ送信
        /// </summary>
        /// <param name="header"></param>
        /// <param name="status"></param>
        public byte[][] sendMessage(HeaderData header, UInt32 status)
        {
            //送信データ作成
            var sendData = new HundMadePacket[10000];
            var ret = new List<byte[]>();
            var sendBytes = new byte[sendData.Sum(x => x.Packet.Length)];

            var i = 0;
            sendData.TakeWhile(x =>
            {
                var j = 0;
                x.Packet.TakeWhile(y =>
                {
                    sendBytes[i * 8 + j] = y;
                    j++;
                    return true;
                });
                i++;
                return true;
            });
            //1024byte刻みでデータ送信
            foreach (var data in sendBytes.Cut1024Bytes())
            {
                //ヘッダ作成
                var h = new byte[3] { 0x11, 0x00, 0x00 };
                //ヘッダーをいただく
                h[1] = header.HeaderByte;
                //ステータス値(uint)の後ろ1Byte分をいただく
                h[2] = status.ConvertBytes().Last();
                //送信
                var send = h.Concat(data).ToArray();
                ret.Add(send);
            }
            return ret.ToArray();
        }
            public static HeaderData Deserialize(byte[] input)
            {
                if (input == null || input.Length < 32)
                    return null;

                HeaderData result = new HeaderData();
                ComposedByteStream stream = ComposedByteStream.FromByteArray(input);

                result.parentName = stream.ReadNextStream();
                result.meshName = stream.ReadNextStream();
                ComposedPrimitives prims = ComposedPrimitives.FromByteArray(stream.ReadNextStream<byte>());
                result.matrix = new SMatrix4x4(stream.ReadNextStream<float>());

                result.activeInHierarchy = prims.ReadNextValue<bool>();
                result.meshInstanceID = prims.ReadNextValue<int>();
                result.goInstanceID = prims.ReadNextValue<int>();
                result.type = prims.ReadNextValue<Type>();

                prims.Dispose();
                return result;
            }
Exemplo n.º 47
0
 public static string POST(string url, PostContentData[] postContentData, HeaderData[] headers)
 {
     return SendData("POST", url, postContentData, null, headers);
 }
Exemplo n.º 48
0
        public void GetSet_HeaderInternal_Default_Value(Data data, HeaderData headerData, string value)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var test = new Message(data);

            var messageContextDataFactory = fixture.Create<IMessageContextDataFactory>();

            messageContextDataFactory.Create(value, headerData).Returns(new MessageContextData<HeaderData>(value, headerData));

            var property = messageContextDataFactory.Create(value, headerData);
            var headerData2 = test.GetInternalHeader(property);
            Assert.Equal(headerData2, headerData);

            var headerData3 = test.GetInternalHeader(property);
            Assert.Equal(headerData2, headerData3);
        }
Exemplo n.º 49
0
 public static string PUT(string url, PostContentData[] postContentData, HeaderData[] headers, string userAgent, NetworkCredential credential)
 {
     return SendData("PUT", url, postContentData, null, headers, userAgent, credential);
 }
        public override void Dispose()
        {
            base.Dispose();

            if (header != null) header.Dispose();
            if (subMeshes != null) subMeshes.Dispose();
            if (vertices != null) vertices.Dispose();
            if (uv != null) uv.Dispose();
            if (uv1 != null) uv1.Dispose();
            if (uv2 != null) uv2.Dispose();
            if (uv3 != null) uv3.Dispose();
            if (uv4 != null) uv4.Dispose();
            if (bindPoses != null) bindPoses.Dispose();
            if (bones != null) bones.Dispose();
            if (boneWeights != null) boneWeights.Dispose();

            header = null;
            subMeshes = null;
            triangles = null;
            vertices = null;
            uv = null;
            uv1 = null;
            uv2 = null;
            uv3 = null;
            uv4 = null;
            bindPoses = null;
            bones = null;
            boneWeights = null;
        }
Exemplo n.º 51
0
 public void BuildHeader(HeaderData header) { _page.AddHeader(header); }
            //--------------- Serialize / Deserialize --------------------
            internal static byte[] Serialize(HeaderData input)
            {
                if (input == null)
                    return null;

                ComposedPrimitives prims = new ComposedPrimitives();
                prims.AddValue(input.activeInHierarchy);
                prims.AddValue(input.meshInstanceID);
                prims.AddValue(input.goInstanceID);
                prims.AddValue(input.type);

                ComposedByteStream stream = ComposedByteStream.FetchStream(4);
                stream.AddStream(input.parentName);
                stream.AddStream(input.meshName);
                stream.AddStream(prims.Compose());
                stream.AddStream(input.matrix.GetRawData());
                return stream.Compose();
            }