When I stub out a test with CodeRush, it is automatically inserting a using statement for NUnit when I already have a using statement for MBUnit. Is there a way to change the default test framework used when using the templates? I was unable to find it if so.
In the templates you can change the default test namespace used. You can also add conditional logic to check if the project references MBunit.Framework, if so add the MBUnit.Framework using statement, else use Nunit.
Related
I want to use modules dynamically and I know their name, but creating a module and then applying using like this:
using PyPlot
a = Module(:Plots)
using a
will yield an excpetion telling me that a is not definied. Which is a very unintuitive error message, since when you do this on the repl you can use 'a' afterwards. Just in combination with using it tells you that it is not defined.
The error message is emitted by Base.require, so you should use using Main.a or using .a instead:
require(module::Symbol)
This function is part of the implementation of using / import, if a module is not already
defined in Main. It can also be called directly to force reloading a module, regardless of
whether it has been loaded before (for example, when interactively developing libraries).
...
When searching for files, require first looks for package code under Pkg.dir(), then tries paths
in the global array LOAD_PATH. require is case-sensitive on all platforms, including those with
case-insensitive filesystems like macOS and Windows.
Or just use module keyword to define a module on the fly:
module A
...
end
using A
For an existing module, you could also dynamically use it via eval(using module-name).
My ASP application in VB has many modules that I'd like to share with a WinForms VB application. But the VB.ASP modules have includes that won't be necessary, useful, or possible to include in the WinForms app. Can I use compiler directives to enable one file to work in both projects?
check out this question: VB.NET Preprocessor Directives it shows how you can use preprocessor directives
so, basically you need to include your files into Winforms app and in these files add lines like this:
#IF MYDEFINEFORASPNET Then
require/import/define functions which are only for .net
#End if
#if MYDEFINEFORWINFORM Then
require/import/function for only win form
#End if
define generic functions
another way to achieve this - refactor your code to move generic parts into separate dll, which can be used for both projects without recompiling
Self defined values is indeed one way, but I think I have another.
The _MYTYPE compilation constant is managed by Visual Studio, and contains "Windows", "Console", "Web", and similar specifics. And I can enclose IMPORTS statements inside the #If like so:
#If _MYTYPE = "Web" Then
Imports System.Web.HttpRequest
#End If
Refactoring does appear to the required to do this, unfortunately. They probably won't let me do that.
Tridion's user interface allows you to extend specific commands, which is a great way to modify the behavior of certain existing commands. In the configuration file of the editor this is done with a section like this:
<ext:commands>
<ext:command name="TextUnderline" extendingcommand="MyTextUnderline"/>
<ext:command name="TextStrikethrough" extendingcommand="MyTextStrikethrough"/>
I am working on a generic command extension class that can be used to modify the behavior of a number of commands:
<ext:commands>
<ext:command name="TextUnderline" extendingcommand="MyCommandExtension"/>
<ext:command name="TextStrikethrough" extendingcommand="MyCommandExtension"/>
So in this second configuration fragment, we have the same MyCommandExtension extending both TextUnderline and TextStrikethrough.
But now in the JavaScript for my MyCommandExtension, how can I determine which command was originally fired?
MyCommandExtension.prototype.isAvailable = function (selection, pipeline) {
...
console.log(this.properties.name);
...
};
In this scenario the this.properties.name will be logged as a less-than-useful-but-completely-correct:
"DisabledCommand"
I suspect that the information is available somewhere in the pipeline parameter, but haven't found it yet.
How can I find out the original command from MyCommandExtension?
Short answer: I couldn't.
I had to do something similar, and ended up having to extend various commands and set the "current" command as part of my "_execute" call (so I would now call _execute(selection, pipeline, originalCommand) for my command.
N
You cannot find out what the original command is. The assumption is that an extending command is specific to the command it extends and so would know which one it is extending. When creating generic extensions that work on different commands, I can see how it might be useful to know what the configuration would be.
Maybe you could add this as an Enhancement Request?
To work around it for now, you could create a base command with your logic - which takes the name of the command that it extends as a parameter. And then create specific classes for each command you which to extend, which just call the base command and pass in the name.
To put it differently, create a BaseExtendingCommand with all of the required methods - and then both a TextUnderlineExtendingCommand and TextStrikethroughExtendingCommand which call the methods on BaseExtendingCommand (and pass in "TextUnderline" and "TextStrikethrough", respectively, as arguments)
I need to access data from pre-existing tables. I've started working my way through creating a module to display the data etc. However, Orchard is prefixing the table commands with the 'Table_Prefix' and 'Module Name'.
Is there any way I can specify what table to bind the model, so that I can use the existing IRepository
I'm trying to steer clear of modifying the core code, or implement my own IRepository ( which I've got a feeling is what I'm going to have to do.)
Thanks in advance.
You can create custom table naming convention (so that it would fit your current naming) by altering the core code, in three ways:
Record name mapping is created in BuildRecord method of
CompositionStrategy class
(Orchard.Framework/Environment/ShellBuilders/CompositionStrategy), so you can simply modify the code here.
By altering the Apply method of Orchard.Data.Conventions.RecordTableNameConvention class. This is where the record table name mappings (built in point 1.) get pushed to NHibernate.
Create your own implementation of FluentNHibernate.Conventions.IClassConvention (similar to RecordTableNameConvention mentioned above and replace the default one used by AutoMap in Orchard.Data.Providers.AbstractDataServicesProvider's CreatePersistenceModel(...) method with it.
You could also create your own IDataServicesProvider implementation, but that would surely be an overkill if you only need to change the table naming convention.
I was modifying CompositionStrategy and discovered that you have to modify the following
1. SetupService.cs (Modules\Orchard.Setup\Services):
Tables hardcoded in the Setup method are
"Orchard_Framework_DataMigrationRecord" and
"Settings_ShellDescriptorRecord"
2. InfosetController.cs (Modules\Upgrade\Controllers):
Multiple tables were hardcoded in this class which need to be updated.
3. DataMigrationManager.cs (Data\Migration):
Replace the SchemaBuilder parameters to the contructor.
OK my project uses an xml file called Chart-app.xml inside this XML file there is a tag called <version></version> which I keep in the format like: <version>1.2.128</version> I am wondering if I can set it to append to the third number every time I run my project.
So if I ran it now it would be 1.2.129, then if i ran it again it would be 1.2.130
Thanks!!
After reading VonC's answer I don't know anything about ANT or creating custom builds, but he did give me an idea that seems to be working:
I already have a method to tell if the app is running in the ADL (within eclipse), so if it is, I just have my app open the file itself and change the value.
I am not sure there is a native Eclipse way to do this.
You can increment the number within that xml file either:
programmatically, launching a special class which do that, and then call your primary application Class
through a dependency during launch, for instance, you can make a JUnit test suite which will first call a Java class doing the increment, and then call your main method.
But in both case, you would have to somehow code the increment process.
Note: it is easier when you want to increment something each time you build, because you can add a custom builder.