当前位置: 首页>>代码示例>>C#>>正文


C# Marker.GetBytes方法代码示例

本文整理汇总了C#中Marker.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Marker.GetBytes方法的具体用法?C# Marker.GetBytes怎么用?C# Marker.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Marker的用法示例。


在下文中一共展示了Marker.GetBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Merge


//.........这里部分代码省略.........


                            //Read and write the pathfinding data
                            sourcebuffered.Seek(65536, SeekOrigin.Begin);
                            inputbuffered.Seek(65536, SeekOrigin.Begin);

                            sourcebuffered.Read(source, 0, 65536);
                            inputbuffered.Read(input, 0, 65536);

                            Compare(source, input, 0xfa, 65536);

                            sourcebuffered.Seek(65536, SeekOrigin.Begin);
                            sourcebuffered.Write(source, 0, 65536);


                            //Read and write the marker data
                            sourcebuffered.Seek(131072, SeekOrigin.Begin);
                            byte[] sourcemarkercountbytes = new byte[4];
                            sourcebuffered.Read(sourcemarkercountbytes, 0, 4);
                            int sourcemarkercount = BitConverter.ToInt32(sourcemarkercountbytes, 0);

                            inputbuffered.Seek(131072, SeekOrigin.Begin);
                            byte[] inputmarkercountbytes = new byte[4];
                            inputbuffered.Read(inputmarkercountbytes, 0, 4);
                            int inputmarkercount = BitConverter.ToInt32(inputmarkercountbytes, 0);

                            List<Marker> sourcemarkers = new List<Marker>();

                            for (int r = 0; r < sourcemarkercount; ++r)
                            {
                                byte[] data = new byte[12];
                                sourcebuffered.Read(data, 0, 12);

                                byte[] stringlength = new byte[2];
                                sourcebuffered.Read(stringlength, 0, 2);
                                int len = BitConverter.ToUInt16(stringlength, 0);

                                byte[] str = new byte[len];
                                sourcebuffered.Read(str, 0, len);
                                sourcebuffered.Seek(len, SeekOrigin.Current);

                                Marker marker = new Marker(data, stringlength, str);
                                sourcemarkers.Add(marker);
                            }

                            for (int r = 0; r < inputmarkercount; ++r)
                            {
                                byte[] data = new byte[12];
                                inputbuffered.Read(data, 0, 12);

                                byte[] stringlength = new byte[2];
                                inputbuffered.Read(stringlength, 0, 2);
                                int len = BitConverter.ToUInt16(stringlength, 0);

                                byte[] str = new byte[len];
                                inputbuffered.Read(str, 0, len);
                                inputbuffered.Seek(len, SeekOrigin.Current);

                                Marker marker = new Marker(data, stringlength, str);

                                //Make sure we arn't copying a marker that already exists
                                if (!sourcemarkers.Contains(marker))
                                {
                                    sourcemarkercount++;

                                    byte[] write = marker.GetBytes();
                                    sourcebuffered.SetLength(sourcebuffered.Length + write.Length);
                                    sourcebuffered.Seek(-write.Length, SeekOrigin.End);
                                    sourcebuffered.Write(write, 0, write.Length);
                                }
                            }

                            sourcebuffered.Seek(131072, SeekOrigin.Begin);
                            sourcemarkercountbytes = BitConverter.GetBytes(sourcemarkercount);
                            sourcebuffered.Write(sourcemarkercountbytes, 0, 4);
                        }
                        catch
                        {
                            return false;
                        }
                        finally
                        {
                            if (sourcebuffered != null)
                                sourcebuffered.Close();

                            if (inputbuffered != null)
                                inputbuffered.Close();

                            if (sourcefile != null)
                                sourcefile.Close();

                            if (inputfile != null)
                                inputfile.Close();
                        }
                    }
                }
            }

            return true;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:101,代码来源:MapMerger.cs


注:本文中的Marker.GetBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。