Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Linq; 
using Alastri.Scripting; 
using Alastri.BlockModel.Engine.CustomVariables;

public class DryTonnes : IDoubleCustomVariable
{
    public double GetNumber(CustomVariablesContext context)
    {
        double density = context.N("DENSITY");

        double volume = context.N("XINC")*context.N("YINC")*context.N("ZINC");
        
        return (density > 0 ? density * volume : 0);
        
    }
}
Содержания одного

...

полезного компонента
Code Block
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Alastri.Scripting;
using Alastri.BlockModel.Engine.CustomVariables;

public class Parcel : ITextCustomVariable
{
    public string GetText(CustomVariablesContext context)
    {
        double fe = context.N("fe");
        
        if(fe > 60)        return "hg";
        else if(fe > 58)   return "mg";
        else if(fe > 57.5) return "lg1";
        else if(fe > 56)   return "lg2"; 
        else if(fe > 50)   return "minw";
        else               return "w";

    }
}

Несколько

...

компонентов
Code Block
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Alastri.Scripting;
using Alastri.BlockModel.Engine.CustomVariables;

public class Parcel : ITextCustomVariable
{
    public string GetText(CustomVariablesContext context)
    {
        double fe = context.N("fe");
        double al = context.N("al");
        string geology = context.T("geology");
        
        string fe_bin;
        
        if(fe > 60) 
        {
             fe_bin = "60";
        }
        else if(fe > 55) 
        {
            fe = Math.Floor(fe); 
            fe_bin = fe.ToString("#,##0");
        }
        else
        {
           fe_bin = "50";
        }

        string al_bin;

        if(al < 3)
        {
           al_bin = "3";
        }
        else if(al < 6)
        {
           al = Math.Ceil(al);
           al_bin = al.ToString("#,##0");
        }
        else
        {
          al_bin = "9";
        }

        string geoClass = "1";
        if(geology.Equals("detrital", StringComparison.OrdinalIgnoreCase))
        {
           geoClass = "2";
        }

        return fe_bin + "_" + al_bin + "_" + geoClass;
    }
}

...