本文整理汇总了C#中ByteArrayPart类的典型用法代码示例。如果您正苦于以下问题:C# ByteArrayPart类的具体用法?C# ByteArrayPart怎么用?C# ByteArrayPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayPart类属于命名空间,在下文中一共展示了ByteArrayPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: It_should_trim_sws_at_end
public void It_should_trim_sws_at_end()
{
var part1 = new ByteArrayPart("X\r\n ");
part1.TrimEndSws();
var part2 = new ByteArrayPart("X \r\n ");
part2.TrimEndSws();
var part3 = new ByteArrayPart("X \r\n ");
part3.TrimEndSws();
var part4 = new ByteArrayPart(" \r\n ");
part4.TrimEndSws();
var part5 = new ByteArrayPart(" \r\n ");
part5.TrimEndSws();
var part6 = new ByteArrayPart("X ");
part6.TrimEndSws();
var part7 = new ByteArrayPart("");
part7.TrimEndSws();
Assert.AreEqual("X", part1.ToString());
Assert.AreEqual("X", part2.ToString());
Assert.AreEqual("X", part3.ToString());
Assert.AreEqual("", part4.ToString());
Assert.AreEqual("", part5.ToString());
Assert.AreEqual("X", part6.ToString());
Assert.AreEqual("", part7.ToString());
}
示例2: ProcessPutItem
public override HttpMessageWriter ProcessPutItem(ByteArrayPart username, ByteArrayPart domain, HttpMessageReader reader, ArraySegment<byte> content)
{
var statusCode = StatusCodes.OK;
int sipIfMatch = simpleModule.InvalidEtag;
if (reader.Count.IfMatches > 0)
{
if (HexEncoding.TryParseHex8(reader.IfMatches[0].Bytes, reader.IfMatches[0].Begin, out sipIfMatch) == false)
statusCode = StatusCodes.PreconditionFailed;
}
if (statusCode == StatusCodes.OK)
{
if (simpleModule.Publish(username.ToString() + "@" + domain.ToString(), ref sipIfMatch, 60, content) == false)
statusCode = StatusCodes.BadRequest;
}
HttpMessageWriter response;
if (statusCode != StatusCodes.OK)
{
response = CreateResponse(statusCode);
}
else
{
response = CreateNotFinishedResponse(statusCode, ContentType.None);
response.WriteEtag(sipIfMatch);
response.WriteCRLF();
}
return response;
}
示例3: It_should_test_equality_by_value
public void It_should_test_equality_by_value()
{
var part1 = new ByteArrayPart(@"1234567890");
var part2 = new ByteArrayPart(@"1234567890");
var part3 = new ByteArrayPart(@"123456789-");
var part4 = new ByteArrayPart(@"123456789");
var part5 = new ByteArrayPart(@"12345678901");
Assert.IsTrue(part1.IsEqualValue(part2));
Assert.IsFalse(part1.IsEqualValue(part3));
Assert.IsFalse(part1.IsEqualValue(part4));
Assert.IsFalse(part1.IsEqualValue(part5));
Assert.IsTrue(part1 == part2);
Assert.IsTrue(part1 != part3);
Assert.IsTrue(part1 != part4);
Assert.IsTrue(part1 != part5);
var bytes2 = Encoding.UTF8.GetBytes(@"1234567890");
var bytes3 = Encoding.UTF8.GetBytes(@"123456789-");
var bytes4 = Encoding.UTF8.GetBytes(@"123456789");
var bytes5 = Encoding.UTF8.GetBytes(@"12345678901");
Assert.IsTrue(part1.Equals(bytes2));
Assert.IsFalse(part1.Equals(bytes3));
Assert.IsFalse(part1.Equals(bytes4));
Assert.IsFalse(part1.Equals(bytes5));
}
示例4: IsAuthorized
protected override HttpMessageWriter IsAuthorized(BaseHttpConnection c, ByteArrayPart realm, int agentIndex)
{
HttpMessageWriter writer;
authorization.IsAuthorized(c.HttpReader, c.Content, realm, agentIndex, out writer);
return writer;
}
示例5: DirectorySearchTU
public DirectorySearchTU(IAccounts accounts, ServiceSoap1 serviceSoap, IUserz userz)
{
this.type = new ByteArrayPart("application");
this.subtype = new ByteArrayPart("SOAP+xml");
this.accounts = accounts;
this.serviceSoap = serviceSoap;
this.userz = userz;
}
示例6: MrasTU
public MrasTU(Mras1 mras)
{
this.type = new ByteArrayPart("application");
this.subtype = new ByteArrayPart("msrtc-media-relay-auth+xml");
this.userPrefix = Encoding.UTF8.GetBytes("MRASLoc.");
this.mras = mras;
}
示例7: WriteResponse
public void WriteResponse(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag)
{
WriteStatusLine(statusCode);
CopyViaToFromCallIdRecordRouteCSeq(request, statusCode, localTag);
WriteContentLength(0);
WriteCustomHeaders();
WriteCRLF();
}
示例8: Create
public static IProxie Create(int transactionId, Trunk trunk, ByteArrayPart toTag)
{
int tag;
Dialog dialog1 = null;
if (HexEncoding.TryParseHex8(toTag, out tag))
dialog1 = trunk.GetDialog1(tag);
return (dialog1 == null) ? null : new TrunkDialogProxie(transactionId, trunk, tag, dialog1);
}
示例9: WriteStatusLineToTop
public void WriteStatusLineToTop(StatusCodes statusCode, ByteArrayPart reason)
{
WriteToTop(C.CRLF);
WriteToTop(reason, 100);
WriteToTop(C.SP);
WriteToTop((uint)statusCode);
WriteToTop(C.SP);
WriteToTop(C.SIP_2_0);
}
示例10: CopyFrom
public static int CopyFrom(this byte[] bytes, ByteArrayPart part, int offset)
{
int length = part.Length;
if (length > 0)
Buffer.BlockCopy(part.Bytes, part.Begin, bytes, offset, length);
return offset + length;
}
示例11: GetTrunkByDomain
public Trunk GetTrunkByDomain(ByteArrayPart host)
{
lock (sync)
{
for (int i = 0; i < trunks.Count; i++)
if (trunks[i].Domain.Equals(host))
return trunks[i].IsConnected ? trunks[i] : null;
return null;
}
}
示例12: RemoveAllBindings
public void RemoveAllBindings(ByteArrayPart user, ByteArrayPart domain)
{
Bindings bindings = GetBindings(GetAor(user, domain));
if (bindings != null)
{
if (bindings.TryRemoveAll(ContactRemovedHandler))
RemoveStaleBindings(bindings);
}
}
示例13: ProcessGetItem
public HttpMessageWriter ProcessGetItem(ByteArrayPart username, ByteArrayPart domain)
{
var writer = base.CreateNotFinishedResponse(StatusCodes.OK, ContentType.ApplicationResourceListsXml);
var content = CreateResourceList(GetEntries(username, domain));
writer.WriteContentLength(content.Length);
writer.WriteCRLF();
writer.Write(content);
return writer;
}
示例14: ParseHex2
public static byte ParseHex2(ByteArrayPart part, int offset)
{
byte result = 0xff;
if (part.IsValid && part.Length - offset >= 2)
{
result = AsciiCodeToHex[part.Bytes[part.Offset + offset]];
result <<= 4;
result |= AsciiCodeToHex[part.Bytes[part.Offset + offset + 1]];
}
return result;
}
示例15: UpdateBindings
public bool UpdateBindings(ByteArrayPart user, ByteArrayPart domain, IncomingMessageEx request, int defaultExpires)
{
bool isNewData;
Bindings bindings;
do
{
bindings = GetOrAddBindings(GetAor(user, domain));
} while (bindings.TryUpdate(request, defaultExpires, out isNewData, ContactAddedHandler, ContactRemovedHandler) == false);
RemoveStaleBindings(bindings);
return isNewData;
}