Domain.GetDomainsById not working in Umbraco 6 - umbraco

I'm trying to get the language from the current node but are unable to get this working.
umbraco.cms.businesslogic.web.Domain.GetDomainsById(
umbraco.uQuery.GetCurrentNode().Id
).Id
This will return 0 at all times. Any advice where to start looking or are there other methods to acquire the current language id, thanks!

After some extensive digging in the well functioning dictionary classes I found the UmbracoCultureDictionary library that contains useful stuff like this
new umbraco.MacroEngines.UmbracoCultureDictionary().Language.id
Currently obsoleted and the referenced class Umbraco.Web.Dictionary.DefaultCultureDictionary is Internal, hence the following approach is probably the most compatible at the moment
umbraco.cms.businesslogic.language.Language.GetByCultureCode(
System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).id
umbraco.cms.businesslogic.language.Language.GetByCultureCode(
System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).FriendlyName
umbraco.cms.businesslogic.language.Language.GetByCultureCode(
System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).CultureAlias

Related

Vaadin: after upgrading to v23.0.1 (from 22.0.2): Error with Binder opening a Form

After upgrading to Vaadin 23.0.x (from former 22.0.2) I now keep getting the following error when opening a certain dialog:
2022-08-01 18:56:25,977 ERROR [http-nio-8085-exec-5] net.mmo.utils.kism.ui.views.nodes.NodeView: java.lang.IllegalStateException: All bindings created with forField must be completed before calling readBean
at com.vaadin.flow.data.binder.Binder.checkBindingsCompleted(Binder.java:3070)
at com.vaadin.flow.data.binder.Binder.readBean(Binder.java:2110)
at net.mmo.utils.kism.ui.views.nodes.NodeForm.readBean(NodeForm.java:487)
at net.mmo.utils.kism.ui.views.nodes.NodeForm.setNode(NodeForm.java:211)
This dialog has worked perfectly fine since I wrote it (using version 18.0.x about 2 years ago) and up to v22.0.2. I can't make sense of that error message and I don't understand what the issue could be here. I verified that issue going back and forth and the difference is really only the Vaadin version upgrade. Before it, the dialog works just fine and after it I get the above Exception when opening it.
I also can't quite believe what I think the message is stating here: if it would indeed check that I define or complete any bindings AFTER calling Binder.readBean() - how could it know that already in that very moment, i.e. when the code calls readBean() - as indicated by the stacktrace?
If there would indeed be any bindings being defined afterwards, IMHO it could only find that out AFTER said readBean()-call, i.e. when any additional bindings were actually defined, couldn't it?
So, could someone please try to "translate" or explain that issue or the background behind it to me?
The error basically states the problem: in the process of binding a field to a property (or getter/setter in general), the finishing step of actually binding was not undertaken. So the process was started with .forField() but never finished by .bind().
Since the error message as of now only states the fact, but not the culprit, a developer would be in need of a debugger to inspect the private state of the Binder, where the map incompleteBindings holds the current state of the Binder. The content of this map may help to find the culprit, e.g. by only holding one entry and by inspecting the flow of the program so far, that would conclude, what binding attempt failed. Or e.g. via the included field types.
Other than plain "bugs" by the developer, there are some potential reasons, why this suddenly happens by like an update or what places to look for:
multiple (re-)binding was recently added (e.g. to first bind "automatically" and then hand-tune the result); this holds potential, that older versions of the code just kept the initial binding and ignored the dangling second process.
the binding process uses a builder pattern; builder must build up on the result of the previous steps. This means, that in imperative code, there is the chance, that this chained call miss reassigning the build step. E.g.
var b = binder.forField(field)
if (predicate)
b.asRequired() // XXX: should be `b = b.asRequired()`
b.bind(...)
(this may or may not be a source for this kind of problem, but it's good to point out here, since the binder builder implementation actually switche(s|d) the builder (in the past)

How can I programmatically set the value inside a complex Map/List by a given path in Dart?

Here is an example on DartPad.
The example has the commentary but let me explain anyway. Suppose we have a quite complex Map<String, dynamic> or a List<dynamic>, e.g. it might contain an integer inside a map inside a list inside another map inside another list...
I get a path, which I called targetPath and is a List<dynamic>, defining where the target value is inside this complex data.
I'd like to change the value referred by this targetPath but have no idea how to do that.
How can I change a value inside a List/Map given by a path?
Thanks in advance.
Troubleshooting
I have looked up some solutions on the internet which have not been applicable in my situation but I'd like to put them here and state why they did not work in my case.
Merging Two Maps
Combine/merge multiple maps into 1 map
I have come across this while looking for it but my case has targetPath which is not applicable to this situation. The question has many answers but none of it covers my case.
Environment
Dart 2.15.1
Flutter 2.8.1 (if relevant)
Actually, I have found a package called deeply, which addresses the same issue I have at hand.
All the examples adress Maps though. However, I took a quick look at the implementation, which seems to be friendly with List type at the first glance.

VS2019 custom template - parent variable prefix (ext_) not working

I am trying to create a custom template for VS2019 comprised of multiple projects (based on this guide), and I'm having problems with the references.
My solution is based on the classic 3-tier architecture (data/business/ui), so when I create a new solution - call it "MySolution", I get "MySolution.Data", "MySolution.Business" and "MySolution.UI" - all good. I need the business layer to have a reference to the data layer - however, using the $ext_safeprojectname$ variable just gives me an unresolved reference in the projects node of my dependencies to "$ext_safeprojectname$.Data"
Other variables seem to work fine - for example, if I use $safeprojectname$, I get "MySolution.Business.Data" in my reference - correct parsing of the variable, for the business layer project, but not the desired result.
Has the ext_ prefix been replaced? I cannot seem to find any documentation for this anywhere.
Thanks!
I was able to solve it after commenting on your question. I was missing the CopyParameters=true attribute for ProjectTemplateLink element in the .vstemplate file. It is mentioned as a tip on Create a multi-project template from an existing solution. My ext_ variables were replaced once I did this. Your ProjectTemplateLink element should look something like below:
<ProjectTemplateLink ProjectName="MyProject" CopyParameters="true">...</ProjectTemplateLink>

Why does LambdaExpression.Compile() work on iOS (Xamarin)?

Since Xamarin.iOS doesn't support code generation at runtime, why do Compile() and DynamicInvoke() work as expected?
For example, the following code works fine:
var lambda = Expression.Lambda(
Expression.Add(
Expression.Constant(1),
Expression.Constant(2)
)
);
var f = lambda.Compile();
var result = f.DynamicInvoke();
// result==3 at this point
Is Xamarin evaluating the expression tree at runtime instead of emitting IL code?
On platforms that support code generation, Reflection.Emit-based LambdaCompiler is used.
If that's not available, the expression is interpreted using the interpreter. For example, there are classes that interpret Constant and Add.
The details of the Xamarin limitations are here.
You don't seem to be using anything in the Reflection.Emit namespace, which is the big no-no. Your code must still be AOT'd. Otherwise, I would imagine it would not work.
But there HAVE been examples of [native] developers thwarting the iOS static analysis tool and circumventing the dynamic code restriction. I tried to locate the article, but couldn't find it.
Anyway, I don't think your scenario exemplifies that. Your code example will still be AOT-compiled.
But you raise a really good question: at what time does the expression get evaluated?
EDIT:
Another SO answer on the same topic: What does Expression.Compile do on Monotouch?
There's also some good info on Expression.Compile() and "full AOT" here:
http://www.mono-project.com/docs/advanced/aot/
EDIT:
After reading some more, I think I know what's going on here. It's not that Expression.Compile() won't work...it's that when your iOS app bundle is subjected to the iOS static analysis tool when you submit it to the app store, it will not pass the analysis, because it is dynamically generating code. So, sure, you can use Expression.Compile(), but don't expect it to be accepted into the app store. But as mentioned by #svick, if you use the "full AOT" compile option, your Expression.Compile() will probably fail at runtime, or perhaps even fail compilation.

How can find what is included in the #containment annotation?

How can find what is included in the #containment annotation? I can not find that in the documentation online, that refers only to grammar-spec and nothing more? I'm talking about trying to obtain information/facts from the M3 model..
As an example:
scheme=="java+variable" or some other condition is used in a comprehesion to filter, how do you know what can be used to find certain thing??
Thanks
The documentation is not complete, but these pages are relevant:
http://tutor.rascal-mpl.org/Rascal/Libraries/lang/java/m3/m3.html#/Rascal/Libraries/analysis/m3/Core/Core.html
http://tutor.rascal-mpl.org/Rascal/Libraries/lang/java/m3/m3.html
I would also have a look at the code in these files:
https://github.com/cwi-swat/rascal/blob/master/src/org/rascalmpl/library/lang/java/m3/Core.rsc
https://github.com/cwi-swat/rascal/blob/master/src/org/rascalmpl/library/lang/java/m3/AST.rsc
They can be found in the rascal navigator view in Eclipse as well. In particular the core file contains all to know about the relations and locations in the java m3 model.

Resources