本文整理汇总了C#中ObjectTypes.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectTypes.Parse方法的具体用法?C# ObjectTypes.Parse怎么用?C# ObjectTypes.Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectTypes
的用法示例。
在下文中一共展示了ObjectTypes.Parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessUpdateRequest
private void ProcessUpdateRequest(Exchange exchange)
{
Request request = exchange.Request;
Guid clientID;
Response response;
if (StringUtils.GuidTryDecode(request.UriPath.Substring(4), out clientID))
{
LWM2MClient client = BusinessLogicFactory.Clients.GetClient(clientID);
if (client == null)
{
response = Response.CreateResponse(request, StatusCode.NotFound);
}
else
{
client.Parse(request.UriQueries);
BusinessLogicFactory.Clients.UpdateClientActivity(client);
client.Address = request.Source;
client.EndPoint = exchange.EndPoint;
bool updatedLifeTime = false;
if ((request.ContentType == (int)MediaType.ApplicationLinkFormat) || (request.ContentType == -1))
{
if (request.PayloadSize > 0)
{
ObjectTypes objectTypes = new ObjectTypes();
objectTypes.Parse(request.PayloadString);
if (ObjectTypes.Compare(client.SupportedTypes, objectTypes) != 0)
{
client.SupportedTypes = objectTypes;
if (client.ClientID != Guid.Empty)
{
DataAccessFactory.Clients.SaveClient(client, TObjectState.Add);
updatedLifeTime = true;
}
BusinessLogicFactory.Clients.ClientChangedSupportedTypes(client);
}
}
}
if (!updatedLifeTime)
{
BusinessLogicFactory.Clients.UpdateClientLifetime(client.ClientID, client.Lifetime);
}
response = Response.CreateResponse(request, StatusCode.Changed);
ApplicationEventLog.Write(LogLevel.Information, string.Concat("Client update ", client.Name, " address ", client.Address.ToString()));
}
}
else
{
ApplicationEventLog.WriteEntry(string.Concat("Invalid update location", request.UriPath));
response = Response.CreateResponse(request, StatusCode.BadRequest);
}
exchange.SendResponse(response);
}
示例2: ProcessRegisterRequest
private void ProcessRegisterRequest(Exchange exchange)
{
Request request = exchange.Request;
LWM2MClient client = new LWM2MClient();
client.Server = _ServerEndPoint;
client.Address = request.Source;
client.Parse(request.UriQueries);
ObjectTypes objectTypes = new ObjectTypes();
objectTypes.Parse(request.PayloadString);
client.SupportedTypes = objectTypes;
client.EndPoint = exchange.EndPoint;
if (_SecureChannel != null)
{
CertificateInfo certificateInfo = _SecureChannel.GetClientCertificateInfo(client.Address);
if (certificateInfo == null)
{
string pskIdentity = _SecureChannel.GetClientPSKIdentity(client.Address);
if (!string.IsNullOrEmpty(pskIdentity))
{
Guid clientID;
PSKIdentity identity = DataAccessFactory.Identities.GetPSKIdentity(pskIdentity);
if (identity != null)
{
if (StringUtils.GuidTryDecode(pskIdentity, out clientID))
{
client.ClientID = clientID;
}
client.OrganisationID = identity.OrganisationID;
}
}
}
else
{
Console.WriteLine(certificateInfo.Subject.CommonName);
Console.WriteLine(certificateInfo.Subject.Organistion);
Guid clientID;
if (Guid.TryParse(certificateInfo.Subject.CommonName, out clientID))
{
client.ClientID = clientID;
}
int organisationID;
if (int.TryParse(certificateInfo.Subject.Organistion, out organisationID))
{
client.OrganisationID = organisationID;
}
}
}
if (client.ClientID != Guid.Empty && (client.OrganisationID > 0 || !SecureOnly) && !DataAccessFactory.Clients.IsBlacklisted(client.ClientID))
{
BusinessLogicFactory.Clients.AddClient(client);
}
Response response = Response.CreateResponse(request, StatusCode.Created);
//response.AddOption(Option.Create(OptionType.LocationPath, string.Concat("rd/",StringUtils.GuidEncode(client.ClientID))));
response.AddOption(Option.Create(OptionType.LocationPath, "rd"));
response.AddOption(Option.Create(OptionType.LocationPath, StringUtils.GuidEncode(client.ClientID)));
exchange.SendResponse(response);
ApplicationEventLog.Write(LogLevel.Information, string.Concat("Client registered ", client.Name, " address ", client.Address.ToString()));
}