Ruby AOP in 12 lines of Code

First, we shim the Ruby Object class with a profiling aspect, in this case an additional method called profile that will wrap any existing method with timing code that we tell it to. Lets put this in a file called: aop_extension.rb. class Object   def Object.profile symbol     _symbol = (“rprof_” + symbol.to_s).to_sym     alias_methodContinue reading “Ruby AOP in 12 lines of Code”

Property getter/setter extraction from C# Types

The C# Expression API allows you to scrape property and method definitions from Types and work with them as external references.  See here: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Dynamic; using System.Runtime.CompilerServices; public static class Extensions  {        public static Func<X, T> GetPropertyFunction<X, T>(this Type source, string name) { ParameterExpression param = Expression.Parameter(typeof(X), “arg”);              MemberExpressionContinue reading “Property getter/setter extraction from C# Types”

My C# ObservableDictionary

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ComponentModel;using System.Collections.Specialized; namespace DynamicSpikes{    public class ObservableDictionary<String, Object> : Dictionary<string, object>, INotifyPropertyChanged, INotifyCollectionChanged    {         public event PropertyChangedEventHandler PropertyChanged = delegate { };        public event NotifyCollectionChangedEventHandler CollectionChanged = delegate { };         private void OnCollectionChanged(object sender, NotifyCollectionChangedAction action, object value)        {            if (CollectionChanged != null)            {                CollectionChanged(sender, new NotifyCollectionChangedEventArgs(action, value));            }        }         private void OnPropertyChanged(object sender, string propertyName)       Continue reading “My C# ObservableDictionary”