protected BehaviorViewBindingBase(IApplicationContext context, IApplicationContextAccessible contextAccessible) { var behaviorNames = new List <String>(); var assembly = contextAccessible.GetType().Assembly; var types = assembly.GetTypes(); foreach (var type in types) { var attributes = type.GetCustomAttributes(false); foreach (var behaviorAttribute in attributes.OfType <BehaviorAttribute>()) { behaviorNames.Add(behaviorAttribute.Name); var behaviorType = behaviorAttribute.ViewModelName == null ? type : type.MakeGenericType(typeof(object)); var ctor = behaviorType.GetConstructor(new[] { typeof(IApplicationContext) }); if (ctor == null) { continue; } var obj = ctor.Invoke(new object[] { context }); Behaviors.Add(behaviorAttribute.Name, obj as IApplicationContextAccessible); } } }
protected BehaviorViewBindingBase(IApplicationContext context, IApplicationContextAccessible contextAccessible) { var behaviorNames = new List<String>(); var assembly = contextAccessible.GetType().Assembly; var types = assembly.GetTypes(); foreach(var type in types) { var attributes = type.GetCustomAttributes(false); foreach (var behaviorAttribute in attributes.OfType<BehaviorAttribute>()) { behaviorNames.Add(behaviorAttribute.Name); var behaviorType = behaviorAttribute.ViewModelName == null ? type : type.MakeGenericType(typeof(object)); var ctor = behaviorType.GetConstructor(new[] { typeof(IApplicationContext) }); if (ctor == null) continue; var obj = ctor.Invoke(new object[] { context }); Behaviors.Add(behaviorAttribute.Name, obj as IApplicationContextAccessible); } } }