本文整理汇总了C#中ByteArrayPart类的典型用法代码示例。如果您正苦于以下问题:C# ByteArrayPart类的具体用法?C# ByteArrayPart怎么用?C# ByteArrayPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayPart类属于命名空间,在下文中一共展示了ByteArrayPart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:five-x,项目名称:siprevo,代码行数:31,代码来源:ByteArrayPartTest.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:32,代码来源:PidfManipulationHandler.cs
示例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));
}
开发者ID:five-x,项目名称:siprevo,代码行数:28,代码来源:ByteArrayPartTest.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:7,代码来源:HttpServer.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:8,代码来源:DirectorySearchTU.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:8,代码来源:MrasTU.cs
示例7: WriteResponse
public void WriteResponse(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag)
{
WriteStatusLine(statusCode);
CopyViaToFromCallIdRecordRouteCSeq(request, statusCode, localTag);
WriteContentLength(0);
WriteCustomHeaders();
WriteCRLF();
}
开发者ID:five-x,项目名称:siprevo,代码行数:8,代码来源:SipResponseWriter.cs
示例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);
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:9,代码来源:ProxieFactory.cs
示例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);
}
开发者ID:five-x,项目名称:siprevo,代码行数:9,代码来源:SipResponseWriter.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:9,代码来源:ByteArray.cs
示例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;
}
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:10,代码来源:TrunkManager.cs
示例12: RemoveAllBindings
public void RemoveAllBindings(ByteArrayPart user, ByteArrayPart domain)
{
Bindings bindings = GetBindings(GetAor(user, domain));
if (bindings != null)
{
if (bindings.TryRemoveAll(ContactRemovedHandler))
RemoveStaleBindings(bindings);
}
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:10,代码来源:LocationService.cs
示例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;
}
开发者ID:vf1,项目名称:xcap.org,代码行数:12,代码来源:BaseResourceListsHandler.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:13,代码来源:HexEncoding.cs
示例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;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:15,代码来源:LocationService.cs
示例16: ProcessGetItem
public override HttpMessageWriter ProcessGetItem(ByteArrayPart username, ByteArrayPart domain)
{
var document = simpleModule.GetDocument(username.ToString() + "@" + domain.ToString());
if (document == null)
{
return base.CreateResponse(StatusCodes.NotFound);
}
else
{
var response = base.CreateNotFinishedResponse(StatusCodes.OK, ContentType.ApplicationPidfXml);
document.WriteLenghtAndContent(response);
return response;
}
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:17,代码来源:PidfManipulationHandler.cs
示例17: TryParseHex2
public static bool TryParseHex2(ByteArrayPart part, int offset, out byte result)
{
if (part.IsValid && part.Length - offset >= 2)
{
byte b1 = AsciiCodeToHex[part.Bytes[part.Offset + offset]];
byte b2 = AsciiCodeToHex[part.Bytes[part.Offset + offset + 1]];
if (b1 != 0xff && b2 != 0xff)
{
result = b1;
result <<= 4;
result |= b2;
return true;
}
}
result = 0;
return false;
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:19,代码来源:HexEncoding.cs
示例18: GetEntries
protected override IEnumerable<Entry> GetEntries(ByteArrayPart username, ByteArrayPart domain)
{
var account = accounts.GetAccount(domain);
if (account != null)
{
for (int i = 0; i < userz.Count; i++)
{
int count = userz[i].GetCount(account.Id);
var users = userz[i].GetUsers(account.Id, 0, count);
for (int j = 0; j < users.Count; j++)
{
var user = users[j];
yield return new Entry("sip:" + user.Name + "@" + account.DomainName, user.DisplayName);
}
}
}
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:20,代码来源:ResourceListsHandler.cs
示例19: GenerateForwardedRequest
public void GenerateForwardedRequest(SipMessageWriter writer, SipMessageReader reader, ArraySegment<byte> content, ConnectionAddresses fromConnectionAddress, int serverTransactionId)
{
//dialog2 = new Dialog(reader, fromTag, fromConnectionAddress);
Dialog dialog1 = null;
if (HexEncoding.TryParseHex8(reader.To.Tag, out tag))
dialog1 = trunk.GetDialog1(tag);
else
tag = DialogManager.NewLocalTag();
dialog2 = new Dialog(reader, tag, fromConnectionAddress);
trunk.AddDialog2(tag, dialog2);
/////////////////////////////////////////////////////////////////////////////////
writer.WriteRequestLine(reader.Method, binding.AddrSpec);
//var msReceivedCid = fromConnectionAddress.ToLowerHexChars(serverTransactionId);
//writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId, msReceivedCid);
writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId);
for (int i = 0; i < reader.Count.HeaderCount; i++)
{
switch (reader.Headers[i].HeaderName)
{
case HeaderNames.MaxForwards:
writer.WriteMaxForwards((reader.MaxForwards == int.MinValue) ? 69 : reader.MaxForwards - 1);
break;
case HeaderNames.Contact:
writer.WriteContact(binding.ConnectionAddresses.LocalEndPoint, binding.ConnectionAddresses.Transport);
break;
case HeaderNames.To:
writer.WriteTo(trunk.ForwardCallToUri, (dialog1 != null) ? dialog1.RemoteTag : ByteArrayPart.Invalid);
break;
case HeaderNames.From:
writer.WriteFrom(reader.From.AddrSpec.Value, tag);
break;
case HeaderNames.Authorization:
break;
default:
writer.WriteHeader(reader, i);
break;
case HeaderNames.Via:
via = reader.Headers[i].Value.DeepCopy();
break;
}
}
if (reader.ContentLength == int.MinValue)
writer.WriteContentLength(content.Count);
writer.WriteCustomHeaders();
writer.WriteCRLF();
writer.Write(content);
}
开发者ID:hungdluit,项目名称:sipserver,代码行数:62,代码来源:TrunkLocalProxie.cs
示例20: ProcessGetItem
public override HttpMessageWriter ProcessGetItem(ByteArrayPart item)
{
throw new NotImplementedException();
}
开发者ID:vf1,项目名称:xcap.org,代码行数:4,代码来源:XcapCapsHandler.cs
注:本文中的ByteArrayPart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论