本文整理汇总了C#中ByteArray类的典型用法代码示例。如果您正苦于以下问题:C# ByteArray类的具体用法?C# ByteArray怎么用?C# ByteArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArray类属于命名空间,在下文中一共展示了ByteArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public void Read(ByteArray bs)
{
signature = bs.ReadStringNull();
streamVersion = bs.ReadInt();
unityVersion = bs.ReadStringNull();
unityRevision = bs.ReadStringNull();
minimumStreamedBytes = bs.ReadInt();
headerSize = bs.ReadUInt();
numberOfLevelsToDownload = bs.ReadInt();
int numberOfLevels = bs.ReadInt();
for (int i = 0; i < numberOfLevels; i++)
{
levelByteEnd.Add(new LevelInfo() { PackSize = bs.ReadUInt(), UncompressedSize = bs.ReadUInt() });
}
if (streamVersion >= 2)
{
completeFileSize = bs.ReadUInt();
}
if (streamVersion >= 3)
{
dataHeaderSize = bs.ReadUInt();
}
bs.ReadByte();
}
示例2: SendMessageAsync
public override Task SendMessageAsync(ByteArray message, CancellationToken token)
{
if (token.IsCancellationRequested)
return Task.FromResult<object>(null);
return udp.SendAsync(message, message.Length);
}
示例3: upload
public void upload(ByteArray vertexProgram, ByteArray fragmentProgram) {
// convert shaders from AGAL to GLSL
var glslVertex = AGALConverter.ConvertToGLSL(vertexProgram);
var glslFragment = AGALConverter.ConvertToGLSL(fragmentProgram);
// upload as GLSL
uploadFromGLSL(glslVertex, glslFragment);
}
示例4: ToByteArray
public static byte[] ToByteArray(Int16[] value)
{
ByteArray arr = new ByteArray();
foreach (Int16 val in value)
arr.Add(ToByteArray(val));
return arr.array;
}
示例5: Write
/// <summary>
/// 将消息体编码
/// </summary>
/// <param name="type"></param>
/// <param name="area"></param>
/// <param name="command"></param>
/// <param name="message"></param>
public void Write(byte type, int area, int command, object message)
{
ByteArray ba = new ByteArray();
ba.Write(type);
ba.Write(area);
ba.Write(command);
if (message != null)
{
ba.Write(SerializeUtil.Encode(message));
}
//进行黏包处理
ByteArray arrl = new ByteArray();
arrl.Write(ba.Length);
arrl.Write(ba.GetBuff());
try
{
socket.Send(arrl.GetBuff());
}
catch(Exception e)
{
Debug.Log("网络错误,请重新登录" + e.Message);
}
}
示例6: GenerateByteArray
public System.Collections.Generic.List<object> GenerateByteArray(byte[] bytes)
{
ByteArray data = new ByteArray(bytes);
System.Collections.Generic.List<object> list = new System.Collections.Generic.List<object>();
int length = data.ReadInt();
for (int i = 0; (i < length); i = (i + 1))
{
BuildingTemplateVO vo = new BuildingTemplateVO();
vo.id = data.ReadInt();
vo.name = data.ReadUTF();
vo.type = data.ReadInt();
vo.buildingIndex = data.ReadInt();
vo.camp = data.ReadInt();
vo.image = data.ReadUTF();
vo.levelMap = data.ReadInt();
vo.affiliation = data.ReadInt();
vo.openNeedThLevel = data.ReadInt();
vo.isInitZore = data.ReadInt();
vo.levelRule = data.ReadInt();
vo.gold = data.ReadInt();
vo.wood = data.ReadInt();
vo.crystal = data.ReadInt();
vo.stone = data.ReadInt();
vo.sulfur = data.ReadInt();
vo.diamond = data.ReadInt();
vo.upgradeCdTime = data.ReadInt();
vo.productActorId = data.ReadInt();
vo.makeCurrencyId = data.ReadInt();
vo.desc = data.ReadUTF();
vo.isOpen = data.ReadInt();
list.Add(vo);
}
return list;
}
示例7: parseXMLFile
public static bool parseXMLFile()
{
ByteArray bytes = ResourcePool.remove(GameConfig.XML_LIB_URL) as ByteArray;
if (bytes != null) {
try {
bytes.Uncompress();
} catch (Exception e) {
}
map = new Dictionary<string,object>();
while (bytes.Length != bytes.Postion) {
string name = bytes.readUTF();
if(name == "fish.xml"){
Debug.Log(name);
}
int size = bytes.readInt();
if (size > bytes.Length)
{
return false;
}
ByteArray xmlData;
byte[] xmlDataList = new byte[size];
bytes.readBytes(xmlDataList, 0, (uint)size);
xmlData = new ByteArray(xmlDataList);
map[name] = xmlData;
}
return true;
}
return false;
}
示例8: GetBytes
public ByteArray GetBytes()
{
if (writeObject == null) throw new Exception("write object is null");
var byteArray = new ByteArray();
byteArray.WriteObject(writeObject);
return byteArray;
}
示例9: ImageSheetModel
public ImageSheetModel(DeckModel deck, Guid id, SheetDisposition disp, Rectangle bounds, ByteArray md5, int height)
: base(id, disp, bounds, false, height)
{
this.m_MD5 = md5;
this.m_Deck = deck;
this.visible_ = true;
}
示例10: ByteArray
public ByteArray(ByteArray src, byte[] data, int pos) {
if(data==null) {
return;
}
if(src==null) {
if(pos<0) {
pos=0;
}
_val=new byte[pos+data.Length];
Buffer.BlockCopy(data, 0, _val, pos, data.Length);
} else {
if(pos<0) { // negative => position from end
pos=src._val.Length+1+pos;
}
if(pos>=src._val.Length) {
_val=new byte[pos+data.Length];
Buffer.BlockCopy(src._val, 0, _val, 0, src._val.Length);
Buffer.BlockCopy(data, 0, _val, pos, data.Length);
} else if(pos==0) {
_val=new byte[src._val.Length+data.Length];
Buffer.BlockCopy(data, 0, _val, 0, data.Length);
Buffer.BlockCopy(src._val, 0, _val, data.Length, src._val.Length);
} else {
_val=new byte[src._val.Length+data.Length];
Buffer.BlockCopy(src._val, 0, _val, 0, pos);
Buffer.BlockCopy(data, 0, _val, pos, data.Length);
Buffer.BlockCopy(src._val, pos, _val, pos+data.Length, src._val.Length-pos);
}
}
}
示例11: GenerateByteArray
public ByteArray GenerateByteArray(object data)
{
List<BuildingTemplateVO> list = data as List<BuildingTemplateVO>;
ByteArray ba = new ByteArray();
int length = list.Count;
ba.WriteInt(length);
for (int i = 0; (i < length); i = (i + 1))
{
ba.WriteInt(list[i].id);
ba.WriteUTF(list[i].name);
ba.WriteInt(list[i].type);
ba.WriteInt(list[i].buildingIndex);
ba.WriteInt(list[i].camp);
ba.WriteUTF(list[i].image);
ba.WriteInt(list[i].levelMap);
ba.WriteInt(list[i].affiliation);
ba.WriteInt(list[i].openNeedThLevel);
ba.WriteInt(list[i].isInitZore);
ba.WriteInt(list[i].levelRule);
ba.WriteInt(list[i].gold);
ba.WriteInt(list[i].wood);
ba.WriteInt(list[i].crystal);
ba.WriteInt(list[i].stone);
ba.WriteInt(list[i].sulfur);
ba.WriteInt(list[i].diamond);
ba.WriteInt(list[i].upgradeCdTime);
ba.WriteInt(list[i].productActorId);
ba.WriteInt(list[i].makeCurrencyId);
ba.WriteUTF(list[i].desc);
ba.WriteInt(list[i].isOpen);
}
return ba;
}
示例12: Read
public void Read(ByteArray inData, AssetHeader assetHeader)
{
if (assetHeader.GetVersion() >= 7)
{
inData.ReadStringNull();
attributes = inData.ReadInt();
}
int numBaseClasses = inData.ReadInt();
Debug.Log("numBaseClasses:" + numBaseClasses);
for (int i = 0; i < numBaseClasses; i++)
{
int classID = inData.ReadInt();
FieldTypeNode node = new FieldTypeNode();
node.Read(inData);
typeMap.Add(classID, node);
}
// padding
if (assetHeader.GetVersion() >= 7)
{
inData.ReadInt();
}
}
示例13: UnPack
public static auto_id UnPack(ByteArray reader)
{
auto_id tbl = new auto_id();
tbl.id = reader.ReadInt32();
return tbl;
}
示例14: TestByteArrayWrite
public static void TestByteArrayWrite()
{
ByteArray ba = new ByteArray();
ba.write(5);
ByteArray ba2 = new ByteArray();
ba2.write(ba.getBuff());
}
示例15: ReadToMemoryStream
public static MemoryStream ReadToMemoryStream(this BinaryReader e, int length)
{
var o = new ByteArray();
e.BaseStream.ToByteArray().readBytes(o, 0, (uint)length);
return o.ToMemoryStream();
}