Tag | reflection Posts

I’ve had to look this up a couple of times, and there’s not much out there, so I end up guessing the same answer over and over. When using MethodBase.GetParameters() to get an array of ParameterInfo object, I often want to get a count of the number of parameters that are out, optional, params, etc. For out and optional, you can simply check ParameterInfo.IsOut or ParameterInfo.IsOptional or any number of other “Attributes”. However, for params, there isn’t a property on ParameterInfo. Instead, you ...
The .NET Framework allows you to easily add metadata to your classes by using attributes. These attributes can be ones that the .NET Framework already provides, of which there are over 300, or you can create your own. Using reflection, the ways to retrieve the custom attributes of a type are: System.Reflection.MemberInfo public abstract object[] GetCustomAttributes(bool inherit); public abstract object[] GetCustomAttributes(Type attributeType, bool inherit); public abstract bool IsDefined(Type attributeType, ...
In last few months i have been looking into a number of technologies, methodologies and tricks on how i can design and expedite the development of the EMR software. Some of the critical success factors of this EMR were extensibility because the institution has a huge research component and many research studies have various requirements and new ones come through anytime. Therefore, the EMR architecture is supposed to allow the developer to simply create a plug-in using a VS template and simply add ...
1. Introduction This is a follow-up to the "An attribute based approach to business object validation" article in which i introduced the use attributes and reflection to validate business objects. I also promised to write another article on data converters and method based validators, and here it is. 2. Background In this article i will use an example to show how you can validate your business object using a method based attribute and how you can convert data assigned to properties when it is saved ...
1. Introduction This article shows how you can use attributes to validate your business objects. You may have had to write tones of code to validate your business objects without taking advantage of attributes. The value of attributes comes when you need to apply the same rules on a number of properties and the only thing you have to do is to decorate your property accordingly. For other articles on attribute based validation please check the Visual Studio Magazine and Ennis Ray Lynch, Jr. 2. Background ...
Recently, I ran into a problem where I needed to cast from an unknown type to a known type. Normally this would be fine as I a generic cast. For example... 1 public static T ValueOf<T>( this OracleCommand command, string parameterName ) 2 { 3 return (T)command.Parameters[param... 4 } The parameter of course returns an object and I wanted to streamline the parameter value lookup process. All was well until I started using ODP.Net (instead of Microsofts OracleClient). With the OracleClient, ...
Hello everyone This is my first blog entry at this site and first in a couple of years, but I wanted to share something I created with some help. Since generics came out with VS 2005 I wondered if it were possible to create a completely generic data access layer. I also wanted to take advantage of some cool features like custom attributes, enterprise library, and reflection. One that could get and update objects regardless of the type of object being manipulated. With the help of some great authors ...
When we decided that ParaPlan 4.0 would be rebuilt in .NET (from Access), we decided not to redesign the SQL database. Even though we have some inefficiencies in our db we want to decrease development time and allow our beta testers to be able to switch back and forth between our Access front end and our .NET front end. As development began, we decided that we needed an object for each table and that we could eliminate some of the database inefficiencies in our objects. So we have an Appointment ...
I'm not being narcissistic, I just discovered tonight that I'll be able to save over 5000 lines of code on my current project using System.Reflection to internally populate an object from an external object of the same type. I'll post some code later so the true gurus can pick it apart. Technorati tags: Reflection, Justice Gray, ParaPlan, GoldStar ...