Changes

Jump to navigation Jump to search
Line 284: Line 284:  
:: A reference to the loaded data. For example, here's how to add or replace a specific entry to the above example:
 
:: A reference to the loaded data. For example, here's how to add or replace a specific entry to the above example:
 
:: <syntaxhighlight lang="C#">
 
:: <syntaxhighlight lang="C#">
public void Edit<T>(IAssetData asset)
+
 
{
+
    /// <inheritdoc cref="IContentEvents.AssetRequested"/>
  var editor = asset.AsDictionary<string, string>();
+
    /// <param name="sender">The event sender.</param>
  editor.Data["Key C"] = "Value C";
+
    /// <param name="e">The event data.</param>
}
+
    private void OnAssetRequested(object sender, AssetRequestedEventArgs e)
 +
    {
 +
        if (e.NameWithoutLocale.IsEquivalentTo("Location/Of/The/Asset"))
 +
        {
 +
            e.Edit(asset =>
 +
            {
 +
                var data = asset.AsDictionary<int, string>().Data;
 +
 
 +
                foreach ((int itemID, string itemData) in data)
 +
                {
 +
                    var editor = asset.AsDictionary<string, string>();
 +
                    editor.Data["Key C"] = "Value C";
 +
                }
 +
            });
 +
        }
 +
    }
 
</syntaxhighlight>
 
</syntaxhighlight>
  
528

edits

Navigation menu