logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class PrefetchPolicyValidator

    Every rule that decides whether a PrefetchPolicyCreator.Input or a live wizard row is safe to write, resolved read-only against the project's own assets. PrefetchPolicyCreator keeps a thin Validate forwarder for its existing public surface; every other caller (headless tests, the window) reaches this type directly.

    Inheritance
    object
    PrefetchPolicyValidator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.AssetPrefetcher.Infrastructure.Editor.Builder
    Assembly: Serenity.UnityAssetPrefetcher.Infrastructure.Editor.dll
    Syntax
    public static class PrefetchPolicyValidator

    Methods

    FindOrphanedProfiles(PrefetchPolicyRegistry, List<ProfileRow>)

    Profiles an existing registry references whose resolved id has no matching row in the current input — Create(Input) replaces Profiles wholesale from the authored rows, so anything not re-authored is silently dropped from the array (never deleted). Shared with Preview(Input).

    Declaration
    public static List<PrefetchPolicyProfile> FindOrphanedProfiles(PrefetchPolicyRegistry existingRegistry, List<PrefetchPolicyCreator.ProfileRow> rows)
    Parameters
    Type Name Description
    PrefetchPolicyRegistry existingRegistry
    List<PrefetchPolicyCreator.ProfileRow> rows
    Returns
    Type Description
    List<PrefetchPolicyProfile>

    FindProfileByIdOrCaseVariant(string, string)

    A live (uncached) counterpart of Serenity.AssetPrefetcher.Infrastructure.Editor.Builder.PrefetchPolicyValidator.FindByIdOrCaseVariant(System.Collections.Generic.IReadOnlyDictionary{System.String,Serenity.AssetPrefetcher.Infrastructure.Settings.PrefetchPolicyProfile},System.String) for a one-off caller that is not on a per-repaint hot path — CreateFromDrafts(IReadOnlyList<SerenityWizardScratchDraft<PrefetchPolicyProfile>>, string, string, bool, UnboundRowWriteMode)'s own defense-in-depth check, which runs once per actual write, never per frame.

    Declaration
    public static PrefetchPolicyProfile FindProfileByIdOrCaseVariant(string profilesFolderPath, string id)
    Parameters
    Type Name Description
    string profilesFolderPath
    string id
    Returns
    Type Description
    PrefetchPolicyProfile

    ResolvedProfileId(PrefetchPolicyProfile)

    The profile's resolved identity — the same id Get(string) matches against (asset name when the serialized Id is empty), read through the IFoundationSettings.Id getter IPrefetchPolicyProfile exposes. Shared with PrefetchPolicyCreator's own ordering/reporting.

    Declaration
    public static string ResolvedProfileId(PrefetchPolicyProfile profile)
    Parameters
    Type Name Description
    PrefetchPolicyProfile profile
    Returns
    Type Description
    string

    ScanProfilesInFolderById(string)

    Every PrefetchPolicyProfile currently in profilesFolderPath, keyed by its own resolved Id (ordinal) — the project-wide scan CreatePrefetchPolicyWindow caches once per validation recompute instead of repeating per row, per keystroke. A caller matching a candidate Id also checks case variants via Serenity.AssetPrefetcher.Infrastructure.Editor.Builder.PrefetchPolicyValidator.FindByIdOrCaseVariant(System.Collections.Generic.IReadOnlyDictionary{System.String,Serenity.AssetPrefetcher.Infrastructure.Settings.PrefetchPolicyProfile},System.String), since this dictionary's own ordinal keys alone would miss them.

    Declaration
    public static Dictionary<string, PrefetchPolicyProfile> ScanProfilesInFolderById(string profilesFolderPath)
    Parameters
    Type Name Description
    string profilesFolderPath
    Returns
    Type Description
    Dictionary<string, PrefetchPolicyProfile>

    Validate(Input)

    Validates the request: at least one profile row, exactly one profile with DefaultProfileId, unique Ids (case-insensitively — they become file names) that are each non-empty, a positive MaxSizeMB on every row (a warning when it is below RuntimeMinimumMaxSizeMB — the runtime clamps it rather than rejecting it), and a well-formed destination folder. Also warns (never blocks) when: the 'default' row is not listed first (Create(Input) reorders it to the front regardless); a project-wide registry search turns up more than one existing asset — see the resolve-or-edit note on ResolveRegistryContext(string); or an existing registry references profiles that will be unlinked because they are not among the authored rows.

    Declaration
    public static SerenityCreationValidationResult Validate(PrefetchPolicyCreator.Input input)
    Parameters
    Type Name Description
    PrefetchPolicyCreator.Input input
    Returns
    Type Description
    SerenityCreationValidationResult

    ValidateRowIdNotBoundToADifferentAsset(IReadOnlyDictionary<string, PrefetchPolicyProfile>, string, string)

    The row-binding rule CreateFromDrafts(IReadOnlyList<SerenityWizardScratchDraft<PrefetchPolicyProfile>>, string, string, bool, UnboundRowWriteMode)'s own SourceAsset-first resolution depends on being enforced upstream, before an author ever confirms: a row bound to an existing profile (sourceAssetPath non-empty) may rename that SAME asset's Id freely, but never retype into an Id that already belongs to a DIFFERENT existing profile — and a brand-new row (sourceAssetPath empty) may never silently claim an untracked existing profile's Id either, which the wizard's own row list would then disagree with. Returns the blocking message, or null when candidateId is free or already belongs to the row's own source. Matches by exact Id first, then by case-variant — a retyped Id colliding with an existing profile only by letter case is still a real collision (both would sanitize to the same file name), the same reasoning PrefetchPolicyCreator.ProfileRow's own row-vs-row duplicate check already applies.

    Kept here — not folded into Validate(Input)/Serenity.AssetPrefetcher.Infrastructure.Editor.Builder.PrefetchPolicyValidator.ValidateProfileRows(System.Collections.Generic.List{Serenity.AssetPrefetcher.Infrastructure.Editor.Builder.PrefetchPolicyCreator.ProfileRow},System.String,Serenity.Global.Infrastructure.Editor.SerenityCreationValidationResult) — because Create(Input)'s own flat PrefetchPolicyCreator.Input/PrefetchPolicyCreator.ProfileRow shape has no "seeded from" concept: every one of ITS rows resolves by Id-in-folder as a documented, intentional feature (update-in-place by Id for a headless/programmatic caller), which this rule would otherwise wrongly block. CreatePrefetchPolicyWindow — the only caller with real row bindings to check — calls this directly for both its per-row early hint and its primary-action gate, against profilesInFolderById: one project-wide scan cached per validation recompute rather than repeated per row, per keystroke.

    Declaration
    public static string ValidateRowIdNotBoundToADifferentAsset(IReadOnlyDictionary<string, PrefetchPolicyProfile> profilesInFolderById, string sourceAssetPath, string candidateId)
    Parameters
    Type Name Description
    IReadOnlyDictionary<string, PrefetchPolicyProfile> profilesInFolderById
    string sourceAssetPath
    string candidateId
    Returns
    Type Description
    string
    In this article
    © 2026 Serenity. All Rights Reserved