mirror of
https://github.com/PetroProtsyk/SSharp
synced 2026-06-08 12:11:10 +00:00
91 lines
2.5 KiB
Plaintext
91 lines
2.5 KiB
Plaintext
<#@ template language="C#" #>
|
|
<#@ assembly name="System.Xml.dll" #>
|
|
<#@ import namespace="System.Xml" #>
|
|
<#
|
|
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
|
|
doc.Load("SSharp.Net/RuntimeConfig.xml");
|
|
#>
|
|
// <autogenerated>
|
|
// This code was generated by a tool. Any changes made manually will be lost
|
|
// the next time this code is regenerated.
|
|
// </autogenerated>
|
|
using System;
|
|
using Scripting.SSharp.Runtime.Configuration;
|
|
|
|
namespace Scripting.SSharp.Runtime{
|
|
public class <#= this.ClassName #>
|
|
{
|
|
public static ScriptConfiguration CreateDefault()
|
|
{
|
|
ScriptConfiguration cf = new ScriptConfiguration();
|
|
<#
|
|
var refs = doc.SelectNodes("/Configuration/References/*");
|
|
foreach(XmlElement r in refs)
|
|
{
|
|
var sn = r.GetAttribute("sn");
|
|
|
|
Write(" cf.References.Add(new Reference(");
|
|
Write("\""+r.GetAttribute("name")+"\",");
|
|
Write((string.IsNullOrEmpty(sn)?"false":sn)+"));");
|
|
WriteLine("");
|
|
}
|
|
#>
|
|
<#
|
|
WriteLine("");
|
|
var types = doc.SelectNodes("/Configuration/Types/*");
|
|
foreach(XmlElement r in types)
|
|
{
|
|
var alias = r.GetAttribute("alias");
|
|
var name = r.GetAttribute("name");
|
|
|
|
Write(" cf.Types.Add(new TypeXml() { Alias = \""+alias+"\", QualifiedName = \""+name+"\" });");
|
|
WriteLine("");
|
|
}
|
|
#>
|
|
<#
|
|
WriteLine("");
|
|
var scopes = doc.SelectNodes("/Configuration/Scopes/*");
|
|
foreach(XmlElement r in scopes)
|
|
{
|
|
var id = r.GetAttribute("id");
|
|
var type = r.GetAttribute("type");
|
|
|
|
Write(" cf.Scopes.Add(new ScopeDefinition() { Id = "+id+", Type = \""+type+"\" });");
|
|
WriteLine("");
|
|
}
|
|
#>
|
|
<#
|
|
WriteLine("");
|
|
var ops = doc.SelectNodes("/Configuration/Operators/*");
|
|
foreach(XmlElement r in ops )
|
|
{
|
|
var name = r.GetAttribute("name");
|
|
var type = r.GetAttribute("type");
|
|
|
|
Write(" cf.Operators.Add(new OperatorDefinition() { Name = \""+name+"\", Type = \""+type+"\" });");
|
|
WriteLine("");
|
|
}
|
|
#>
|
|
<#
|
|
WriteLine("");
|
|
var sets = doc.SelectNodes("/Configuration/Settings/*");
|
|
foreach(XmlElement r in sets )
|
|
{
|
|
var id = r.GetAttribute("id");
|
|
var value = r.GetAttribute("value");
|
|
var converter = r.GetAttribute("converter");
|
|
if (string.IsNullOrEmpty(converter)) converter=null;
|
|
|
|
Write(" cf.SettingXml.Add(new SettingXml() { Name = \""+id+"\", Value = \""+value+"\", Converter= \""+converter+"\" });");
|
|
WriteLine("");
|
|
}
|
|
#>
|
|
return cf;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
<#+
|
|
string ClassName = "Configurations";
|
|
#> |