I'm following the docs from Microsoft for Globalization and Localization (.Net Core 3.0) and I leave the default language literal strings in the app and wrap them in the localizer. I'm also using a database for resources and I need to find a way to get all these strings from the assemblies and save them to the database. Is this possible?
lundi 4 novembre 2019
How to override private method
I am extending existing Java class which has some private method. And to achieve what I want, I have to to override this private method.
So I read something about Java reflection, and came out with the following:
class CustomSlider : Slider() {
init {
Slider::class.java.getDeclaredMethod("drawTrack", Canvas::class.java, Int::class.java, Int::class.java).isAccessible = true
}
override fun drawTrack(canvas: Canvas, width: Int, top: Int) {
}
}
But on the override
line, I'm getting an error that it's not possible.
So how can I do this?
PL/SQL Reflection Set Attribute Values
Here the link whose answer is the opposite to I want: Reflection in PLSQL? I want to do the opposite operation to that Jon Heller wrote in the link above. I mean, I want to set attributes of an object dynamically not manually (because my user-defined type object has 130 attributes and in my opinion, filling out some many attributes manually is not best practice and not generic programming. Does anybody know how we can accomplish that?
dimanche 3 novembre 2019
Sending Settings as JSON and using Reflection - SDK C#
I'm creating a plugin SDK for my application. There are some static settings that are common between all plugins. I'm using an interface here to force SDK developers to use all of these static settings.
But Every plugin also has its own different settings which I can not add them to the SDK. Instead of I have added a string property in the interface so User should implement it and send plugin settings as a string in JSON format and every plugin should load and convert it to its necessary class or settings using reflection.
Is this process right for this situation?
samedi 2 novembre 2019
Redirect Console.WriteLine for code loaded in new AppDomain
I'm trying to load .NET code from internet and execute it, e.g
AppDomain domain = AppDomain.CreateDomain("Test");
Assembly assembly = Assembly.Load(data);
It works perfectly, but is it possible to redirect Console.WriteLine from that assembly (not the current domain) to somewhere, so that I can collect it and send it via HTTP requests?
Dlang: get names of all superclasses for an instance as array
I can get the full class name of an instance with fullyQualifiedName, but how can I get the fullyQualifiedNames of all it's superclasses? Is it possible?
vendredi 1 novembre 2019
How get inner property value by reflection
I want to use the reflection to get the value from a class object. In this case, Rating is my main class which contains a property of Contribution class.
Following is the structure of my class
public class Rating
{
public string personal_client_id { get; set; }
public string risk_benefit_id { get; set; }
public string type { get; set; }
public string risk_event { get; set; }
public string value { get; set; }
public Contribution contribution { get; set; }
}
public class Contribution
{
public string from { get; set; }
public string value { get; set; }
}
Now I want the value from the contribution property like below.
var Rating = RatingObject.Where(x => x.personal_client_id == pcid).FirstOrDefault();
if (Rating != null)
{
Type type = Rating.GetType();
PropertyInfo propertyInfo = type.GetProperty("contribution");
var aa = propertyInfo.GetValue(Rating, null);
//aa has the Contribution property now but i don't know how can i get the property value from
this object
//Remember i dont want to do this **((Contribution)(aa)).from**
}
else
{
return "";
}
Please help!