Intentando Clasificar (sin funcionar)
This commit is contained in:
53
testML/DictionaryToObjectConverterClass.tt
Normal file
53
testML/DictionaryToObjectConverterClass.tt
Normal file
@@ -0,0 +1,53 @@
|
||||
<#@ template language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.ML.Data;
|
||||
|
||||
namespace DictionaryToObjectConverterNamespace
|
||||
{
|
||||
public class <#= ClassName #> : testML.IDictionaryToObjectConverter
|
||||
{
|
||||
<# foreach (var key in Definition.Keys)
|
||||
{
|
||||
var type = Definition[key];
|
||||
#>
|
||||
|
||||
[ColumnName("<#= key #>")]
|
||||
public <#= type.FullName #> <#= key #> { get; set; }
|
||||
<# } //Fin loop #>
|
||||
|
||||
public object this[string propertyName]
|
||||
{
|
||||
get { return GetValue(propertyName); }
|
||||
set { SetValue(propertyName, value); }
|
||||
}
|
||||
|
||||
public void SetValue(string propertyName, object value)
|
||||
{
|
||||
switch(propertyName)
|
||||
{
|
||||
<# foreach (var key in Definition.Keys) {
|
||||
var type = Definition[key]; #>
|
||||
case "<#= key #>": <#= key #> = (<#= type.FullName #>)value; break;
|
||||
<# } #>
|
||||
}
|
||||
}
|
||||
|
||||
public object GetValue(string propertyName)
|
||||
{
|
||||
switch(propertyName)
|
||||
{
|
||||
<# foreach (var key in Definition.Keys) { #>
|
||||
case "<#= key #>": return <#= key #>;
|
||||
<# } #>
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user