Code First Conventions - entity-framework-5

When using Entity Framework Code First in the mappings using the fluent api I can use Ignore to not map certain classes.
I have a convention where I start some of my classes with the characters Stub and Missing.
Is there a way in Entity Framework 5 Code First to set a convention that will not map ANY classes beginning with Stub* or Missing*?
I tried a search but was not able to find anything to help me with this.

Related

How does lab.antlr.org get the parser rule and alternative number?

I have been playing with ANTLR Lab (really nice by the way) and was wondering how it is able to label the matching parser rule and alternative number. For example, below content:1, x_tag:2 and x_tag:3 are all rule names and the number after the colon is the alternative within that rule.
I have built a recognizer from my grammar but cannot see from looking at the runtime API how to access them from within a custom listener.
AFAIK, ANTLR Lab and the ANTLR IntelliJ plugin both use the RuleContextWithAltNum to set and get the alternative.
Note that it is only implemented in Java. From the documentation:
A handy class for use with options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} that provides a backing field / impl for the outer alternative number matched for an internal parse tree node. I'm only putting into Java runtime as I'm certain I'm the only one that will really every use this.
Also see the related stackoverflow Q&A: Is there a way to know which alternative rule ANTLR parser is currently in?

Simple way to extend the default ApplicationDbContext in asp mvc5 using Ef6 Code First

When i run the entity framework Reverse Engineer Code First in an asp mvc project, it runs fine and generates all the mapping and poco classes, but i now have two context and conflicting classes in both the ApplicationDbContext and the new Auto Generated DbContext.
When generating EF Classes using Code First from Database, often there are more steps as the generated code is not always exactly as you want. I typically rename all files to "EntityNameDAO" I then right click refactor all classes to "EntityNameDAO" to match the file name appropriately.
After this, you will typically find that you have additional or less needs or perhaps even circular dependencies in the json result from these generated classes. To deal with this, I create specific domain objects for each objective EntityName_SpecificUseCase.
You will notice I use EntityName"AdditionalData" so that the alphabetic sorting keeps each of my entities next to eachother and I can verify I have the right flavors for each entity quickly and easily.
To deal with the circular json, you will need to add this code to your appconfig.cs:
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling =
Newtonsoft.Json.PreserveReferencesHandling.All;

How to create custom extension point in ReSharper plugin

We are working on plugin for ReSharper and we want to make our plugin extensible. Seems, we should use ShellComponent attribute to do it but we can not find any examples. Could anybody enplane how to define custom extension point and how to manage extension. Example of code of extension point and extension implementation would be very helpful.
Thanks.
If you're looking to write a plugin that can extend ReSharper, you need to tell ReSharper about the classes in your plugin, by marking them with the [ShellComponent] or [SoutionComponent] attributes. These attributes have different lifetimes - a shell component lasts the lifetime of ReSharper itself, and a solution component is created when a solution is opened and disposed when the solution is closed.
To make ReSharper do something useful with your components, they typically have to implement an interface, such as ICodeCompletionItemsProvider, and sometimes have to use a different attribute, such as [CodeCleanupModule] (which itself derives from ShellComponentAttribute). There are many extension points in ReSharper, and the one that's appropriate for you depends on what you're trying to do - refactoring, unit test provider, code cleanup, code completion items, etc. The devguide provides a good introduction to the more common extension points.
But if you want to make your own plugin extensible, then your component needs to work with a kind of provider pattern, by deferring work to multiple provider instances. For example, code cleanup works by deferring to multiple code cleanup modules, each responsible for cleaning up a different aspect of your code (whitespace, ordering, etc). To do this, your component should take in a collection of providers in the constructor. ReSharper's component model will automatically create a collection of these types and pass them to. More specifically, you should have a constructor that takes an IEnumerable<T> or IViewable<T>, where T is the interface of the provider you're going to define and call. The IEnumerable<T> will give you a simple collection of providers, but IViewable<T> represents an observable collection, and allows you to subscribe to notifications of new providers being made available from the component model.

How to add "Using " statement at runtime using IWizard

at compile time we have
using MyNamespace;
This works till now but recently the requirement got change and it needs to handle at run time based on the application type selected by the user.
So, How can I add the "Using" namespace statement using c# code in the IWizard?
I know how to add the reference at run time ass under
var appProject = project.Object as VSProject;
appProject.References.Add(Mydll);
What I want is that at runtime
using System.IO;
using MyNamespace-> should come at runtime based on the application selected
Thanks
I just hit a similar issue and while it is not exactly changing the namespace at run time it does all you to get objects etc from a different namespace at run time. If you want to be changing namespaces chances are you have classes with the same names and interfaces but different implementations otherwise your code would need to be changed. What you need to do if make a new lib and namespace that just contains the interfaces for all the classes you want to use. You then make the classes in the different namespaces inherit these interfaces so you can code your class to just use the interface not the particular implementation. Then to select the implementation to use at run time you use "Dependancy Injection" to choose the correct implementation to insert via config file or let some other part of your application configure the injection. Dependancy Injection can be a little hard to get started with but once you get your head around it, it will make your life a lot easier. Ninject is a nice easy dependancy injection framework to start with.

What is the use of ".# " in groovy?

What is the use of .# in groovy? Can anyone explain me with a code snippet?
Have you seen the official documentation? It contains nice code samples.
Essentially, when you use normal . operator, you access fields indirectly, using implicitly generated getters/setters. However, .# allows you to access the field directly, skipping getter/setter.
This can be useful when you want to avoid some additional logic implemented in getter/setter and change the field directly. Violates tons of OOP principles, but the authors of Groovy found this construct to be useful.
That's the Java Field operator (according to the documentation)
There are examples in the documentation.
It is also used for accessing attributes when you are parsing XML (again, there's an example if you follow that link).

Resources