本文整理汇总了C#中Buffer类的典型用法代码示例。如果您正苦于以下问题:C# Buffer类的具体用法?C# Buffer怎么用?C# Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Buffer类属于命名空间,在下文中一共展示了Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InverseTransform
public int InverseTransform(Buffer buffer, int length)
{
Log.Trace("Cipher.InverseTransform: input length {0}", length);
int result;
using (var ms = new MemoryStream(length))
{
var decryptor = algorithm.CreateDecryptor(key, iv);
using (var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Write))
{
var buffers = new List<ArraySegment<byte>>();
buffer.ListStartingSegments(buffers, length);
for (var i = 0; i < buffers.Count; ++i)
{
var segment = buffers[i];
Log.Trace("Cipher.InverseTransform: input block {0}",
BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
cs.Write(segment.Array, segment.Offset, segment.Count);
}
cs.FlushFinalBlock();
result = (int)ms.Length;
}
buffer.Rewind();
buffer.CopyFrom(ms.GetBuffer(), 0, result);
Log.Trace("Cipher.InverseTransform: output {0} {1}",
result, BitConverter.ToString(ms.GetBuffer(), 0, result));
}
return result;
}
开发者ID:nice1378,项目名称:x2clr,代码行数:35,代码来源:Cipher.cs
示例2: ReceiveBuffer
/////////////////////////////////////////////有效時間性Buffer////////////////////////////////////////////////////////
/// <summary>
/// 腳色取得Buffer,傳入Buffer
/// </summary>
public virtual void ReceiveBuffer(Buffer _buffer)
{
if (BufferDic == null)
{
Debug.LogWarning("BufferDic為null");
return;
}
//尚未擁有此BufferID
if (!BufferDic.ContainsKey(_buffer.ID))
{
Go_BufferEntity = Instantiate(Prefab_BufferEntity, Vector2.zero, Quaternion.identity) as GameObject;
Go_BufferEntity.transform.parent = Trans_BufferList;
Com_BufferEntity = Go_BufferEntity.GetComponent<BufferEntity>();
Com_BufferEntity.IniBuffer(_buffer, this);
List<BufferEntity> TmpBufferEntityList = new List<BufferEntity>();
TmpBufferEntityList.Add(Com_BufferEntity);
BufferDic.Add(_buffer.ID, TmpBufferEntityList);//加入BufferDIc字典
}
else//已經擁有此BufferID
{
//如果此狀態是可疊加的
if (_buffer.Stackable)
{
Go_BufferEntity = Instantiate(Prefab_BufferEntity, Vector2.zero, Quaternion.identity) as GameObject;
Go_BufferEntity.transform.parent = Trans_BufferList;
Com_BufferEntity = Go_BufferEntity.GetComponent<BufferEntity>();
Com_BufferEntity.IniBuffer(_buffer, this);
BufferDic[_buffer.ID].Add(Com_BufferEntity);
}
else//如果此狀態不可疊加
{
BufferDic[_buffer.ID][0].IniBuffer(_buffer, this);
}
}
}
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:39,代码来源:Buffer.cs
示例3: request
public void request(Session session, Channel channel)
{
Buffer buf = new Buffer();
Packet packet = new Packet(buf);
bool reply = waitForReply();
if (reply)
{
channel.Replay = -1;
}
packet.reset();
buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
buf.putInt(channel.Recipient);
buf.putString(Util.getBytes("subsystem"));
buf.putByte((byte)(waitForReply() ? 1 : 0));
buf.putString(Util.getBytes("sftp"));
session.write(packet);
if (reply)
{
while (channel.Replay == -1)
{
try { System.Threading.Thread.Sleep(10); }
catch//(Exception ee)
{
}
}
if (channel.Replay == 0)
{
throw new JSchException("failed to send sftp request");
}
}
}
开发者ID:x893,项目名称:SharpSSH,代码行数:34,代码来源:RequestSftp.cs
示例4: Blit
public void Blit(Buffer src, int srcX, int srcY, int width, int height, int dstX, int dstY)
{
var attribs = new int[] {
(int)BlitAttribute.SCREEN_BLIT_SOURCE_X,
srcX,
(int)BlitAttribute.SCREEN_BLIT_SOURCE_Y,
srcY,
(int)BlitAttribute.SCREEN_BLIT_SOURCE_WIDTH,
width,
(int)BlitAttribute.SCREEN_BLIT_SOURCE_HEIGHT,
height,
(int)BlitAttribute.SCREEN_BLIT_DESTINATION_X,
dstX,
(int)BlitAttribute.SCREEN_BLIT_DESTINATION_Y,
dstY,
(int)BlitAttribute.SCREEN_BLIT_DESTINATION_WIDTH,
width,
(int)BlitAttribute.SCREEN_BLIT_DESTINATION_HEIGHT,
height,
(int)BlitAttribute.SCREEN_BLIT_END
};
if (screen_blit (context.Handle, buffer, src.buffer, attribs) != 0) {
throw new Exception ("Error blitting.");
}
}
开发者ID:h2oman,项目名称:monoberry,代码行数:25,代码来源:Buffer.cs
示例5: Clear
internal void Clear()
{
m_deviceContext.ClearState();
m_inputLayout = null;
m_primitiveTopology = PrimitiveTopology.Undefined;
m_indexBufferRef = null;
m_indexBufferFormat = 0;
m_indexBufferOffset = 0;
for (int i = 0; i < m_vertexBuffers.Length; i++)
m_vertexBuffers[i] = null;
for (int i = 0; i < m_vertexBuffersStrides.Length; i++)
m_vertexBuffersStrides[i] = 0;
m_blendState = null;
m_stencilRef = 0;
m_depthStencilState = null;
m_rtvsCount = 0;
for (int i = 0; i < m_rtvs.Length; i++)
m_rtvs[i] = null;
m_dsv = null;
m_rasterizerState = null;
m_scissorLeftTop = new Vector2I(-1, -1);
m_scissorRightBottom = new Vector2I(-1, -1);
m_viewport = default(RawViewportF);
m_targetBuffer = null;
m_targetOffsets = 0;
m_statistics.ClearStates++;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:32,代码来源:MyRenderContextState.cs
示例6: MeshContainer
public MeshContainer(Engine.Serialize.Mesh M)
{
if (M != null)
{
LocalAABBMax = M.AABBMax;
LocalAABBMin = M.AABBMin;
VertexsCount = M.VertexCount;
FaceCount = M.FaceCount;
BytesPerVertex = M.VertexData.Length / VertexsCount;
using (var vertices = new DataStream(BytesPerVertex * VertexsCount, true, true))
{
vertices.WriteRange<byte>(M.VertexData, 0, M.VertexData.Length);
vertices.Position = 0;
Vertexs = new Buffer(ModelViewer.Program.device, vertices, BytesPerVertex * VertexsCount, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
binding = new VertexBufferBinding(Vertexs, BytesPerVertex, 0);
}
using (var indices = new DataStream(4 * FaceCount * 3, true, true))
{
indices.WriteRange<byte>(M.IndexData, 0, M.IndexData.Length);
indices.Position = 0;
Indices = new Buffer(ModelViewer.Program.device, indices, 4 * FaceCount * 3, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
}
}
}
开发者ID:MagistrAVSH,项目名称:my-spacegame-engine,代码行数:27,代码来源:MeshContainer.cs
示例7: UnloadedBlock
internal UnloadedBlock(Buffer raw, DirectivesBlock directives)
: base(BlockCode.Unloaded)
{
kind = raw.ReadByte ();
start_counter = raw.ReadUlong ();
end_counter = raw.ReadUlong ();
thread_id = raw.ReadUlong ();
if (directives.LoadedElementsCarryId)
id = raw.ReadUint ();
item_name = raw.ReadString ();
switch ((LoadedItemInfo) kind) {
case LoadedItemInfo.APPDOMAIN:
is_appdomain = true;
break;
case LoadedItemInfo.MODULE:
is_module = true;
break;
case LoadedItemInfo.ASSEMBLY:
is_assembly = true;
break;
default:
throw new Exception (String.Format ("unknown load event kind {0}", kind));
}
if (!raw.IsEmpty)
throw new Exception ("Unexpected data remaining in block");
}
开发者ID:mono,项目名称:emveepee,代码行数:27,代码来源:UnloadedBlock.cs
示例8: WaitPanelThread
public WaitPanelThread(Point origin, int delay, bool positiveAxis, bool horizontal, Panel panel, Plane plane, Semaphore semaphoreThis, Semaphore semaphoreNext, Semaphore semaphoreTerminal, Buffer bufferPrevious, Buffer bufferNext, Buffer bufferTerminal, int length, int terminalID)
{
this.origin = origin;
this.delay = delay;
this.positiveAxis = positiveAxis;
this.panel = panel;
this.plane = plane;
this.panel.Paint += new PaintEventHandler(this.panel_Paint);
if (horizontal)
{
this.xDelta = positiveAxis ? +10 : -10;
this.yDelta = 0;
}
else
{
this.xDelta = 0;
this.yDelta = positiveAxis ? +10 : -10;
}
this.semaphoreThis = semaphoreThis;
this.semaphoreNext = semaphoreNext;
this.semaphoreTerminal = semaphoreTerminal;
this.bufferPrevious = bufferPrevious;
this.bufferNext = bufferNext;
this.bufferTerminal = bufferTerminal;
this.length = length;
this.terminalID = terminalID;
}
开发者ID:kathrynaj7,项目名称:AirportThreadingExample,代码行数:27,代码来源:WaitPanelThread.cs
示例9: BufferNode
public BufferNode(Dictionary<string, TreeNode> actors, Dictionary<string, TreeNode> quests, string clientHash)
{
this.Buffer = new Buffer(new byte[0]);
this.actors = actors;
this.quests = quests;
this.clientHash = clientHash;
}
开发者ID:loonbg,项目名称:mooege,代码行数:7,代码来源:BufferNode.cs
示例10: IOProcessor
public IOProcessor(KeyProcessor kpr)
{
SetKPR(kpr);
bf = new Buffer();
log = new Log();
cfg = new Config("MyInput\\");
}
开发者ID:sanlinnaing,项目名称:MyInput,代码行数:7,代码来源:IOProcessor.cs
示例11: run
public void run()
{
Buffer buf=new Buffer(300); // ??
Packet packet=new Packet(buf);
thread=this;
try
{
ss.Start();
while(thread!=null)
{
Socket socket=ss.AcceptSocket();
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
NetworkStream ns = new NetworkStream(socket);
Stream ins= ns;
Stream outs=ns;
ChannelDirectTCPIP channel=new ChannelDirectTCPIP();
channel.init();
channel.setInputStream(ins);
channel.setOutputStream(outs);
session.addChannel(channel);
((ChannelDirectTCPIP)channel).setHost(host);
((ChannelDirectTCPIP)channel).setPort(rport);
((ChannelDirectTCPIP)channel).setOrgIPAddress( ((IPEndPoint)socket.RemoteEndPoint).Address.ToString() );
((ChannelDirectTCPIP)channel).setOrgPort(((IPEndPoint)socket.RemoteEndPoint).Port);
channel.connect();
if(channel.exitstatus!=-1)
{
}
}
}
catch
{
//System.out.println("! "+e);
}
}
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:35,代码来源:PortWatcher.cs
示例12: Next
public Buffer Next()
{
lock (obj)
{
if (next == null) return null;
int size = next.Size();
if (size < 13) return null;
if (next.GetInt(0) != 0x42424344)
{
System.Console.WriteLine("Not reading a dirac stream");
next = null;
return null;
}
int offset = next.GetInt(5);
if (offset == 0)
offset = 13;
if (offset > size) return null;
if (prev != next.GetInt(9))
throw new Exception();
prev = offset;
if (size == offset)
{
Buffer tmp = next;
next = null;
return tmp;
}
else
{
Buffer tmp = next.Sub(0, offset);
next = next.Sub(offset);
return tmp;
}
}
}
开发者ID:mono,项目名称:csdirac,代码行数:34,代码来源:Stream.cs
示例13: Add
public void Add(Buffer buf)
{
lock(obj)
{
next = (next == null ? buf : next.Cat(buf));
}
}
开发者ID:mono,项目名称:csdirac,代码行数:7,代码来源:Stream.cs
示例14: TestTransform
public void TestTransform()
{
BlockCipher cipher1 = new BlockCipher();
BlockCipher cipher2 = new BlockCipher();
byte[] bytes1 = cipher1.InitializeHandshake();
byte[] bytes2 = cipher2.InitializeHandshake();
bytes1 = cipher2.Handshake(bytes1);
bytes2 = cipher1.Handshake(bytes2);
cipher1.FinalizeHandshake(bytes1);
cipher2.FinalizeHandshake(bytes2);
Buffer buffer = new Buffer();
string text = new String('x', 5300);
Assert.AreEqual(5300, text.Length);
/*
buffer.Write(1);
buffer.Write(text);
buffer.Shrink(1);
*/
cipher1.Transform(buffer, (int)buffer.Length);
cipher2.InverseTransform(buffer, (int)buffer.Length);
buffer.Rewind();
/*
string result;
buffer.Read(out result);
Assert.AreEqual(text, result);
*/
}
开发者ID:gitter-badger,项目名称:x2clr,代码行数:34,代码来源:CipherTests.cs
示例15: OnEnable
void OnEnable()
{
if (mRequest == null)
{
mRequest = Buffer.Create();
mRequest.BeginPacket(Packet.RequestServerList).Write(GameServer.gameID);
mRequest.EndPacket();
}
if (mRemoteAddress == null)
{
if (string.IsNullOrEmpty(remoteAddress))
{
mRemoteAddress = new IPEndPoint(IPAddress.Broadcast, remotePort);
}
else
{
mRemoteAddress = Tools.ResolveEndPoint(remoteAddress, remotePort);
}
if (mRemoteAddress == null)
{
mUdp.Error(new IPEndPoint(IPAddress.Loopback, mUdp.listeningPort), "Invalid address: " + remoteAddress + ":" + remotePort);
}
}
// Twice just in case the first try falls on a taken port
if (!mUdp.Start(Tools.randomPort)) mUdp.Start(Tools.randomPort);
}
开发者ID:jeffmun,项目名称:BalloonPop,代码行数:29,代码来源:TNUdpLobbyClient.cs
示例16: Main
static void Main()
{
var buffer = new Buffer { };
var blinker = new Blinker { SourceBuffer = buffer };
// PowerShell PS> Invoke-WebRequest -Uri "http://try.yaler.net/gsiot-8a3m-5w8t/blinkingPeriod/target" -Method Put -Body 100 -TimeoutSec 2
var webServer = new HttpServer
{
RelayDomain = Parameters.RelayDomain,
RelaySecretKey = Parameters.RelaySecretKey,
RequestRouting =
{
{
"PUT /blinkingPeriod/target",
new ManipulatedVariable
{
FromHttpRequest =
CSharpRepresentation.TryDeserializeInt,
ToActuator = buffer.HandlePut
}.HandleRequest
},
{
"GET /blinkingPeriod/target.html",
HandleBlinkTargetHtml
}
}
};
var blinkerThread = new Thread(blinker.Run);
blinkerThread.Start();
webServer.Run();
}
开发者ID:jchidley,项目名称:GSIOT-NP2,代码行数:33,代码来源:Program.cs
示例17: Main
private static int Main()
{
Buffer b1 = new Buffer("Abra-cadabra");
int result = 0;
if (b1.Peek() < 0)
{
result += 1;
}
b1.AdvanceToEnd();
if (b1.Peek() < 0)
{
result += 2;
}
if (result == 2)
{
Console.WriteLine("====== PASSED ======");
return 100;
}
else
{
Console.WriteLine("****** FAILED ******");
return 101;
}
}
开发者ID:l1183479157,项目名称:coreclr,代码行数:28,代码来源:bug595776.cs
示例18: Sky
public Sky(Device device, string filename, float skySphereRadius) {
CubeMapSRV = ShaderResourceView.FromFile(device, filename);
using (var r = CubeMapSRV.Resource) {
r.DebugName = "sky cubemap";
}
var sphere = GeometryGenerator.CreateSphere(skySphereRadius, 30, 30);
var vertices = sphere.Vertices.Select(v => v.Position).ToArray();
var vbd = new BufferDescription(
Marshal.SizeOf(typeof(Vector3)) * vertices.Length,
ResourceUsage.Immutable,
BindFlags.VertexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None,
0
);
_vb = new Buffer(device, new DataStream(vertices, false, false), vbd);
_indexCount = sphere.Indices.Count;
var ibd = new BufferDescription(
_indexCount * sizeof(int),
ResourceUsage.Immutable,
BindFlags.IndexBuffer,
CpuAccessFlags.None,
ResourceOptionFlags.None,
0
);
_ib = new Buffer(device, new DataStream(sphere.Indices.ToArray(), false, false), ibd);
}
开发者ID:amitprakash07,项目名称:dx11,代码行数:30,代码来源:Sky.cs
示例19: InputChannel
public InputChannel(int channel)
{
Channel = channel;
//Data = new List<double>();
movingAverage = new AudioLib.TF.MovingAverage(1);
Buffer = new Buffer(10000);
Config = new InputChannelConfig(this);
this.InputConfig.Name = "Ch " + channel;
// Set up IChannel - GetValue
Signals = new List<Signal>();
Signals.Add(new Signal(this, VALUE_POWER, GetPowerMapped));
Signals.Add(new Signal(this, VALUE_VALUE, GetValue));
// Set up ITrigger
TriggerEvent = new Event(this, TRIGGER_EVENT);
DataEvent = new Event(this, TRIGGER_DATA);
Events = new List<Event>();
Events.Add(TriggerEvent);
Events.Add(DataEvent);
Brain.KB.Sources.AddSignalChannel(this);
Brain.KB.Sources.AddTriggerChannel(this);
}
开发者ID:ValdemarOrn,项目名称:KickBrain,代码行数:26,代码来源:InputChannel.cs
示例20: Paragraph
protected override void Paragraph(Buffer ob, Buffer text)
{
ob.Put("\n");
ob.Put(text);
ob.Put("\n");
ob.Put("\n");
}
开发者ID:uonun,项目名称:sundown.net,代码行数:7,代码来源:BBCode.cs
注:本文中的Buffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论