Skip to content

Commit

Permalink
Extract the framework restriction application code
Browse files Browse the repository at this point in the history
  • Loading branch information
vbfox committed Oct 15, 2015
1 parent a6a09e1 commit 2daab5b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
20 changes: 1 addition & 19 deletions src/Paket.Core/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -288,25 +288,7 @@ type InstallModel =
| [] -> this
| restrictions ->
let applRestriction folder =
{ folder with
Targets =
folder.Targets
|> List.filter
(function
| SinglePlatform pf ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly fw -> pf = fw
| FrameworkRestriction.Portable r -> false
| FrameworkRestriction.AtLeast fw -> pf >= fw
| FrameworkRestriction.Between(min,max) -> pf >= min && pf < max)
| _ ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Portable r -> true
| _ -> false))}
{ folder with Targets = applyRestrictionsToTargets restrictions folder.Targets}

{this with
ReferenceFileFolders =
Expand Down
23 changes: 23 additions & 0 deletions src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ let filterRestrictions (list1:FrameworkRestrictions) (list2:FrameworkRestriction
if c <> [] then yield! c]
|> optimizeRestrictions

/// Get if a target should be considered with the specified restrictions
let isTargetMatchingRestrictions (restrictions:FrameworkRestrictions) = function
| SinglePlatform pf ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly fw -> pf = fw
| FrameworkRestriction.Portable _ -> false
| FrameworkRestriction.AtLeast fw -> pf >= fw
| FrameworkRestriction.Between(min,max) -> pf >= min && pf < max)
| _ ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Portable r -> true
| _ -> false)

/// Get all targets that should be considered with the specified restrictions
let applyRestrictionsToTargets (restrictions:FrameworkRestrictions) (targets: TargetProfile list) =
let result = targets |> List.filter (isTargetMatchingRestrictions restrictions)
result


type ContentCopySettings =
| Omit
| Overwrite
Expand Down

0 comments on commit 2daab5b

Please sign in to comment.