.NET script (2)

zhaozj2021-02-16  64

Version update history:

Update 3/18/04: Version 2.0.0.1

This version is too big, so I want to mention it to a primary version number. Here is a list of repairs and improvements.

A app.config file is added to replace the option XML element in the .dnml file, such as: Waitforuseraction, portfolio, scripting language, and common reference assembly. I also add a function of adding a new language for the script engine, so you can write the .NET script file in any language, as long as the 'CodeProvider' class of the language is defined (mentioned in more detail later). The value defined in the app.config file is like the machine configuration. That is, or, these basic values ​​can be overwritten by the values ​​in the DNML file. The value in the DNML file has the highest priority, which will be used by the script engine. But if your .dnml script file does not define any configuration, the value in the app.config file will be used. This allows you to define the actual code in the .dnml file.

User Preferences Configuration Segment: A user preference section is added to the app.config file. This section defines three configurations. Default language, scripting entry and waiting for user action flags. The default language is used to determine the language of the scripting language when the language element is not defined in the DNML file. The entry is a method that the script will call when the DNML file does not define an entry. The WaitForUseraction tag is a Boolean value that determines whether the console window is kept when the script is executed, and waits for a CRLF button. If this is not defined in the DNML file, the value in the config file will be called by the script engine. Here is an example of this paragraph.

Waitforuseraction = "true" />

The assembly reference configuration segment: This section is used to define the assembly that the script is required. Any assembly defined in this segment will be compiled when each script is running. Just need the program name instead of the full path name. Here is an example of this paragraph.

Language Support Configuration Segment: This section allows you to add a new support language for the scripting engine without re-raising engine code. The property name is the name defined in the DNML file or the defaultLanguage property in the user preference section. Properties Assembly are the full path names and file names that contain CodeProvder's language implementation. Property CodeProvidername is the language of the language of the language that contains the name space. Check out the LatebindCodeProvider () method of class AssemblyGenerator () method I can find out how I add this feature for the script engine.

Assembly = "c: /winnt/microsoft.net/framework/v1.1.4322/MICROSOFT.JScript.dll"

CodeProviderName = "Microsoft.jscript.jscriptcodeProvider" />

Assembly = "c: /winnt/microsoft.net/framework/v1.1.4322/VJSHARPCODEPROVIDER.DLL"

CodeProviderName = "Microsoft.vjsharp.vjsharpcodeProvider" />

Update 2/18/04: Version 1.0.2.0

I picked the CHARLIE POINTENGINE.EXE registration. DNML file extension associated with DotNetScripTENGINE.EXE.

An optional EntryPoint property is also added to the DNML file format. This allows the user to specify an assembly entry, not just a "main" method. If the attribute entrypoint is populated by a method name, the method will become an entry point. Otherwise, "main" will become the default program set entry point.

Element Language can be defined in the following three ways.

main () Will Be The

Entry Method to the assembly

main () Will

Be the entry method to the assembly

stuff ()

Will be the entry method to the assembly

I also added an optional element to .dnml XML format. This is a new fake, which allows you to keep the console window after the script is executed. Element Waitforusraction is optional. If it is not included in the .dnml file, the window will remain (open). This attribute value can be 'True' or 'false'. If true, the window will remain. If it is a fake, the console window will turn off immediately when the script is executed. This allows you to link several script files to a batch file.

Possible pathways using this element.

--NTHING - Console Window Will Remain Open After Script Has Run

console window will

Remain Open After Script Has Run

console window will

Remain Open After Script Has Run

console window will

Remain Open After Script Has Run

console window will

Close After Script Has Run

Console Window WillClose After Script Has Run

console window will

Close After Script Has Run

Finally, I added the .NET script to the calling process, cmd or batch file, a value of a value, which can be empty, or an integer. There are now two ways to define script portions return values. You can define it empty, or you can define it as a whole value. If you use a null value, the script will not return anything. If you use an integer value, the script engine will return to a full value of the process called it.

Examples of two different scripts inlet methods:

// The Script Engine Will Return Nothing When this Script is Called.

Public static void main ()

{

//...do stuff

Return;

}

// The Script ENGINE WILL RETURN A 5 WHEN Script is Called.

Public static int main ()

{

//...do stuff

Return 5;

}

// The Script Engine Will Return Nothing When this Script is Called.

Public Shared Sub Main ()

'... do stuff

Return

End Sub

// The Script ENGINE WILL RETURN A 5 WHEN Script is Called.

Public Shared Function Main () AS INTEGER

'... do stuff

Return 5

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-27979.html

New Post(0)