Esempio n. 1
0
        /*********
        ** Protected methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="operation">The text operation to perform.</param>
        /// <param name="target">The specific text field to change as a breadcrumb path. Each value in the list represents a field to navigate into.</param>
        protected BaseTextOperation(TextOperationType operation, ICollection <IManagedTokenString> target)
        {
            this.Operation = operation;
            this.Target    = target.ToArray <ITokenString>();

            this.Contextuals = new AggregateContextual()
                               .Add(target);
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="key">The unique key for the entry in the data file.</param>
        /// <param name="value">The entry value to set.</param>
        public EditDataPatchRecord(ITokenString key, TokenisableJToken value)
        {
            this.Key   = key;
            this.Value = value;

            this.Contextuals = new AggregateContextual()
                               .Add(key)
                               .Add(value);
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="key">The map property name.</param>
        /// <param name="value">The map property value.</param>
        public EditMapPatchProperty(IManagedTokenString key, IManagedTokenString?value)
        {
            this.Key   = key;
            this.Value = value;

            this.Contextuals = new AggregateContextual()
                               .Add(key)
                               .Add(value);
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="conditions">The underlying conditions.</param>
        /// <param name="context">The context with which to update conditions.</param>
        /// <param name="isValid">Whether the conditions were parsed successfully (regardless of whether they're in scope currently).</param>
        /// <param name="validationError">If <paramref name="isValid"/> is false, an error phrase indicating why the conditions failed to parse.</param>
        public ApiManagedConditionsForSingleScreen(Condition[] conditions, IContext context, bool isValid = true, string validationError = null)
        {
            this.Conditions      = conditions;
            this.Context         = context;
            this.IsValid         = isValid;
            this.ValidationError = validationError;

            this.Contextuals = new AggregateContextual().Add(conditions);
        }
Esempio n. 5
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="parentToken">The token whose value to set.</param>
 /// <param name="value">The token value to set.</param>
 /// <param name="conditions">The conditions that must match to set this value.</param>
 public DynamicTokenValue(ManagedManualToken parentToken, IManagedTokenString value, IEnumerable <Condition> conditions)
 {
     this.ParentToken = parentToken;
     this.Value       = value;
     this.Conditions  = conditions.ToArray();
     this.Contextuals = new AggregateContextual()
                        .Add(value)
                        .Add(this.Conditions);
 }
Esempio n. 6
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="name">The name of the token whose value to set.</param>
 /// <param name="value">The token value to set.</param>
 /// <param name="conditions">The conditions that must match to set this value.</param>
 public DynamicTokenValue(string name, IManagedTokenString value, IEnumerable <Condition> conditions)
 {
     this.Name        = name;
     this.Value       = value;
     this.Conditions  = conditions.ToArray();
     this.Contextuals = new AggregateContextual()
                        .Add(value)
                        .Add(this.Conditions);
 }
Esempio n. 7
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="parentToken">The token whose value to set.</param>
 /// <param name="value">The token value to set.</param>
 /// <param name="conditions">The conditions that must match to set this value.</param>
 public DynamicTokenValue(ManagedManualToken parentToken, IManagedTokenString value, Condition[] conditions)
 {
     this.ParentToken = parentToken;
     this.Value       = value;
     this.Conditions  = conditions;
     this.Contextuals = new AggregateContextual()
                        .Add(value)
                        .Add(this.Conditions);
 }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="entryKey">The unique key for the entry in the data file.</param>
        /// <param name="fieldKey">The field number to change.</param>
        /// <param name="value">The entry value to set.</param>
        public EditDataPatchField(ITokenString entryKey, ITokenString fieldKey, TokenisableJToken value)
        {
            this.EntryKey = entryKey;
            this.FieldKey = fieldKey;
            this.Value    = value;

            this.Contextuals = new AggregateContextual()
                               .Add(entryKey)
                               .Add(fieldKey)
                               .Add(value);
        }
Esempio n. 9
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="operation">The text operation to perform.</param>
        /// <param name="target">The specific text field to change as a breadcrumb path. Each value in the list represents a field to navigate into.</param>
        /// <param name="value">The value to append or prepend.</param>
        /// <param name="delimiter">If the target field already has a value, text to add between the previous and inserted values, if any.</param>
        public TextOperation(TextOperationType operation, IManagedTokenString[] target, IManagedTokenString value, string delimiter)
        {
            this.Operation = operation;
            this.Target    = target.Cast <ITokenString>().ToArray();
            this.Value     = value;
            this.Delimiter = delimiter;

            this.Contextuals = new AggregateContextual()
                               .Add(target)
                               .Add(value);
        }
Esempio n. 10
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="operation">The text operation to perform.</param>
        /// <param name="target">The specific text field to change as a breadcrumb path. Each value in the list represents a field to navigate into.</param>
        /// <param name="value">The value to append or prepend.</param>
        /// <param name="delimiter">If the target field already has a value, text to add between the previous and inserted values, if any.</param>
        public TextOperation(TextOperationType operation, ICollection <IManagedTokenString> target, IManagedTokenString value, string?delimiter)
        {
            this.Operation = operation;
            this.Target    = target.ToArray <ITokenString>();
            this.Value     = value;
            this.Delimiter = delimiter ?? string.Empty;

            this.Contextuals = new AggregateContextual()
                               .Add(target)
                               .Add(value);
        }
Esempio n. 11
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="id">The unique key for the entry in the data file.</param>
        /// <param name="beforeID">The ID of another entry this one should be inserted before.</param>
        /// <param name="afterID">The ID of another entry this one should be inserted after.</param>
        /// <param name="toPosition">The position to set.</param>
        public EditDataPatchMoveRecord(ITokenString id, ITokenString beforeID, ITokenString afterID, MoveEntryPosition toPosition)
        {
            this.ID         = id;
            this.BeforeID   = beforeID;
            this.AfterID    = afterID;
            this.ToPosition = toPosition;

            this.Contextuals = new AggregateContextual()
                               .Add(id)
                               .Add(beforeID)
                               .Add(afterID);
        }
Esempio n. 12
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="name">The token name in the context.</param>
        /// <param name="input">The token input arguments.</param>
        /// <param name="values">The token values for which this condition is valid.</param>
        public Condition(string name, IManagedTokenString input, IManagedTokenString values)
        {
            // save values
            this.Name        = name;
            this.Input       = new InputArguments(input);
            this.Values      = values;
            this.Contextuals = new AggregateContextual()
                               .Add(input)
                               .Add(values);

            // init immutable values
            if (this.Values.IsReady)
            {
                this.CurrentValues = this.Values.SplitValuesUnique();
            }
        }
Esempio n. 13
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="name">The token name in the context.</param>
        /// <param name="input">The token input argument, if any.</param>
        /// <param name="values">The token values for which this condition is valid.</param>
        public Condition(string name, ITokenString input, ITokenString values)
        {
            // save values
            this.Name        = name;
            this.Input       = input;
            this.Values      = values;
            this.Contextuals = new AggregateContextual()
                               .Add(input)
                               .Add(values);

            // init values
            if (this.IsReady)
            {
                this.CurrentValues = this.Values.SplitValues();
            }
        }
Esempio n. 14
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="position">The tile position to edit, relative to the top-left corner.</param>
        /// <param name="layer">The map layer name to edit.</param>
        /// <param name="setIndex">The tilesheet index to apply, the string <c>false</c> to remove it, or null to leave it as-is.</param>
        /// <param name="setTilesheet">The tilesheet ID to set.</param>
        /// <param name="setProperties">The tile properties to set.</param>
        /// <param name="remove">Whether to remove the current tile and all its properties.</param>
        public EditMapPatchTile(TokenPosition position, IManagedTokenString layer, IManagedTokenString setIndex, IManagedTokenString setTilesheet, IDictionary <IManagedTokenString, IManagedTokenString> setProperties, IManagedTokenString remove)
        {
            this.Position      = position;
            this.Layer         = layer;
            this.SetIndex      = setIndex;
            this.SetTilesheet  = setTilesheet;
            this.SetProperties = setProperties?.ToDictionary(p => (ITokenString)p.Key, p => (ITokenString)p.Value);
            this.Remove        = remove;

            this.Contextuals = new AggregateContextual()
                               .Add(position)
                               .Add(layer)
                               .Add(setIndex)
                               .Add(setTilesheet)
                               .Add(remove);

            if (setProperties != null)
            {
                foreach (var pair in setProperties)
                {
                    this.Contextuals.Add(pair.Key).Add(pair.Value);
                }
            }
        }