public static EndpointActionDto ToEndpointRuleDto(this EndpointActionEntity entity, InternalHelper internalHelper) { var actionType = internalHelper.GetConcreteActionType(entity.ActionType); var optionsType = actionType.BaseType.GetGenericArguments().FirstOrDefault(); var dto = new EndpointActionDto(); dto.Id = entity.Id; dto.ActionType = entity.ActionType; dto.Enabled = entity.Enabled; dto.EndpointRuleEntityId = entity.EndpointRuleEntityId; dto.Order = entity.Order; dto.Terminating = entity.Terminating; dto.WriteStreamDirect = entity.WriteStreamDirect; var tempDict = Json.Converter.ToDictionary(entity.Parameters); var nDict = new Dictionary <string, object>(); foreach (var(key, value) in tempDict) { var prop = optionsType.GetProperty(key); if (prop == null) { continue; } var internalProp = prop.GetCustomAttribute <InternalAttribute>(); if (internalProp == null) { nDict.Add(key, value); } } dto.Parameters = nDict; return(dto); }