Com.Latipium.Core 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Com.Latipium.Core --version 2.0.0                
NuGet\Install-Package Com.Latipium.Core -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Com.Latipium.Core" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Com.Latipium.Core --version 2.0.0                
#r "nuget: Com.Latipium.Core, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Com.Latipium.Core as a Cake Addin
#addin nuget:?package=Com.Latipium.Core&version=2.0.0

// Install Com.Latipium.Core as a Cake Tool
#tool nuget:?package=Com.Latipium.Core&version=2.0.0                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 1,126 1/3/2018
2.0.2 1,043 1/1/2018
2.0.1 1,204 12/31/2017
2.0.0 1,091 12/23/2017
1.0.3.2 1,104 12/23/2016
1.0.2.15 959 11/24/2016
1.0.0.17 968 11/23/2016
0.0.18.2 987 11/23/2016
0.0.16.3 1,057 11/22/2016
0.0.15.6 999 11/22/2016
0.0.14.3 957 11/22/2016