Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added automated Load attributes #127

Merged
merged 6 commits into from
Nov 26, 2021
Merged

Conversation

Spartan322
Copy link
Collaborator

@Spartan322 Spartan322 commented Oct 23, 2021

Attribute Association (defaults to class unless specified otherwise)

  • ActionAttribute -> Action.PathfinderAction
  • AdministratorAttribute -> Administrator.BaseAdministrator
  • CommandAttribute -> Action<OS, string[]> (Any void (OS, string[]) method)
  • ComputerExecutorAttribute -> Replacements.ContentLoader.ComputerExecutor
  • ConditionAttribute -> Action.PathfinderCondition
  • DaemonAttribute -> Daemon.BaseDaemon
  • EventAttribute
    • If on class or struct checks for any static void (PathfinderEvent) methods
    • Else it only applies to a static void (PathfinderEvent) method
  • ExecutableAttribute -> Executable.BaseExecutable
  • ExtensionInfoExecutorAttribute -> Replacements.ExtensionInfoLoader.ExtensionInfoExecutor
  • GoalAttribute -> MisisonGoal
  • MissionExecutorAttribute -> Replacements.MissionLoader.MissionExecutor
  • OptionAttribute -> Options.Option (field or property)
  • PortAttribute -> Port.PortRecord (field or property)
  • SaveExecutorAttribute -> Replacements.SaveLoader.SaveExecutor

Additional Attributes

  • IgnorePluginAttribute: forces PathfinderAPI to ignore the entire assembly if placed on the assembly's plugin
  • IgnoreEventAttribute: forces Type related EventAttribute to ignore the specific valid method, does not prevent any EventAttribute on the method itself
  • OptionsTabAttribute: registers the plugin's default OptionsTab tag name if OptionAttribute would not designate a tag when placed on the plugin class

Extensions

Adds HacknetPlugin.GetOptionsTag() and HacknetPlugin.HasOptionsTag() for handling OptionsTabAttribute registry

AttributeManager

  • ReadAttributesFor is always called right before HacknetPlugin.Load
  • Guarantees that the plugin type and everything within it is always read first before any other type on definition in the assembly
  • Does recursively read nested types
  • Not effected by accessibility

@Spartan322 Spartan322 force-pushed the feature/load-attributes branch from 5a4727e to 6b6877b Compare October 26, 2021 00:55
@Spartan322 Spartan322 mentioned this pull request Oct 26, 2021
Spartan322 added a commit that referenced this pull request Nov 4, 2021
	Operates after all plugins are loaded
	Common use case is acting upon the plugin list
Added Load, PostLoad, and Unload events
	Enables organization and separation of load related behavior
	With #127 load behavior can be automated without a plugin Load method
	Load and PostLoad events run after their method counterparts
	Unload events run before its method counterpart
	PostLoad and Unload are patches to the related HacknetPlugin methods
	Load is patched to postfix HacknetChainloader.LoadPlugin
Added Assembly indexer getter to AssemblyAssociatedList
	Enables retrieving Assembly pure assembly lists
	Useful for Load events
Added EventManager.InvokeAssembly
	Used for Load events
EventManager's invoke behavior put into a central private static method
Added IgnorePluginAttribute to skip the plugin's assembly
Added OptionsTabAttribute for globally declaring the plugins OptionsTab Tag for OptionAttribute
Added OptionAttribute for registering an Options object
Added Meta.Load.HacknetPluginExtensions.GetOptionsTag to retrieve OptionsTab tag for plugin
AttributeManager.ReadAttributesFor is patched to prefix Plugin Loading
	Corrected to run right before Load is called
	Now patches HacknetChainloader with ILManipulator instead
Actually compile the Pathfinder.Meta.Load namespace
Made EventAttribute able to function on Types as well
	If an EventAttribute is on a type, checks type for any applicable event methods
	Valid methods are static void methods whose only parameter is of type PathfinderEvent
	Can ignore specific events for a auto-register with IgnoreEventAttribute
Renamed Meta.Load.ComputerExecutor to ComputerExecutorAttribute
@Spartan322 Spartan322 force-pushed the feature/load-attributes branch from 3cf0f1c to 79669ba Compare November 5, 2021 03:44
Check both instance and static members
Correct OptionAttribute throw messages
Make PortAttribute use PortRecord
Throw if EventAttribute is on a method that isn't static
Windows10CE pushed a commit that referenced this pull request Nov 8, 2021
* Added HacknetPlugin.PostLoad
	Operates after all plugins are loaded
	Common use case is acting upon the plugin list
Added Load, PostLoad, and Unload events
	Enables organization and separation of load related behavior
	With #127 load behavior can be automated without a plugin Load method
	Load and PostLoad events run after their method counterparts
	Unload events run before its method counterpart
	PostLoad and Unload are patches to the related HacknetPlugin methods
	Load is patched to postfix HacknetChainloader.LoadPlugin
Added Assembly indexer getter to AssemblyAssociatedList
	Enables retrieving Assembly pure assembly lists
	Useful for Load events
Added EventManager.InvokeAssembly
	Used for Load events
EventManager's invoke behavior put into a central private static method

* Fix incorrect directory for Load events

* Changed EventManager.InvokeAll and InvokeAssembly access to public
	Enables calling events, like for custom events
	Does not consider plugin ownership of the event
@Windows10CE Windows10CE merged commit 218043a into develop Nov 26, 2021
@Spartan322 Spartan322 deleted the feature/load-attributes branch May 2, 2022 08:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants