/// <summary>Update the 'FromFile' value, and add the relevant tokens to the patch context.</summary>
        /// <param name="context">The local patch context (already updated from the parent context).</param>
        /// <returns>Returns whether the field changed.</returns>
        private bool UpdateFromFile(LocalContext context)
        {
            // no value
            if (this.ManagedRawFromAsset == null)
            {
                this.FromAsset = null;
                context.SetLocalValue(ConditionType.FromFile.ToString(), "");
                return(false);
            }

            // update
            bool changed = this.ManagedRawFromAsset.UpdateContext(context);

            if (this.RawFromAsset.IsReady)
            {
                this.FromAsset = this.NormalizeLocalAssetPath(this.RawFromAsset.Value, logName: $"{nameof(PatchConfig.FromFile)} field");
                context.SetLocalValue(ConditionType.FromFile.ToString(), this.FromAsset);
            }
            else
            {
                this.FromAsset = null;
                context.SetLocalValue(ConditionType.FromFile.ToString(), "", ready: false);
            }

            return(changed);
        }
Exemple #2
0
        /// <summary>Update the target path, and add the relevant tokens to the patch context.</summary>
        /// <param name="context">The local patch context (already updated from the parent context).</param>
        /// <returns>Returns whether the field changed.</returns>
        private bool UpdateTargetPath(LocalContext context)
        {
            bool changed = this.ManagedRawTargetAsset.UpdateContext(context);

            if (this.RawTargetAsset.IsReady)
            {
                this.TargetAsset = this.NormalizeAssetNameImpl(this.RawTargetAsset.Value);
                context.SetLocalValue(ConditionType.Target.ToString(), this.TargetAsset);
                context.SetLocalValue(ConditionType.TargetWithoutPath.ToString(), Path.GetFileName(this.TargetAsset));
            }
            else
            {
                this.TargetAsset = "";
            }

            return(changed);
        }
        /// <summary>Update the target path, and add the relevant tokens to the patch context.</summary>
        /// <param name="context">The local patch context (already updated from the parent context).</param>
        /// <returns>Returns whether the field changed.</returns>
        private bool UpdateTargetPath(LocalContext context)
        {
            if (this.RawTargetAsset == null)
            {
                return(false);
            }

            bool changed = this.ManagedRawTargetAsset.UpdateContext(context);

            if (this.RawTargetAsset.IsReady)
            {
                this.TargetAsset = this.NormalizeAssetNameImpl(this.RawTargetAsset.Value);
                context.SetLocalValue(ConditionType.Target.ToString(), this.TargetAsset);
                context.SetLocalValue(ConditionType.TargetPathOnly.ToString(), System.IO.Path.GetDirectoryName(this.TargetAsset));
                context.SetLocalValue(ConditionType.TargetWithoutPath.ToString(), System.IO.Path.GetFileName(this.TargetAsset));
            }
            else
            {
                this.TargetAsset = "";
                context.SetLocalValue(ConditionType.Target.ToString(), "", ready: false);
                context.SetLocalValue(ConditionType.TargetPathOnly.ToString(), "", ready: false);
                context.SetLocalValue(ConditionType.TargetWithoutPath.ToString(), "", ready: false);
            }

            return(changed);
        }