Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi every one
 
I'll try to keep this short, my problem is i'm making some kind of a "game" (maybe more of an engine?) and the whole idea in what i try to make is that i have made everything ready for others to do, in other words you make your own game but i have made some basic things ready to use, maybe a little like minecraft, where you have some basic stuff but can add mods to it easily.
 
what i'm thinking is to make some class partial, e.g. i have a input system and i wanna have my own stuff there with some basic movement, but i wanna let the "modders" have the ability to add their own inputs by using a partial class and "simply" load every mod into the solution and just extend the input system with the user made partial class.
 
now here is the problem i honestly have no clue how i can add this class into the solution at runtime and still make it possible for the program to find these classes and use them as if they're partial/extender to my main input class.
 
so is this possible and how? code simples and sources would be lovely.
 
or if there is a better way of doing this, how?
 
or if it isn't possible, is there any other way i can make it work just the same?
 
Thanks for reading i appreciate you time and help Smile | :)
 
- Jackie
 
EDIT:
 
fast update: it just came to my mind i could also just load an assembly, however i feel this might be much more advance and it would also require the player/"modder"/stuff to compile every thing to a dll or exe which i really just wanna try to avoid since i wanna keep it simple for the modder/player so he can go right ahead in notepad or something.
 
an other one also go abit advance since this will require to almost make a whole new language which i REALLY wanna avoid, i can go in on a ini file scanner maybe but please no more here Smile | :)
 
Edit:
 
Ps. im using mono development for this game so the solution should be multi platform usable if possible.
Posted 2-Jun-12 18:01pm
Edited 2-Jun-12 20:44pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The concept of partial class has nothing to do with run time. The question makes no sense.
 
To understand what partial declaration does, read carefully: http://msdn.microsoft.com/en-us/library/wa80x488.aspx[^].
 
It looks like you do not really understand what a project build does, how the application is compiled, loaded and executed.
 
When you learn it, you will be able to pose the valid questions and learn the advanced matter that you may need.
 
Basically, you might need to implement and use some pluggability feature. Please see my past answers on the topic:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^],
code generating using CodeDom[^],
Create WPF Application that uses Reloadable Plugins...[^],
Dynamically Load User Controls[^],
C# Reflection InvokeMember on existing instance[^],
Projects and DLL's: How to keep them managable?[^].
 
You might also consider using MEF. Please see:
http://en.wikipedia.org/wiki/Managed_Extensibility_Framework[^],
http://mef.codeplex.com/[^].
 
It is possible that some simpler technique can suite your application goals, but then you would need to explain them properly. You would need some important skill of isolation of functional requirements from the possible technical solutions; that could help you to avoid loosing the ability to choose right solution due to wrong ideas you might be preoccupied with.
 
—SA
  Permalink  
Comments
Jackssen at 3-Jun-12 1:41am
   
i do know how partial works, you ca split classes up in multiple files, but i wanted to know if you from you program could load and use a class that just add user diff. stuff into an already existing file that way... :)
SAKryukov at 3-Jun-12 2:01am
   
Even if you know that, you might not understand what "load" means. You can load assembly, you can generate and load assembly during run-time, you can create a DynamicMethod during run-time, but not "extend" a type. If you just analyzed documentation and syntax, from one hand, and the documentation on the life cycle of the process, you would see it.
--SA
Jackssen at 3-Jun-12 8:57am
   
"but not "extend" a type" aaah okay thanks for answer
Jackssen at 3-Jun-12 1:43am
   
Ow yea i all forgot, im using mono for this game so the solution should be multi platform useable.
SAKryukov at 3-Jun-12 2:04am
   
We are discussing the topics where there is no essential difference between Mono and .NET. Everything I have written about on related topics works on Mono as well. I regularly test many my codes on Mono for Windows and Linux, also worked with Mac OS X.
--SA
Jackssen at 3-Jun-12 9:00am
   
do you know a way to execute/compile code on the fly in mono then? what i get from google is codedom is not an option in mono.
SAKryukov at 16-Jun-12 22:38pm
   
Yes, I do. Exactly the same way as in .NET, through Reflection. Both Mono and .NET are SLR implementation, and they both implement the libraries standardized via ECMA:
 
http://msdn.microsoft.com/en-us/netframework/aa569283.aspx
 
Reflection lies in the very fundamentals of CLR, so it works on both. I have actually done very advanced development based not only on System.Reflection, but also on System.Reflection.Emit, tested it all on Mono, everything worked for me.
 
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 3 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100