CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of reflection
C#
public static class TypeEx
{
    public static string GetFriendlyName(this Type t)
    {
        using (var provider = new CSharpCodeProvider())
        {
            var typeRef = new CodeTypeReference(t);
            return provider.GetTypeOutput(typeRef);
        }
    }
by bnaya   January 10, 2012 @ 3:21am
28 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using FizzWare.NBuilder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace Tests.Reporting
{
    [TestClass]
    public class DynamicXmlFormatting
128 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace Tests.Reporting
{
    [TestClass]
    public class DynamicTextFormatting
    {
137 Views
no comments
 
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
 
namespace ConsoleApplication1
{
  public class Program
by Eric Williams   November 09, 2010 @ 5:33am
274 Views
no comments
 
C#
// usage
class Person {
    ICollection<Address> Addresses { get; set; }
}
 
person.Ensure(p => p.Addresses);
 
// implementation
public static class Crap
{
by John Nelson   October 12, 2010 @ 10:36am
135 Views
1 comments
 
C#
/// <summary>
/// Return all properties from a type up to a specified base type in the inheritance hierarchy
/// </summary>
/// <param name="type">Type that will be examined</param>
/// <param name="baseType">Where to stop in the inheritance hierarchy. Must be a type that first parameter inherits from
/// </param>
/// <returns>A list of all found properties</returns>
public static List<PropertyInfo> GetAllProperties(Type type, Type baseType)
{
   List<PropertyInfo> properties = new List<PropertyInfo>();
by Robert Andersson   March 11, 2010 @ 12:25pm
293 Views
no comments
 
C#
/// <summary>
/// Turns a string into a typed value generically.
/// Explicitly assigns common types and falls back
/// on using type converters for unhandled types.         
/// 
/// Common uses: 
/// * UI -&gt; to data conversions
/// * Parsers
/// <seealso>Class ReflectionUtils</seealso>
/// </summary>
by Rick Strahl   January 08, 2010 @ 4:21pm
1280 Views
no comments
 
C#
// create instance of class DateTime
DateTime dateTime = (DateTime)Activator.CreateInstance(typeof(DateTime));
 
// create instance of DateTime, use constructor with parameters (year, month, day)
DateTime dateTime = (DateTime)Activator.CreateInstance(typeof(DateTime),
                                                       new object[] { 2008, 7, 4 });
 
 
//namespace Test
//{
by KMS   December 23, 2009 @ 9:25am
215 Views
no comments
 
C#
typeof ( WebPartChrome ).GetMethod ( "RenderVerbsInTitleBar", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).Invoke ( this, new object[] { writer, webPart, 1 } ); 
by Athens Springer   October 29, 2009 @ 7:36am
215 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate