public IEnumerable<ActionCall> FindActions(TypePool types) { var awesomeEntities = (from entities in types.TypesMatching(AwesomeConfiguration.AwesomeEntities) where entities.IsConcrete() select entities).ToList() .Distinct(); var openHandlers = new[] { typeof (RestfulCreateHandler<>), typeof (RestfulPatchHandler<>), typeof (RestfulDeleteHandler<>), typeof (RestfulFindHandler<>), typeof (RestfulIndexHandler<>), typeof (AwesomeCreateHandler<>), typeof (AwesomeEditHandler<>) }; foreach (var awesomeEntity in awesomeEntities) { foreach(var openHandler in openHandlers) { var closedHandler = openHandler.MakeGenericType(awesomeEntity); var closedMethod = closedHandler.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance); //should drive from RestfulHandler guard(closedHandler, closedMethod); yield return new ActionCall(closedHandler, closedMethod); } } }
public IEnumerable<ActionCall> FindActions(TypePool types) { var actionCalls = new List<ActionCall>(); var viewModels = types.TypesMatching(t => IsAssignableFromGenericInterface(typeof(IEntityUpdateable<>), t)); foreach (var viewModel in viewModels) { Type entityType = null; foreach (Type interfaceType in viewModel.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntityUpdateable<>)) { entityType = interfaceType.GetGenericArguments().Single(); break; } } Type queryType = typeof(SaveHandler<,>).MakeGenericType(viewModel, entityType); MethodInfo retrievalMethod = queryType.GetMethod("Save"); actionCalls.Add(new ActionCall(queryType, retrievalMethod)); } return actionCalls; }
public void Configure(IServiceRegistry services) { var matchedTypes = _types.TypesMatching(_typeFilters.Matches); _conventions .Each(convention => convention.Register(matchedTypes, services)); }
public IEnumerable<ActionCall> FindActions(TypePool types) { return types.TypesMatching(t => t.Name.EndsWith("Endpoint") || t.Name.EndsWith("Endpoints")) .SelectMany(type => { var methods = type.GetMethods().Where(ActionSource.IsCandidate); return methods.Select(m => new ActionCall(type, m)); }); }
public IEnumerable<IViewToken> FindViews(BehaviorGraph graph) { var types = new TypePool(); types.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies()); types.IgnoreExportTypeFailures = true; return types.TypesMatching(t => t.IsConcrete() && t.Closes(typeof (FubuHtmlDocument<>)) && !t.Equals(typeof(FubuHtmlDocument<>))) .Select(t => new HtmlDocumentViewToken(t)); }
public IEnumerable <ActionCall> FindActions(TypePool types) { return(types.TypesMatching(t => t.Name.EndsWith("Endpoint") || t.Name.EndsWith("Endpoints")) .SelectMany(type => { var methods = type.GetMethods().Where(ActionSource.IsCandidate); return methods.Select(m => new ActionCall(type, m)); })); }
public IEnumerable<ActionCall> FindActions(Assembly applicationAssembly) { var types = new TypePool(); types.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies()); types.IgnoreExportTypeFailures = true; return types.TypesMatching(type => type.IsConcreteTypeOf<ILookupProvider>()).Select(type => { var method = GetLookupMethod(type); return new ActionCall(type, method); }); }
public IEnumerable<IViewToken> FindViews(TypePool types) { IEnumerable<Type> actionTypes = types.TypesMatching(_sparkActionEndPointConventionFilter); var viewTokens = new List<IViewToken>(); actionTypes.Each(actionType => { var sparkBatchEntry = new SparkBatchEntry {ControllerType = actionType}; IList<SparkViewDescriptor> descriptors = _viewFactory.CreateDescriptors(sparkBatchEntry, _getActionNameFromCallConvention); viewTokens.Add(new SparkViewToken(descriptors)); }); return viewTokens; }
public IEnumerable<Type> FindApplicationSourceTypes(ApplicationSettings settings) { var assemblies = AssembliesFromApplicationBaseDirectory(x => true); if (!assemblies.Any()) { var assemblyName = Path.GetFileName(settings.GetApplicationFolder()); assemblies = AssembliesFromApplicationBaseDirectory(x => x.GetName().Name == assemblyName); } var types = new TypePool {IgnoreExportTypeFailures = true}; types.AddAssemblies(assemblies); return types.TypesMatching(x => x.CanBeCastTo<IApplicationSource>() && x.IsConcreteWithDefaultCtor()); }
public static IEnumerable<IFubuRegistryExtension> FindAllExtensions() { if (!PackageRegistry.PackageAssemblies.Any()) return new IFubuRegistryExtension[0]; var pool = new TypePool(null); pool.AddAssemblies(PackageRegistry.PackageAssemblies); // Yeah, it really does have to be this way return pool.TypesMatching( t => hasDefaultCtor(t) && t.GetInterfaces().Any(i => i.FullName == typeof (IFubuRegistryExtension).FullName)) .Select(buildExtension); }
public IEnumerable<IViewToken> FindViews(TypePool types) { IEnumerable<Type> actionTypes = types.TypesMatching(_actionEndPointFilter); var viewTokens = new List<IViewToken>(); actionTypes.Each(actionType => { var sparkBatchEntry = new SparkBatchEntry { ControllerType = actionType }; string viewLocatorName = _getViewLocatorNameFromActionType(actionType); IList<SparkViewDescriptor> descriptors = _viewFactory.CreateDescriptors(sparkBatchEntry, viewLocatorName); viewTokens.Add(new SparkViewToken(descriptors)); }); return viewTokens; }
public IEnumerable<ActionCall> FindActions(TypePool types) { var methodName = ReflectionHelper.GetMethod<ChannelWriter<Topic>>(x => x.Write(null)) .Name; var topicTypes = types.TypesMatching(x => x.IsConcreteTypeOf<Topic>()); foreach (var topicType in topicTypes) { var handlerType = typeof (ChannelWriter<>).MakeGenericType(topicType); var method = handlerType.GetMethod(methodName); yield return new ActionCall(handlerType, method); } }
public void Configure(BehaviorGraph graph) { var rules = graph.Settings.Get <AccessorRules>(); var types = new TypePool(null); types.AddAssemblies(graph.Types.Assemblies.Union(PackageRegistry.PackageAssemblies)); types.TypesMatching(x => x.CanBeCastTo <IAccessorRulesRegistration>() && x.IsConcreteWithDefaultCtor()). Distinct().Select(x => { return(Activator.CreateInstance(x).As <IAccessorRulesRegistration>()); }) .Each(x => x.AddRules(rules)); graph.Services.AddService(rules); }
public IEnumerable<ActionCall> FindActions(TypePool types) { var stateMachines = types.TypesMatching(t => t.Closes(typeof (StateMachine<>))); foreach(var sm in stateMachines) { //TODO: Where can I load things into the container - using ObjDef? var machine = (StateMachine)Activator.CreateInstance(sm); var t = typeof (StateMachineOptionsAction<>).MakeGenericType(sm); var ta = new ActionCall(t, t.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)); yield return ta; //need to fix this //current state? var tt = typeof(StateMachineInstanceOptionsAction<>).MakeGenericType(sm); yield return new ActionCall(tt, tt.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)); var ttt = typeof(StateMachineCurrentStateAction<>).MakeGenericType(sm); yield return new ActionCall(ttt, ttt.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)); foreach (var @event in machine.Events) { //need to track the event name //between here and the event url generation //so I used a custom ActionCall extension var eventName = @event.Name; var tttt = typeof (StateMachineRaiseSimpleEventAction<>).MakeGenericType(sm); var eventType = @event.GetType(); if (eventType != typeof (SimpleEvent)) { tttt = typeof (StateMachineRaiseDataEventAction<,>).MakeGenericType(sm, eventType); } var call = new EventActionCall(eventName, tttt, tttt.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)); yield return call; } yield break; } }
public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log) { var pool = new TypePool(); pool.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies()); pool.IgnoreExportTypeFailures = true; pool.TypesMatching(type => type.IsConcreteWithDefaultCtor() && type.CanBeCastTo<TopicRegistry>()) .Each(type => { // All we have to do is create it to work Activator.CreateInstance(type); }); TopicGraph.AllTopics.All().Each(node => { node.Url = _urls.UrlFor(node.TopicType); if (!node.Url.StartsWith("/")) { node.Url = "/" + node.Url; // has to be an absolute } }); }
public IEnumerable<ActionCall> FindActions(TypePool types) { var actionCalls = new List<ActionCall>(); var viewModels = types.TypesMatching(t => t.Name.EndsWith("ViewModel")); foreach (var viewModel in viewModels) { object[] attributes = viewModel.GetCustomAttributes(typeof(EntityTypeAttribute), false); if (attributes.Length == 0) continue; var attribute = attributes[0] as EntityTypeAttribute; Type handlerType = typeof(ListingHandler<,>) .MakeGenericType(viewModel, attribute.EntityType); MethodInfo retrievalMethod = handlerType.GetMethod("Retrieve"); actionCalls.Add(new ActionCall(handlerType, retrievalMethod)); } return actionCalls; }
public IEnumerable<Type> Find() { var list = new List<string> { AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; string binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; if (binPath.IsNotEmpty()) { if (Path.IsPathRooted(binPath)) { list.Add(binPath); } else { list.Add(AppDomain.CurrentDomain.SetupInformation.ApplicationBase.AppendPath(binPath)); } } var assemblies = list.SelectMany(x => AssembliesFromPath(x)); var pool = new TypePool(); pool.IgnoreExportTypeFailures = true; pool.AddAssemblies(assemblies); return pool.TypesMatching(x => x.IsConcreteTypeOf<IApplicationSource>() && x.IsConcreteWithDefaultCtor()); }
public IEnumerable <ActionCall> FindActions(TypePool types) { return(types.TypesMatching(_typeFilters.Matches).SelectMany(actionsFromType)); }
public IEnumerable<ActionCall> FindActions(TypePool types) { return types.TypesMatching(_typeFilters.Matches).SelectMany(actionsFromType); }
public IEnumerable<IViewToken> FindViews(TypePool types) { return types .TypesMatching(IsWebFormView) .Select(x => new WebFormViewToken(x) as IViewToken); }
public IEnumerable<Type> GetHandlers() { var pool = new TypePool(); _actions.Do(pool); return pool.TypesMatching(_filter.MatchesAll); }