reflection

Unable to get the “Add” method of a ColumnDefinitionCollection in UWP

三世轮回 提交于 2019-12-24 04:04:27
问题 In the context of a Windows Universal Application, and using reflection, I'm trying to get the Add method from a ColumnDefinitionCollection (the built-in type) So I use this: type.GetRuntimeMethods().First(info => info.Name == "Add"); BUT it returns null! It also happens with the Contains method. Both of them are defined in ICollection<T> ( IList<T> derives from it). However, if I define my own class deriving from IList<T> , it works perfectly. Then, how do I get a MethodInfo for the Add

Reading contents of a managed bean with reflection in a JSF application

╄→尐↘猪︶ㄣ 提交于 2019-12-24 03:41:36
问题 I want to print out the contents of a backing bean in an auto-generated way. So all the contents appear on a JSP. Is this possible anyhow? Thanks in advance, Daniel 回答1: One way to do this would be using the JavaBean API and a custom tag function. WEB-INF/tld/beans.tld: <?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"

Selection in GroupBy query with NHibernate with dynamic anonymous object

…衆ロ難τιáo~ 提交于 2019-12-24 03:38:08
问题 My main objective is to create a dynamic group by and use it in NHibernate. Consider this non dynamic example that works : _repository.Collection<User>().GroupBy(u => new { u.Active }).Select(s => s.Key, Count = s.Count()) Now, I create a dynamic object to generate the new { u.Active } part dynamically: private Expression<Func<T, object>> CreateGrouping<T>(IEnumerable<string> by) { var dynamicTypeForGroup = GetDynamicTypeForGroup<T>(by); var sourceItem = Expression.Parameter(typeof(T)); var

SSIS Script Component to remove '\0' charachers in CHAR(n) fields

坚强是说给别人听的谎言 提交于 2019-12-24 03:25:33
问题 I'm currently working on a database that have '\0' characters in fields. For instance the field Category CHAR(4) sometimes has value '\0\0\0\0' (4 zero characters) and sometimes ' ' (4 blank characters) I want to use a script component to individuate all the fields with this problem. I've written the following script, but it doesn't work since the C# converts the '\0\0\0\0' to an empty string. public override void Input0_ProcessInputRow(Input0Buffer Row) { Type rowType = Row.GetType();

2D Gaming - How to reflect a ball off the bat?

♀尐吖头ヾ 提交于 2019-12-24 03:12:33
问题 I am pretty new to XNA & game dev and stuck at ball reflection. My ball is reflecting once it hits the bat, but only in one angle, no matter which angle the bat is at. Here's the code: if (BallRect.Intersects(BatRect)) { Vector2 NormBallVelocity = Ball.velocity; NormBallVelocity.Normalize(); NormBallVelocity = Vector2.Reflect(Ball.velocity, NormBallVelocity); Ball.velocity = NormBallVelocity; } The ball is retracting its way back. How do I make it look like the ball is reflecting off the bat?

Dynamically load ASP.NET Page from DLL

心不动则不痛 提交于 2019-12-24 03:03:13
问题 I want to create a modular ASP.NET application. Something like, I have a main application that is just some kind of module loader. It only have the one "Default.aspx" page. And, based on the loaded modules, this page will create a menu and links to the pages found in the modules. I want the modules to be ASP.NET projects packed into dll. So, I want to drop that dll into the "Modules" folder of my main application, it will identify the module, and use reflection to load the modules, inspect

Create an object whose type is in a string parameter

杀马特。学长 韩版系。学妹 提交于 2019-12-24 02:44:38
问题 I have a TreeView, which contains nodes. When a user clicks on a node, corresponding CrystalReport document should be created and displayed. For example, names of my nodes are: "PeriodReport1", "PeriodReport2", "PeriodReport3". My CrystalReport documents are named same: "PeriodReport1", "PeriodReport2", "PeriodReport3". How can I create and display right type of crystal reports document? I could do something like this: select case reportName case "PeriodReport1" dim myReport as new

copy an attribute of a property from one instance to another instance (of a different type ) at runtime

我怕爱的太早我们不能终老 提交于 2019-12-24 02:23:31
问题 let's say I have 2 classes like this: public class Foo { [Required] public string Name {get;set;} } public class Bar { // put here [Required] at run-time public string Name {get;set;} } var foo = new Foo(); var bar = new Bar(); //copy the required from foo to bar is it possible to copy the attributes from foo to bar at run-time ? 回答1: The notion of "copying" attributes is out. However, you can do something meaningful in the code that checks if the attribute is applied. You could use another

Load a class from the users workspace

丶灬走出姿态 提交于 2019-12-24 02:13:16
问题 I´m writing an eclipse plugin which should show some information of an enum class. The new view should show all enum constants and the assigned values. The enum values are calculated in the constructor somehow and it is not obvious in the editor which value they will have at runtime. So that´s the motivation for the plugin. I have tried to access the class which is opened in the editor by the eclipse AST. That way I´m getting the enum constant names of that file but not the assigned values at

Load a class from the users workspace

时间秒杀一切 提交于 2019-12-24 02:13:10
问题 I´m writing an eclipse plugin which should show some information of an enum class. The new view should show all enum constants and the assigned values. The enum values are calculated in the constructor somehow and it is not obvious in the editor which value they will have at runtime. So that´s the motivation for the plugin. I have tried to access the class which is opened in the editor by the eclipse AST. That way I´m getting the enum constant names of that file but not the assigned values at