Com.Latipium.Core
2.0.1
See the version list below for details.
dotnet add package Com.Latipium.Core --version 2.0.1
NuGet\Install-Package Com.Latipium.Core -Version 2.0.1
<PackageReference Include="Com.Latipium.Core" Version="2.0.1" />
paket add Com.Latipium.Core --version 2.0.1
#r "nuget: Com.Latipium.Core, 2.0.1"
// Install Com.Latipium.Core as a Cake Addin #addin nuget:?package=Com.Latipium.Core&version=2.0.1 // Install Com.Latipium.Core as a Cake Tool #tool nuget:?package=Com.Latipium.Core&version=2.0.1
Latipium Core Framework
The core framework defined a way for modules to interact with each other without having to reference other modules at compile time or runtime. This way, there can be optional module dependencies and it will prevent many dependency problems. When using this framework, there should be no dependencies to anything other than this core framework and the .NET Core framework.
Examples
To run this example, clone the repository and run the following:
$ dotnet build Core.sln
$ dotnet run BinFolder Examples/ReadMe/bin/Debug/netcoreapp1.0/
Loading Alternate Module...
Loading Real Module...
Hello, world!
2 + 2 = 4
Is the module actually correct?: True
$ dotnet run BinFolder Examples/ReadMe/bin/Debug/netcoreapp1.0/
Loading Alternate Module...
Hello, world!
2 + 2 = 0
Is the module actually correct?: False
Other examples can also be run in a similar way.
AlternateModuleImplementation.cs
using System;
using Com.Latipium.Core;
namespace Examples.ReadMe {
[LatipiumExportClass("ModuleTest")]
public class AlternateModuleImplementation {
[LatipiumExport]
public bool IsValid {
get {
return false;
}
}
[LatipiumExport("Add")]
public int AddNumbers(int a, int b) {
return a - b;
}
[LatipiumPriorityMethod]
public static int DeterminePriority() {
return new Random().Next(100);
}
[LatipiumLoadMethod]
public void Load() {
Console.WriteLine("Loading Alternate Module...");
}
}
}
This class defined a module that can be loaded in place of ModuleExample
, but has a different implementation.
Anything that is a part of the public interface that other modules will call needs to be annotated with [LatipiumExport]
.
The DeterminePriority()
method allows it to randomly choose between this module and the ModuleExample
module.
IInterface.cs
using System;
namespace Examples.ReadMe {
public interface IInterface {
bool IsValid {
get;
}
}
}
This interface is for the module to be bound to in ObjectExample
.
This is just an alternate way than using the dynamic
binding for external modules.
If the members in the interface need to be named differently, add a [LatipiumImport("newName")]
to it.
LoaderExample.cs
using System;
using Com.Latipium.Core;
namespace Examples.ReadMe {
[LatipiumLoader]
public class LoaderExample {
[LatipiumImport("ModuleTest")]
public static dynamic Module;
[LatipiumLoadMethod]
public static void Load() {
Console.WriteLine("Hello, world!");
Console.WriteLine("2 + 2 = {0}", Module.Add(2, 2));
new ObjectExample();
}
}
}
This is a loader, so it is where the control enters the program.
The module is automatically imported to the static field Module
so that it can be used.
ModuleExample.cs
using System;
using Com.Latipium.Core;
namespace Examples.ReadMe {
[LatipiumExportClass("ModuleTest", 42)]
public class ModuleExample {
[LatipiumExport]
public bool IsValid {
get {
return true;
}
}
[LatipiumExport("Add")]
public int AddNumbers(int a, int b) {
return a + b;
}
[LatipiumLoadMethod]
public void Load() {
Console.WriteLine("Loading Real Module...");
}
}
}
This is the real implementation of the module, as opposed to the one in AlternateModuleImplementation
.
ObjectExample.cs
using System;
using Com.Latipium.Core;
namespace Examples.ReadMe {
public class ObjectExample : LatipiumObject {
[LatipiumImport]
public IInterface ModuleTest;
public ObjectExample() {
Console.WriteLine("Is the module actually correct?: {0}", ModuleTest.IsValid);
}
}
}
This is an object that can be constructed normally (not like a singleton like module are) and still has automatic imports.
If the object needed to extend another class, so it could not extend LatipiumObject
, just add the following:
public ObjectExample() {
LatipiumDependencies.Inject(this);
Console.WriteLine("Is the module actually correct?: {0}", ModuleTest.IsValid);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 is compatible. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 1.0
- Microsoft.NETCore.App (>= 1.0.5)
- System.Reflection.Emit (>= 4.3.0)
- System.Runtime.Loader (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.