/// <summary>
 /// Convert registration request to application info model
 /// </summary>
 /// <param name="request"></param>
 /// <param name="context"></param>
 /// <param name="disabled"></param>
 /// <returns></returns>
 public static ApplicationInfoModel ToApplicationInfo(
     this ApplicationRegistrationRequestModel request,
     RegistryOperationContextModel context,
     bool disabled = true)
 {
     return(new ApplicationInfoModel {
         ApplicationName = request.ApplicationName,
         LocalizedNames = request.LocalizedNames,
         ProductUri = request.ProductUri,
         DiscoveryUrls = request.DiscoveryUrls,
         DiscoveryProfileUri = request.DiscoveryProfileUri,
         ApplicationType = request.ApplicationType ?? ApplicationType.Server,
         ApplicationUri = request.ApplicationUri,
         Locale = request.Locale,
         Capabilities = request.Capabilities,
         GatewayServerUri = request.GatewayServerUri,
         SiteId = request.SiteId,
         NotSeenSince = disabled ? DateTime.UtcNow : (DateTime?)null,
         Created = context,
         Updated = null,
         ApplicationId = null,
         DiscovererId = null,
         HostAddresses = null,
     });
 }
Пример #2
0
 /// <summary>
 /// Clone
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static RegistryOperationContextModel Clone(
     this RegistryOperationContextModel model)
 {
     model = model.Validate();
     return(new RegistryOperationContextModel {
         AuthorityId = model.AuthorityId,
         Time = model.Time
     });
 }
Пример #3
0
 /// <summary>
 /// Clone
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static RegistryOperationContextModel Validate(
     this RegistryOperationContextModel context)
 {
     if (context == null)
     {
         context = new RegistryOperationContextModel {
             AuthorityId = null, // Should throw if configured
             Time        = DateTime.UtcNow
         };
     }
     return(context);
 }
 /// <summary>
 /// Convert to Update model
 /// </summary>
 /// <param name="model"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public static ApplicationRegistrationUpdateModel ToUpdateRequest(
     this ApplicationInfoModel model, RegistryOperationContextModel context = null)
 {
     return(new ApplicationRegistrationUpdateModel {
         ApplicationName = model.ApplicationName,
         Capabilities = model.Capabilities,
         DiscoveryProfileUri = model.DiscoveryProfileUri,
         DiscoveryUrls = model.DiscoveryUrls,
         GatewayServerUri = model.GatewayServerUri,
         LocalizedNames = model.LocalizedNames,
         ProductUri = model.ProductUri,
         Locale = model.Locale,
         Context = context
     });
 }
 /// <summary>
 /// Convert to registration request
 /// </summary>
 /// <param name="model"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public static ApplicationRegistrationRequestModel ToRegistrationRequest(
     this ApplicationInfoModel model, RegistryOperationContextModel context = null)
 {
     return(new ApplicationRegistrationRequestModel {
         ApplicationName = model.ApplicationName,
         ApplicationType = model.ApplicationType,
         Capabilities = model.Capabilities,
         ApplicationUri = model.ApplicationUri,
         Certificate = model.Certificate,
         DiscoveryProfileUri = model.DiscoveryProfileUri,
         DiscoveryUrls = model.DiscoveryUrls,
         GatewayServerUri = model.GatewayServerUri,
         LocalizedNames = model.LocalizedNames,
         ProductUri = model.ProductUri,
         SiteId = model.SiteId,
         Context = context
     });
 }