StructureMap scan assemblies from every folder within a given directory - structuremap

I have a mvc project and in the bin folder i have an plugin folder and it look like this
/bin/
/plugin
/plugin1
/plugin2
and i what to scan with structure map every assembly in plugin folder
i've try with AssembliesFromPath but is not loading any assembly.
How can i load all the assembly from every directory within plugin folder ?

StructureMap doesn't recursively search a path, so you just need to call AssembliesFromPath on each of the paths that contain your plugins (ex: bin\plugin\plugin1, bin\plugin\plugin2).
Of course you don't need to hardcode in all of the subdirectories. StructureMap registration code is c#, which means you can use the language constructs. Call Directory.GetDirectories() on your bin\plugin to get the list of subdirectories, and then just loop over them within your Scan() clause to call AssembliesFromPath on each subdirectory.

Related

Ant Pitest Subdirectories targetClasses property

My code works perfectly like this.
But I want to remove "org.apache.commons.lang3.*" (Whole address) and just write * so it can get all files in the current folder and subdirectories. I wanted to make my code work on different projects and don't want to change it again and again. I want to make it universal. I just want to point to the target folder and let it get all files in the folder and subdirectories files. So far I have tried:
( .**.* ) ( .* ) (.* / ) (.* \ )
Any clue how to do this?
This is not currently possible with the pitest Ant plugin. The globs are matched against all classes in the classpath, so using an 'everything' glob results on all classes being instrumented.
If no glob is supplied to the pitest maven plugin, it will scan the source directories and construct a filter based on the packages found there. There is no plan to port this functionality to Ant.

Project level environment variable in source path

I'd like to specify an environment variable for use in the source path (library path) at a project level.
We often have a couple of versions checked out of our SVN repository at the same time in different directories, and I'd like to specify the repository root for a project in relative terms at a project level. I could then use that path in a project's source path and I wouldn't have to include indecipherable dot dot slashes (..\) in paths.
For example, say I have checked out trunk to c:\projects\trunk. Then underneath there I have a project in <repositoryroot>\Foo\Bar\ under trunk which uses the Delphi Spring framework under <repositoryroot>\components\external\Spring4d. I end up with a whole bunch of directories in the search path with ..\..\External\Spring4D\Source at the beginning. For example ..\..\External\Spring4D\Source\Base\Collections. I would like to be able to be able to use ${Spring4D} instead, producing ${Spring4D}\Base\Collections\, which is much less wordy and it means that if you move a project or component you can change one value and it updates all paths.
I know that you can do this on a Delphi level by specifying paths in Delphi's environment variables, but I would like to achieve the same thing on a project level or repository level.
Does anyone have any ideas on how to achieve this? Are there any settings or even add-ins that would allow this sort of functionality?
You can manually edit your project file (.dproj) and add a variable there:
<PropertyGroup>
<MyVariableName>MyVariableContent</MyVariableName>
</PropertyGroup>
Later on, you can refer to the content of that variable:
<DCC_UnitSearchPath>C:\Components;$(MyVariableName)</DCC_UnitSearchPath>
You can also define a new environment variable (SystemPropertiesAdvanced.exe -> Environment variables -> Add) and then refer to that variable using the same syntax, e.g.:
<DCC_UnitSearchPath>C:\Components;$(PATH)</DCC_UnitSearchPath>
(Note that it is a very bad idea to use PATH here, it's only an example of a variable which will exist in your environment.)
You could also employ some cmd script magic to to create environment variables that point to those subdirectories and at the end call the IDE, so these environment variables are available in the IDE in the same way as global environment variables would be (see pepak's answer for that).
Pointers:
%0 is the name of the current cmd file
use tilde for file name parts

how to find and deploy the correct files with Bazel's pkg_tar() in Windows?

please take a look at the bin-win target in my repository here:
https://github.com/thinlizzy/bazelexample/blob/master/demo/BUILD#L28
it seems to be properly packing the executable inside a file named bin-win.tar.gz, but I still have some questions:
1- in my machine, the file is being generated at this directory:
C:\Users\John\AppData\Local\Temp_bazel_John\aS4O8v3V\execroot__main__\bazel-out\x64_windows-fastbuild\bin\demo
which makes finding the tar.gz file a cumbersome task.
The question is how can I make my bin-win target to move the file from there to a "better location"? (perhaps defined by an environment variable or a cmd line parameter/flag)
2- how can I include more files with my executable? My actual use case is I want to supply data files and some DLLs together with the executable. Should I use a filegroup() rule and refer its name in the "srcs" attribute as well?
2a- for the DLLs, is there a way to make a filegroup() rule to interpret environment variables? (e.g: the directories of the DLLs)
Thanks!
Look for the bazel-bin and bazel-genfiles directories in your workspace. These are actually junctions (directory symlinks) that Bazel updates after every build. If you bazel build //:demo, you can access its output as bazel-bin\demo.
(a) You can also set TMP and TEMP in your environment to point to e.g. c:\tmp. Bazel will pick those up instead of C:\Users\John\AppData\Local\Temp, so the full path for the output directory (that bazel-bin points to) will be c:\tmp\aS4O8v3V\execroot\__main__\bazel-out\x64_windows-fastbuild\bin.
(b) Or you can pass the --output_user_root startup flag, e.g. bazel--output_user_root=c:\tmp build //:demo. That will have the same effect as (a).
There's currently no way to get rid of the _bazel_John\aS4O8v3V\execroot part of the path.
Yes, I think you need to put those files in pkg_tar.srcs. Whether you use a filegroup() rule is irrelevant; filegroup just lets you group files together, so you can refer to the group by name, which is useful when you need to refer to the same files in multiple rules.
2.a. I don't think so.

Flume "Spooling Directory Source" recursive-look for the the files within subdirectories

I am looking for the Flume "Spooling Directory Source" recursive-look for the the files within subdirectories.
There are some references here https://issues.apache.org/jira/browse/FLUME-1899
however since then multiple versions have come out, is there any way we can have recursive directory lookup within subdirectories for the files in Spooling Source.
I think you can use the patch FLUME-1899-2.patch directly.
set the "recursiveDirectorySearch" as ture in your config file.
NOTE: the regex in ignorePattern of config file will also affect the recursiveDirectory folder name. so you might need to modify the code in org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java if you want to ignore the folder name.

MVC 4 error in accessing resource file from controller

Getting error in accessing resource file string from MVC controller(working file with views)
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "TempNameSpace.App_GlobalResources.Resource_EN_US.resources" was correctly embedded or linked into assembly "TempNameSpace" at compile time, or that all the satellite assemblies required are loadable and fully signed.
What I have already done
1. Resource file build action : from content to Embedded resource
Result : Publish does not include resource files in it.
2. Added new resource file with name Resource.resx
Result : Same error
Solution hierarchy
1. Solution contains 4 projects, two with resource files(Resource.resx and Resource_EN_US under App_GlobalResources folder)
2. Designer for Resource_EN_US contains correct namespace
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TempNameSpace.App_GlobalResources.Resource_EN_US", typeof(Resource_EN_US).Assembly);
In my projects I use a seperate project for resources. I have set all resource files Build Action property to Embedded Resource.
On the reference to the resources project, I have Copy Local set to True for the resources project. (Rightclick a reference and select Properties)
If you have your resource files inside your web project, I think that the property corresponding with Copy Local should be Copy to Output Directory (Also accessible via rightclick and Properties).
Edit:
I see that in your comment you said that you access the file as Resource.Resource_EN_US.WaterMarkEmail but this is not the right way to access the files. You should access them as one single file: Resources.Property.
My files are named as: Standard.resx, Standard.en.resx, Standard.no.resx and so on. To access them I can use Standard.Property. The resource files will mold toghether, but only if you give them valid names. If you can access all your resource files individually, then you have not used the correct naming convention.
I recommend implementing a ResourceHelper that uses the ResourceManager to access the property that you need.

Resources