• Mobile
  • Extensions
  • Releases
  • GitHub
  • Blog
  • Sponsor
Show / Hide Table of Contents
  • Home
  • Quick Start
  • Setup
    • Dependency Injection
    • Startup
    • Static Instances
    • iOS
    • Android
  • Configuration Extensions
  • Jobs
    • Setup
    • Create a Job
    • Querying, Cancelling, and Adhoc
    • Frequently Asked Questions
  • Bluetooth LE Client
    • Setup
    • Scanning
    • Peripheral
    • Best Practices
    • Manged Scanning
    • Managed Peripheral
  • Bluetooth LE Hosting
    • Setup
    • GATT
    • Advertising
  • Geofencing
  • GPS
    • Setup
  • Motion Activity
  • Local Notifications
    • Getting Started
    • Channels
  • Push Notifications
    • Getting Started
    • Native
    • Azure Notification Hubs
    • Firebase Messaging
    • One Signal
  • Beacons
    • Ranging
    • Monitoring (Background)
  • HTTP Transfers
    • Getting Started
    • Advanced
  • Framework
    • Getting Started
    • ViewModel
  • Sensors
    • Getting Started
    • Accelerometer
    • Ambient Light
    • Barometer
    • Compass
    • Gyroscope
    • Humidity
    • Magnetometer
    • Pedometer
    • Proximity
    • Temperature

Static Class Generation

Using Shiny without dependency injection is not only possible, it is quite easy to do. Do also you like the old plugin style of CrossPlugin.Current? Then you've come to the right document. You may be thinking, why not just include these as part of the package? Several reasons actually, first being - statics don't make as easily testable and the second, statics don't adhere to interfaces and Shiny is always evolving. I got tired of trying to keep things in sync. By adding a generation option, it makes things good for all of us.

Under the hood, you are still using dependency injection and you still need a startup file, BUT, you can have all of the static versions of each service generated in a project of your choice by simply adding the following to your assembly attributes:

[assembly: Shiny.GenerateStaticClasses("YourNamespace")]

After adding this attribute, perform a build. The Shiny source generator will now scan for all Shiny nuget packages that are referenced in this project and generate corresponding static classes for the main services.

// BEFORE
Shiny.ShinyHost.Resolve<IJobManager>().Run(...);

// AFTER
ShinyJobs.Run(...);

By adding this attribute, it will create static access classes for all of the Shiny services in the main namespace of the assembly you use the assembly attribute in.

<?! StaticClasses /?>

  • Improve this Doc
In This Article
Back to top Generated by DocFX