Just poking around the umbraco core (to see how delegate stuff is done.... in short complex)
There is a "WeightedPluginAttribute" class in Umbraco.Core.ObjectResolution, that i think is used someway to weight the execution of types (including IApplicationBase)
defaultpluginweight appears to be 10 in Umbraco.Core.ObjectResolution.ManyObjectsResolverbase.
uSync doesn't set this value - if you hooked into IApplicationEventHandler and weight your thing at 11 - it would fire after uSync?
Option C: a usync version somewhere in a file, usync reads from disk, if the version matches it doesn't continue. just a question of where to store the version ? probibly in a datatype?
Regarding events, you could create a before and after event. Just normal events. Nothing special.
As a wild alternative... have usync set the "read" config to false after 1st load. As a developer, I would have to set it to false after it installs everythign anyway... otherwise my app start is 3mins.
latest version of uSync (1.2.0) has the usync.once file method in it.
if the usync folder has a file at the root called usync.once. then at the end of a read it will be renamed usync.stop.
if their is a usync.stop file then the read will not happen at startup.
I've also seperated out (but not tested in anyway!) the three primary functions of usync into public methods.
so in theory in umbraco (somewhere?) you could:
jumps.umbraco.usync.uSync syncObj = new uSync();
syncObj.ReadAllFromDisk();
syncObj.SaveAllToDisk();
syncObj.AttachToAll();
not sure if you would ever want to.. but in theory you can, these functions when called like this ignore what the config file says, so you could in theory turn usync off and call it programatically - again i haven't actually tested this yet.
next step put in a usync.webservice.dll - but i might just wait a little while :)
Programatically disable uSync
Possibly an odd request.
I'm just wondering if it's possible to programatically disable uSync after it has done it's magic of installing new doctypes, datatypes etc?
The reason being that we want to provide new doctypes etc to a client, but have uSync disabled automatically so consequenting app starts are not slow.
with no changes
you could change the config ? /config/usyncsettings.config.
Assuming it's for delivery only - you would have Read="true" and everything else set to false.
You could load the config and then change this to "false" once the data types are delivered ?
Possible things i could enhance
uSync doesn't have a post load run code thing in it - but that might be an idea ? i could put in a IUSyncBase class with before and after delegates ?
you could then write a class that would trigger before and after usync ran. i might do that at some point ?
"You could load the config and then change this to "false" once the data types are delivered ? "
Yeah the question is how do I hook into that? Would I have to bind to each "new" event? That woudl be messy.
"i could put in a IUSyncBase class with before and after delegates"
That would definitely take care of it.
Just poking around the umbraco core (to see how delegate stuff is done.... in short complex)
There is a "WeightedPluginAttribute" class in Umbraco.Core.ObjectResolution, that i think is used someway to weight the execution of types (including IApplicationBase)
defaultpluginweight appears to be 10 in Umbraco.Core.ObjectResolution.ManyObjectsResolverbase.
uSync doesn't set this value - if you hooked into IApplicationEventHandler and weight your thing at 11 - it would fire after uSync?
Option C: a usync version somewhere in a file, usync reads from disk, if the version matches it doesn't continue. just a question of where to store the version ? probibly in a datatype?
Continued brain dump!
sync.once in the root of usync.
if present, usync renames to sync.stop at end of process.
if sync.stop is present no sync happens.
?
Are you talking about the version table?
Regarding events, you could create a before and after event. Just normal events. Nothing special.
As a wild alternative... have usync set the "read" config to false after 1st load. As a developer, I would have to set it to false after it installs everythign anyway... otherwise my app start is 3mins.
i'm liking the usync.once and usync.stop file. it lets you deploy it with the files and without code.
"it lets you deploy it with the files and without code. "
What do you mean?
A 'deployment' could be
Could that be acheived with a flag in the config?
latest version of uSync (1.2.0) has the usync.once file method in it.
if the usync folder has a file at the root called usync.once. then at the end of a read it will be renamed usync.stop.
if their is a usync.stop file then the read will not happen at startup.
I've also seperated out (but not tested in anyway!) the three primary functions of usync into public methods.
so in theory in umbraco (somewhere?) you could:
not sure if you would ever want to.. but in theory you can, these functions when called like this ignore what the config file says, so you could in theory turn usync off and call it programatically - again i haven't actually tested this yet.
next step put in a usync.webservice.dll - but i might just wait a little while :)
nice work!
is working on a reply...