Are objects from imported namespaces accessed differently in C# than in VB? - namespaces

If I want to use the DriveInfo object in C#, I need to import the System.IO namespace. I can then access the object and any of its methods within the Main method.
If I try to do the same thing in a VB console app, it doesn't work. Apparently, I have to prefix DriveInfo with IO within the Main procedure (IO.DriveInfo), although I’ve already provided that in the Imports statement (Imports System.IO). What is going on here?

Related

MXMLC compiler missing filesystem library

I've had not trouble until this point directly from MXMLC command line. While compiling Actionscript 3 code I ran into a dependency problem.
import flash.filesystem;
and I get
Error: Definition flash:filesystem could not be found
There are another or two file-related libraries such as filestream. Where can I find these standard libraries and how might I add them to my MXMLC library PATH?
What are the specific classes you are trying to use? If you want to import all of the classes in the flash.filesystem package you need a * at the end of that import statement. Otherwise you need to append the class name(s). Something like one of these:
import flash.filesystem.*;
or
import flash.filesystem.File;
The other thing that might be an issue is the values in your flex-config.XML (or air-config.xml) file that is part of the SDK. You might need to configure this to include the classes in the AIR sdk, etc.

Configuring Object Instances from JSON in conf Files

So I want to be able to basically make instances of a class from JSON definitions in a conf file. In looking through the docs, I found that there are ways to reference things that are defined in JSON structures, but I was wondering about how best to instantiate objects from such definitions. For instance, suppose I had a class called RemoteRepository with 4 or 5 properties. I'd like to make a bunch of entries in a JSON file then read in at startup and get back a collection of RemoteRepository objects. I could do this with a database, of course, including a graph one, but would like to just do JSON if possible.
Assuming a static class definition that represents the JSON structure is acceptable, you can try the JSON C# Class Generator
Once you've generated your classes you can simply create a new instance or array of instances by passing in the json to the constructor that this tool creates on the generated class(es).
So I can make instances, but as usual, once I need a bunch of instances, it's time for a database. In this case, I ended up doing some simple XML files to trigger these instances. As much of a mess as XML is, for things like this, it does work best. Namely:
Some nesting of instance information
Not an exact mapping to the target class, e.g. field mappings are part of my config. I am going to load a few fields from the config file, but then create instances of a different class, hence the immediate conversion to a java class I would get from JSON is not meaningful
One other thing I figured out in doing this is that processing XML in Java is still kind of a mess. Still, this was the right way to go in this case.

Using "Import" AS3

I´d like to know.
What exactly does 'import'?
I´m thinking about to use a flash component with this 'import':
//import the required data class
import fl.data.DataProvider;
//import the AutoComplete class
import com.yahoo.astra.fl.controls.AutoComplete;
I mean, I don´t have those folders in my app main folder.
Is it importing from web?
If yes, is it safe? If server is shut down, will the app, that uses those classes, crash?
Thanks.
I am almost completely certain that import does not get anything from the web. I use imports for a complex game core I wrote. Imports can either import from a component of the Flash platform, or from your own classes. When the .swf is compiled, those classes are pulled in and compiled as part of the project.
In order to import something other than from the Flash platform, you WILL need to have the folders in your project. For example, I have gradua.as at trailcrest/gradua/gradua.as, and that trailcrest folder is located in the same directory as my Flash project (.fla). At the top of my gradua.as class, I have the following:
package trailcrest.gradua
{
public class gradua
Then, I can import gradua for use in my main .fla's document class (named osr.as, btw)...
import trailcrest.gradua.gradua;
public static var Gradua:gradua = new gradua();
And I can access its functions (such as my Score function) from anywhere in my project...
osr.Gradua.Score(true);
Again, to restate...to the best of my knowledge, you CANNOT import from the web this way. Flash is going to look for the file path com/yahoo/astra/fl/controls/AutoComplete.as in your project directory...and in a couple other places on your computer, tho I'm not sure where atm...
With the import statement you can include certain ActionScript classes in your application, which then will be compiled in your SWF file. If you use strict syntax and you try to use a Class member that is not imported, the compiler will tell you about it. Otherwise your app will still work.
The imported AS classes must be added to your library path, or src path when working on an ActionScript project. You can't import online files.
Rob

Manipulating Access VBA IDE methods from VBScript

I'm trying to write a VBScript that will export and import the code modules from an Access MDB file to text files.
From within the app I can loop through the DAO Container & Documents and use the 'undocumented' Application.SaveAsText method, but can I do it externally?
Basically it is all COM, but the COM interface doesn't expose methods for opening files, using MDWs for security, etc, but minds greater than my own have found a solution to the problem at http://www.mvps.org/access/modules/mdl0036.htm.
Once I've got a reference to the database, I can then use the techniques Remou and HansUp mention as normal.
It's all COM, so pretty much anything you can do from VBA in the IDE, you can do from a .vbscript file externally.
Set accessApplication = CreateObject("Access.Application")
' then do what you do from the IDE

SSIS: HTML Encoding a URL in a Script Task

I would like to URL encode a URL in a C# SSIS script task. I have tried using System.Web.HttpServerUtility, but intellisense shows it doesn't seem to be aware of "Server". Here's an example of the code that's raising an error:
Import System.Web
...
...
...
Server.HtmlEncode(TestVariable);
I have worked around this issue by writing a function that finds and replaces characters in a string to mimic HTML encoding a string, but I honestly abhore the solution. I would really just like to find out what I need to differently to use what's baked into .NET instead of reinventing the HTML Encoder wheel.
You need to add a reference to the assembly System.Web