Embedding whole directory structure - asp.net

I have a large directory structure with JavaScript, images, etc. that depend on each other. I would like to encapsulate it all into a DLL so I only have to reference one thing and not have multiple copies of all these files across projects.
Because the files depend on each other, I'm thinking I can create an IHttpModule that registers a route to accept URLs such as /MyEmbeddedDir/subdir/file.js. Anything in MyEmbeddedDir would then be handled by a custom IHttpHandler that does the correct mapping. Each web application would then need to reference the DLL and add the module and handler to web.config. Does this seem reasonable?
Also, is there an easier way to embed/reference the files than to set the build action to embedded resource and add [assembly: WebResource(...)] to each file (there are dozens!)? Thanks!
Edit: If I'm not using WebResource.axd then I shouldn't need to add [assembly: WebResource(...)]

Yes, having a single container is a great way to manage large number of files (and no, SQLite won't help here! ;).
We have a product, named SolFS, which is a virtual file system, that lets you keep your data in custom storage (resource DLL is one of the options) and provides file API for accessing the files. We even implemented asynchronous pluggable protocol for IE (on the client side, but the task is very similar to yours). SolFS includes a manager application that lets you easily create container files and import files into container.

I ended up going with the IHTTPModule (register route) and IHTTPHandler (obtain embedded resource). The route is configurable in web.config in case it conflicts with existing content.

Related

How to define Qml component file resolver for Qt 5.5 + QtQuick 2.5?

Is there any way how to implement dynamical file-resolver for missing Qml components in QmlEngine? How to implement dynamically loading of external resources to QmlEngine?
I can use following snippet to load qml component from any data stream:
QUrl uri(...)
QByteArray data(...);
QQmlComponent::setData(data,uri);
but when passed component refers to another one (not already loaded), QmlEngine stopped because of missing resource.
Is there any event/callback where it is possible to handle such missing resource?
Added use-case scenario:
We're developing some QML visual components. Some components are implemented as .qml files and some as QQuickItem.
For example imagine following situation (it's very simplified):
QmlItem "DiagramPoint", implemented in point.qml
QmlItem "Line" implemented in line.qml, class is using "DiagramPoint" item
QQuickItem (c++) "ConnectedLine" which internally using "Line" object
QmlProject which using "ConnectedLine" components.
In case that point.qml and line.qml are located on hdd or stored inside Qt Resources, everything works automatically. But what we would like to achieve is to store these files in encrypted form in our internal .dat file and decode it only on demand.
We're able to decode and load "Line" object from "ConnectedLine" implementation. But in case that "Line" (line.qml) depends on another encrypted file "DiagramPoint" (point.qml), this solution doesn't work.
Another possible solution
Another solution could be to register all decrypted .qml files on application startup and than use it. Something simillar to qmlRegisterType which allows to register c++ QQuickItems to QmlEngine.
Unfortunately none of these methods allow to register Qml snippet from string buffer.
I'm still a bit unsure about how you would do this, but you might find QQmlAbstractUrlInterceptor useful:
QQmlAbstractUrlInterceptor is an interface which can be used to alter URLs before they are used by the QML engine. This is primarily useful for altering file urls into other file urls, such as selecting different graphical assets for the current platform.
Relative URLs are intercepted after being resolved against the file path of the current QML context. URL interception also occurs after setting the base path for a loaded QML file. This means that the content loaded for that QML file uses the intercepted URL, but inside the file the pre-intercepted URL is used for resolving relative paths. This allows for interception of .qml file loading without needing all paths (or local types) inside intercepted content to insert a different relative path.
Compared to setNetworkAccessManagerFactory, QQmlAbstractUrlInterceptor affects all URLs and paths, including local files and embedded resource files. QQmlAbstractUrlInterceptor is synchronous, and for asynchronous files must return a url with an asynchronous scheme (such as http or a custom scheme handled by your own custom QNetworkAccessManager). You can use a QQmlAbstractUrlInterceptor to change file URLs into networked URLs which are handled by your own custom QNetworkAccessManager.
To implement support for a custom networked scheme, see setNetworkAccessManagerFactory.
It says that its synchronous, so perhaps you could decode the QML files when the URLs are intercepted to ensure that they exist?

how to deploy flex app using different web service urls?

Is there some sort of configuration settings in FlashBuilder 4.5 where you can easily switch between webservice urls? Right now I have to delete and recreate the web service every time I switch from local to production and vice versa.
The need/requirement is this – Since I work in a startup, we keep changing servers, and their IP addresses. And being a service oriented application – I need to be able to edit the webservice endpoints in my Flex application in a easy manner every time this happens.
My Solution for this -
Assumption is that my webservice endpoint looks like this -
http:////ListAllServices/
1) Create a file config.xml in a folder named “settings” that sits in the root folder of your Flex application – outside the “src” folder. And the config.xml will be a simple xml file of the following format -
localhostTestFlexApp
At the end of this exercise the directory structure of your flex source code will look like this -
flex_src(root of the source code)
-com(some source folder)
–testapp
—view
—
-images
-settings
–config.xml
-appName.mxml
2) Now in your application code, setup a HTTPService object either in mxml or action script. Set the url of that object to this value- “settings/config.xml” – And the above xml fiel containing the current settings will be loaded into memory .
Now you can store these values in a singleton object and construct your Webservice call at runtime.
And whenever you want to move this to a new server in production, edit the tag of your config.xml and you should be good to go.
And this can be automated as well via the EnvGen ant task.
This is not the best way but yes it is very helpful while switching among servers.
Alrighty... The way I was doing it before in fact worked. The problem was browser caching.
For the benefit of others I modified the subsclass for the generated service and replace the wsdl variable with whatever endpoint I need.

Subclassing Global and overriding Application_Start

I have a couple of web applications whose source code is missing. The project is compiled to a dll and is hosted on a IIS.
I have couple of questions to make.
What is the best way to recreate the
project from the dll file??
We are planning to change the
database server, and the database
connection strings are specified in
the Global.asax ( I mean the public
class Global : HttpApplication ). Is
there a way I can subclass this
Global and override the connection
strings? If yes, how can I make the
IIS refer to the new dll
Thank you all for any suggestions!!
For first part, use decompiler tools such as Reflector/ILSpy/dotPeek to convert IL code from DLL to higher level language such as C#. However, tools cannot get back comments, local variable names and project structure. You need to manually organize the code into files and project structures. From aspx files, you have to figure out the code-behind classes and then link up the source of the class into a correct named code-behind file - for example, if default.aspx says that it inherits from MyApp.Default then create file default.aspx.xs and put the source code for the class into that.
For second part, you can create a new class derived from Global and modify Global.asax to use that class - you need to put the assembly containing new class in bin folder and overwrite inherits clause in asax file to point to the type name of new class. You anyway need to inspect the code of your current Global class (using tools sighted above) to see if you can override connection strings by sub-classing.
Probably the best tool available to reverse engineer a dll into code is .NET Reflector. Unfortunately, the latest version is no longer free, but it is worth the money.
I am not sure exactly if this still applies if you can already reverse engineer your source code. However, I would recommend moving your connection strings outside of your project into web.config as a best practice. This way you can make the change in the future without changing any code.

Dynamically extract interfaces from silverlight modules and load modules

In some winforms / webforms applications, I wrote a module that at application start, using reflection, inspects all assemblies from BIN folder, extract all public classes and interfaces they implement and write into a repository. This to to allow me later, at runtime, to load modules based on interfaces they implements and use.
I need to know if / how can I accomplish this for Silverlight. Is there any way to inspect all XAP's and extract all modules together with their metadata? And later to be able to dynamically load the module where the component I need is located, and then load the component from it.
Thank you
The source code for MEF's DeploymentCatalog should show how to inspect the main application XAP as well as download and inspect other XAPs.

Loading modules from a certain folder

I'm working with modules and each of it will be compiled (deployed) in a common folder in a webproject. In the main class I defined an array of module paths which I need for loading all these defined modules.
How can I make that more dynamically, for instance, I want to say, load all modules in a certain folder an its subfolders without to know each module by name.
You can't do anything in a Flex/AS3 related browser based app to get information about folders on the server.
You're going to have to write a server side service to get the information. Any technology should work, such as .NET, ColdFusion, PHP, Java, or whatever. Then just call the service, and it should send you back the information you need. In ColdFusion, you'd use the cfdirectory tag.

Resources