//---------------------------------------------------------------------
 public ParametersUpdate(int    year,
                         string file)
 {
     this.year = year;
     this.file = file;
     this.parameters = null;
 }
Пример #2
0
		//---------------------------------------------------------------------

		public Parameters(IParameters parameters)
		{
			name        = parameters.Name;
			description = parameters.Description;
			mapCode     = parameters.MapCode;
			active      = parameters.Active;
		}
Пример #3
0
        /// <summary>
        ///     Generate the scripts.
        /// </summary>
        internal static bool Do()
        {
            _log = Program.GetInstance<IBLogger>();
            _params = Program.GetInstance<IParameters>();

            var frmConn = (NpgsqlConnection) _params[Constants.PgConnection];
            PostgresSchemaTables.CreateTables();

            var tblDict = ((Dictionary<string, DataTable>) _params[Constants.PgTables]);
            var schemaTable = tblDict[Constants.PgSchemaTable];

            if (schemaTable.Rows.Count == 0)
            {
                _log.Write('E', Constants.LogTsType, "There are no records to be processed.");
                return false;
            }

            GenerateSchemaScript(schemaTable);

            var typeTable = tblDict[Constants.PgTypeTable];
            var seqTable = tblDict[Constants.PgSeqTable];
            var fkTable = tblDict[Constants.PgFkTable];

            GenerateTableScripts(schemaTable, seqTable, frmConn);
            GenerateBuildIndexes(frmConn);
            GenerateFkConstraints(fkTable);

            if (typeTable.Rows.Count > 0 || seqTable.Rows.Count > 0)
                GenerateTypeScripts(typeTable, seqTable);

            return true;
        }
Пример #4
0
        public static object GetTargets(IParameters parameters)
        {
            var git = new GitCheckout {
                Repository = @"C:\Users\Public\Documents\Development\BigSolution.git",
                Directory = "one"
            };
            var solution = new VisualStudioSolution {
                SolutionPath = git.Files["BigSolution.sln"]
            };
            var webProject = solution.Projects[parameters.Default("proj", "BigSolution")];
            var serviceName = parameters.Default("svc", "BigWindowsService");
            var service = solution.Projects[serviceName];

            return new {
                WebSite = new Iis7WebSite {
                    Directory = webProject.ProjectDirectory,
                    Name = "BigWebSite",
                    Port = 5001
                },
                Tests = new NUnitTests {
                    DllPaths = solution.Projects.Select(p => p.OutputFile)
                },
                Service = new WindowsService {
                    BinaryPath = service.OutputFile,
                    Name = serviceName,
                    DisplayName = "Big Windows Service",
                    Description = "a big windows service demonstrating the bounce build framework"
                },
                Zip = new ZipFile {
                    Directory = webProject.WhenBuilt(() => Path.GetDirectoryName(webProject.OutputFile.Value)),
                    ZipFileName = "web.zip"
                },
            };
        }
Пример #5
0
        public static object RealTargets(IParameters buildParameters)
        {
            var version = buildParameters.Required<string>("version");

            var git = new GitCheckout {
                Repository = "git://github.com/refractalize/bounce.git",
                Directory = "tmp2",
            };
            var solution = new VisualStudioSolution {
                SolutionPath = "Bounce.sln",
            };
            var frameworkProject = solution.Projects["Bounce.Framework"];

            var downloadsDir = new CleanDirectory {
                Path = "Downloads",
            };

            var frameworkZip = new ZipFile {
                Directory = frameworkProject.WhenBuilt(() => Path.GetDirectoryName(frameworkProject.OutputFile.Value)),
                ZipFileName = downloadsDir.Files[version.WhenBuilt(() => string.Format("Bounce.Framework.{0}.zip", version.Value))],
            };

            var downloads = new All(frameworkZip, new GitTag {Directory = ".", Tag = version.WhenBuilt(() => "v" + version.Value)});

            return new {
                Tests = new NUnitTests {
                    DllPaths = solution.Projects.Select(p => p.OutputFile),
                },
                Downloads = downloads,
            };
        }
 public AverageOperation(string outKey, string outType, IParameters parameters)
     : base(string.Empty, outKey) {
     _outType = outType;
     _parameters = parameters;
     _typeSafe = parameters.ToEnumerable().All(kv => kv.Value.SimpleType.Equals(outType));
     Name = string.Format("Average ({0})", outKey);
 }
        //---------------------------------------------------------------------
        public static void Initialize(IParameters parameters)
        {
            string logFileName   = "Century-succession-log.csv";
            UI.WriteLine("   Opening Century-succession log file \"{0}\" ...", logFileName);
            try {
                log = Data.CreateTextFile(logFileName);
            }
            catch (Exception err) {
                string mesg = string.Format("{0}", err.Message);
                throw new System.ApplicationException(mesg);
            }

            log.AutoFlush = true;
            log.Write("Time, Ecoregion, NumSites,");
            log.Write("NEEC, SOMTC, AGB, ");
            log.Write("AG_NPPC, BG_NPPC, LitterfallC, FRootLitterC, ");
            log.Write("MineralN, TotalN, GrossMineralization, ");
            log.Write("C:LeafFRoot, C:WoodCRoot, C:DeadWood, C:DeadCRoot, ");
            log.Write("C:SurfStruc, C:SurfMeta, C:SoilStruc, C:SoilMeta, ");
            log.Write("C:SOM1surf, C:SOM1soil, C:SOM2, C:SOM3, ");
            log.Write("N:CohortLeaf, N:CohortWood, N:DeadWood, N:DeadRoot, ");
            log.Write("N:SurfStruc, N:SurfMeta, N:SoilStruc, N:SoilMeta, ");
            log.Write("N:SOM1surf, N:SOM1soil, N:SOM2, N:SOM3, ");
            log.Write("SurfStrucNetMin, SurfMetaNetMin, SoilStrucNetMin, SoilMetaNetMin, ");
            log.Write("SOM1surfNetMin, SOM1soilNetMin, SOM2NetMin, SOM3NetMin, ");
            log.Write("StreamC, StreamN, FireEfflux");
            log.WriteLine("");
        }
        //private static StreamWriter log;
        //---------------------------------------------------------------------
        public static void Initialize(IParameters parameters)
        {
            FuncType            = parameters.SppFunctionalType;
            NTolerance          = parameters.NTolerance;
            GDDmin              = parameters.GDDmin;
            GDDmax              = parameters.GDDmax;
            MinJanTemp          = parameters.MinJanTemp;
            MaxDrought          = parameters.MaxDrought;
            LeafLongevity       = parameters.LeafLongevity;
            Epicormic           = parameters.Epicormic;
            LeafLignin          = parameters.LeafLignin;
            WoodLignin          = parameters.WoodLignin ;
            CoarseRootLignin    = parameters.CoarseRootLignin ;
            FineRootLignin      = parameters.FineRootLignin ;
            LeafCN              = parameters.LeafCN;
            WoodCN              = parameters.WoodCN;
            CoarseRootCN        = parameters.CoarseRootCN;
            LeafLitterCN        = parameters.FoliageLitterCN;
            FineRootLitterCN    = parameters.FineRootLitterCN;
            NLimits = new Species.AuxParm<double>(Model.Core.Species);

            Establishment.Initialize();

            // The initial set of establishment probabilities:
            EstablishProbability = Establishment.GenerateNewEstablishProbabilities(parameters.Timestep);
            Reproduction.ChangeEstablishProbabilities(Util.ToArray<double>(SpeciesData.EstablishProbability));

            ChangeParameters(parameters);
        }
        /// <summary>
        /// Identify this class as one that handles Blob parameters
        /// </summary>
        /// <param name="parameters">List of parameters</param>
        /// <returns>True if this class handles the specified parameters</returns>
        public bool CanHandle(IParameters parameters)
        {
            if (parameters == null)
                throw new ArgumentNullException(nameof(parameters));

            return parameters.MethodType == MethodType.Blob;
        }
Пример #10
0
        public FileCalculation(FileQueue fileQueue, IParameters parameters)
        {
            if (fileQueue == null)
                throw new ArgumentNullException("fileQueue", "Queue can't be null");
            if (parameters == null)
                throw new ArgumentNullException("parameters", "Parameters can't be null");

            Queue = fileQueue;
            Parameters = parameters;

            var statisticLog = System.IO.Path.Combine(Parameters.GetParameter("CalculationLogs"), "log.xml");
            if (System.IO.File.Exists(statisticLog))
            {
                List<FileCalculationInfo> res = null;
                typeof(List<FileCalculationInfo>).DeserializeFromXML(System.IO.File.ReadAllText(statisticLog), out res);
                if (res != null)
                    infoLog.AddRange(res);
                infoLog.ForEach(il =>
                {
                    if (il.Status == FileCalculationStatus.InAction)
                    {
                        il.Error = "Задание прервано";
                        il.Status = FileCalculationStatus.Error;
                    }
                });
            }
        }
Пример #11
0
        public MailOperation(MailConnection connection, IParameters parameters)
            : base(string.Empty, string.Empty) {
            _connection = connection;
            _parameters = parameters;
            
            _hasCc = parameters.ContainsName("cc");
            _ccKey = _hasCc ? parameters.GetKeyByName("cc") : string.Empty;

            _hasBcc = parameters.ContainsName("bcc");
            _bccKey = _hasBcc ? parameters.GetKeyByName("bcc") : string.Empty;

            _hasSubject = parameters.ContainsName("subject");
            _subjectKey = _hasSubject ? parameters.GetKeyByName("subject") : string.Empty;

            if (!parameters.ContainsName("from")) {
                throw new TransformalizeException(Logger, EntityName, "Mail transform requires parameter named from.");
            }
            _fromKey = parameters.GetKeyByName("from");

            if (!parameters.ContainsName("to")) {
                throw new TransformalizeException(Logger, EntityName, "Mail transform requires parameter named to.");
            }
            _toKey = parameters.GetKeyByName("to");

            if (!parameters.ContainsName("body")) {
                throw new TransformalizeException(Logger, EntityName, "Mail transform requires parameter named body.");
            }
            _bodyKey = parameters.GetKeyByName("body");

            Name = "Mail";
        }
Пример #12
0
        public DefaultSuiteFactory(IParameters parameters, [SuiteRoot] IFileSystemDirectory suiteRoot, ICommandEnumerator commandEnumerator)
        {
            targetGoal = parameters.Goal;
            this.suiteRoot = suiteRoot;

            ignoreTargetGoal = !commandEnumerator.NeedsExplicitTargetGoal(parameters.Command);
        }
Пример #13
0
        //---------------------------------------------------------------------
        
        public override void LoadParameters(string dataFile,
                                            ICore mCore)
        {
            modelCore = mCore;

            // Add local event handler for cohorts death due to age-only
            // disturbances.
            Cohort.AgeOnlyDeathEvent += CohortKilledByAgeOnlyDisturbance;

            HarvestMgmtLib.Main.InitializeLib(modelCore);
            HarvestExtensionMain.SiteHarvestedEvent += SiteHarvested;
            Landis.Library.BiomassHarvest.Main.InitializeLib(modelCore);

            ParametersParser parser = new ParametersParser(modelCore.Species);

            HarvestMgmtLib.IInputParameters baseParameters = Landis.Data.Load<IInputParameters>(dataFile, parser);
            parameters = baseParameters as IParameters;
            if (parser.RoundedRepeatIntervals.Count > 0)
            {
                ModelCore.UI.WriteLine("NOTE: The following repeat intervals were rounded up to");
                ModelCore.UI.WriteLine("      ensure they were multiples of the harvest timestep:");
                ModelCore.UI.WriteLine("      File: {0}", dataFile);
                foreach (RoundedInterval interval in parser.RoundedRepeatIntervals)
                    ModelCore.UI.WriteLine("      At line {0}, the interval {1} rounded up to {2}",
                                 interval.LineNumber,
                                 interval.Original,
                                 interval.Adjusted);
            }

        }
Пример #14
0
 public TagOperation(string outKey, string tag, IParameters parameters, bool decode, bool encode)
     : base(string.Empty, outKey) {
     _tag = tag;
     _parameters = parameters;
     _decode = decode;
     _encode = encode;
 }
Пример #15
0
 /// <summary>
 /// Constructs the MSBuild runner
 /// </summary>
 /// <param name="parameters">User defined parameters for bari</param>
 public XBuild(IParameters parameters)
     : base("xbuild", 
            "",
            "xbuild.bat", new Uri("http://www.go-mono.com/mono-downloads/download.html"))
 {
     this.parameters = parameters;
 }
Пример #16
0
        public static object Targets(IParameters parameters)
        {
            var stage = parameters.Required<string>("stage");
            var machine = parameters.Required<string>("machine");

            var deployService = new Copy {
                FromPath = "service",
                ToPath = machine.WhenBuilt(m => String.Format(@"c:\deployments\install\{0}\service", m)),
            };
            var deployWeb = new Copy {
                FromPath = "web",
                ToPath = machine.WhenBuilt(m => String.Format(@"c:\deployments\install\{0}\web", m)),
            };

            var remoteMachineOne = GetRemoteMachine(stage, machine, "one");
            var remoteMachineTwo = GetRemoteMachine(stage, machine, "two");

            Task<IEnumerable<RemoteMachine>> serviceMachines = new[] {remoteMachineOne, remoteMachineTwo};
            Task<IEnumerable<RemoteMachine>> webMachines = new[] {remoteMachineTwo};

            var deployArchive = new StagedDeployArchive(stage, "archive");
            var service = deployArchive.Add("service", "service", deployService).WithRemoteDeploy(serviceMachines.SelectTasks(m => m.DeployTargets("Service")));
            var web = deployArchive.Add("web", "web", deployWeb).WithRemoteDeploy(webMachines.SelectTasks(m => m.DeployTargets("Web")));

            return new {
                Service = service,
                Web = web,
            };
        }
Пример #17
0
 /// <summary>
 /// Constructs the MSBuild runner
 /// </summary>
 /// <param name="parameters">User defined parameters for bari</param>
 public MSBuild(IParameters parameters)
     : base("msbuild40", 
            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"Microsoft.NET\Framework\v4.0.30319\"), 
            "MSBuild.exe", new Uri("http://www.microsoft.com/en-us/download/details.aspx?id=17851"))
 {
     this.parameters = parameters;
 }
        //---------------------------------------------------------------------
        public static void Initialize(IParameters parameters)
        {
            MinRelativeBiomass  = parameters.MinRelativeBiomass;
            B_MAX               = new Ecoregions.AuxParm<int>(Model.Core.Ecoregions);

            ChangeParameters(parameters);
        }
Пример #19
0
        public SphereEmitter(IParameters parameters)
            : base(parameters)
        {
            _particlesToEmit = new SoAData(200);

            _Radius = Parameters.GetParameterDelegate<float>("Radius");
            _EmitRingOnly = Parameters.GetParameterDelegate<bool>("EmitRingOnly");
        }
Пример #20
0
 public GeoCodeOperation(string inKey, string outKey, int sleep, bool useHttps, IParameters parameters)
     : base(inKey, outKey) {
     _sleep = sleep;
     _parameters = parameters.ToEnumerable().Select(kv => kv.Value).ToArray();
     _service = new GoogleLocationService(useHttps);
     _useParameters = parameters.Count > 1;
     Name = string.Format("GeoCode ({0})", outKey);
 }
Пример #21
0
 /// <summary>
 /// Defines the external tool
 /// </summary>
 /// <param name="name">Name of the tool</param>
 /// <param name="defaultInstallLocation">Default install location where the external tool can be found</param>
 /// <param name="exeName">Executable file name</param>
 /// <param name="manualUri">URI where the user can start solving the problem if the tool is missing</param>
 /// <param name="isDotNETProcess">If <c>true</c> the process will be executed with mono when not running on MS CLR</param>
 /// <param name="parameters">Application parameters</param>
 public ManuallyInstallableExternalTool(string name, string defaultInstallLocation, string exeName, Uri manualUri, bool isDotNETProcess, IParameters parameters)
     : base(name, parameters)
 {
     this.defaultInstallLocation = defaultInstallLocation;
     this.exeName = exeName;
     this.manualUri = manualUri;
     isDotNetProcess = isDotNETProcess;
 }
Пример #22
0
        public OrderTicketViewModel(IParameters tradingParams)
        {
            this.tradingParams = tradingParams;
            this.bookTicketCommand = new DelegateCommand<object>(
                x => this.CanBook(),
                x => { /* nothing here for demo */ });

            this.validationErrors = new ObservableCollection<IError>();
        }
Пример #23
0
        public AddOperation(string outKey, string outType, IParameters parameters)
            : base(string.Empty, outKey) {
            _outType = outType;
            _parameters = parameters;
            _parameterKeys = parameters.Keys.ToArray();
            _map = Common.GetObjectConversionMap();
            Name = "Add (" + outKey + ")";

        }
            public static object GetTargets(IParameters parameters) {
                var one = new FakeTask {Dependencies = new [] {new TaskDependency (parameters.Required<int>("port"))}};
                var two = new FakeTask {Dependencies = new [] {new TaskDependency (parameters.Default("name", "Some Web Site"))}};

                return new {
                    One = one,
                    Two = two,
                };
            }
        public TimeSpanOperation(IParameters parameters, string outKey)
            : base(string.Empty, outKey) {
            _parameters = parameters;
            Name = string.Format("TimeSpanOperation ({0})", outKey);

            if (_parameters.Count < 2) {
                throw new TransformalizeException(EntityName, Logger, "Timespan requires 2 date parameters.");
            }
        }
        //---------------------------------------------------------------------
        public static void Initialize(IParameters parameters)
        {
            ChangeParameters(parameters);

            LeafLignin = parameters.LeafLignin;
            LeafLongevity = parameters.LeafLongevity;
            MortCurveShapeParm = parameters.MortCurveShapeParm;
            GrowthCurveShapeParm = parameters.GrowthCurveShapeParm;
        }
        protected TemplateOperation(string outKey, string outType, string template, IEnumerable<KeyValuePair<string, Template>> templates, IParameters parameters)
            : base(string.Empty, outKey) {
            OutType = Common.ToSimpleType(outType);
            Parameters = parameters;

            CombineTemplates(templates, ref _builder);
            _builder.Append(template);
            Template = _builder.ToString();
        }
Пример #28
0
        public static object GetTargets(IParameters parameters)
        {
            var dir = new CleanDirectory {
                Path = GitCheckoutDirectory
            };

            return new {
                Directory = dir
            };
        }
Пример #29
0
 public InnoSetupCompiler([SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot, IParameters parameters)
     : base("InnoSetup",
         Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Inno Setup 5"),
         "iscc.exe",
         new Uri("http://www.jrsoftware.org/download.php/ispack-unicode.exe"),
         false, parameters)
 {
     this.suiteRoot = suiteRoot;
     this.targetRoot = targetRoot;
 }
Пример #30
0
        internal static RestRequest AddParameters(this RestRequest self, IParameters parameters)
        {
            List<KeyValuePair<string, string>> list = parameters.ToDictionary().ToList();
            if (list.Count > 0)
            {
                list.ForEach(kvp => self.AddParameter(kvp.Key, kvp.Value));
            }

            return self;
        }
Пример #31
0
        public virtual double?GetEntryTakeProfitPrice(Chart chart, IParameters parameters, IDictionary <string, object> state)
        {
            double?takeProfitPrice = null;

            return(takeProfitPrice);
        }
Пример #32
0
        override internal void LoadAll()
        {
            try
            {
                string schema = "";

                if (-1 == this.Procedure.Schema.IndexOf("."))
                {
                    schema = this.Procedure.Schema + ".";
                }

                string select = "SET FMTONLY ON EXEC [" + this.Procedure.Database.Name + "]." + schema +
                                this.Procedure.Name + " ";

                int paramCount = this.Procedure.Parameters.Count;

                if (paramCount > 0)
                {
                    IParameters parameters = this.Procedure.Parameters;
                    IParameter  param      = null;

                    int c = parameters.Count;

                    for (int i = 0; i < c; i++)
                    {
                        param = parameters[i];

                        if (param.Direction == ParamDirection.ReturnValue)
                        {
                            paramCount--;
                        }
                    }
                }

                for (int i = 0; i < paramCount; i++)
                {
                    if (i > 0)
                    {
                        select += ",";
                    }

                    select += "null";
                }

                OleDbDataAdapter adapter  = new OleDbDataAdapter(select, this.dbRoot.ConnectionString);
                DataTable        metaData = new DataTable();

                adapter.Fill(metaData);

                AdvantageResultColumn resultColumn = null;

                int count = metaData.Columns.Count;
                for (int i = 0; i < count; i++)
                {
                    resultColumn               = this.dbRoot.ClassFactory.CreateResultColumn() as Advantage.AdvantageResultColumn;
                    resultColumn.dbRoot        = this.dbRoot;
                    resultColumn.ResultColumns = this;
                    resultColumn._column       = metaData.Columns[i];
                    this._array.Add(resultColumn);
                }
            }
            catch {}
        }
Пример #33
0
 protected Concrete(IParameters parameters, ConstitutiveModel model = ConstitutiveModel.MCFT)
 {
     Parameters = parameters;
     Model      = model;
 }
Пример #34
0
 public Key(IParameters <Algorithm> parameterSet, byte[] bytes)
     : base(parameterSet, bytes)
 {
 }
Пример #35
0
 private static bool HasKey(this IParameters parameters, string name, out string key)
 {
     key = parameters.Select(x => x.Key).FirstOrDefault(k => k.Equals(name, StringComparison.InvariantCultureIgnoreCase));
     return(!string.IsNullOrEmpty(key));
 }
Пример #36
0
 public static void Initialize(View view, IParameters parameters)
 {
     InvokeActionOnViewAndStateObjects <IInitialize>(view, x => x.Initialize(parameters));
     InvokeActionOnViewAndStateObjects <IAbracadabra>(view, x => Abracadabra(x, parameters));
 }
Пример #37
0
        /// <summary>
        /// Defines a tool which can be downloaded if missing from an URL
        /// </summary>
        /// <param name="nuget">NuGet implementation</param>
        /// <param name="name">Unique name of this tool</param>
        /// <param name="defaultInstallLocation">Default installation location where the tool can be found</param>
        /// <param name="executableName">File name of the executable to be ran</param>
        /// <param name="packageName">The NuGet package name</param>
        /// <param name="packageVersion">The NuGEt package version</param>
        /// <param name="parameters">Application parameters</param>
        protected DownloadableNugetTool(INuGet nuget, string name, string defaultInstallLocation, string executableName, string packageName, string packageVersion, IParameters parameters)
            : base(name, defaultInstallLocation, executableName, new Uri("file:///"), true, parameters)
        {
            this.nuget                  = nuget;
            this.packageName            = packageName;
            this.packageVersion         = packageVersion;
            this.defaultInstallLocation = defaultInstallLocation;
            this.executableName         = executableName;

            bariInstallLocation =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                             "bari", "tools", name);
        }
Пример #38
0
 IResponse <T> IDataService <T> .Delete(IParameters parameters)
 {
     return(Delete(parameters));
 }
Пример #39
0
 protected virtual Task <IResponse <T> > PutAsync(T model, IParameters parameters)
 {
     throw new NotImplementedException(nameof(PutAsync));
 }
Пример #40
0
 public Key(IParameters <FipsAlgorithm> parameterSet, byte[] bytes)
     : base(parameterSet, bytes)
 {
     ValidateKeySize(bytes);
 }
Пример #41
0
 public void Initialize()
 {
     _parameters = Algorithm.Parameters;
     _minRate    = 1;
     _maxRate    = _calcCap.Invoke(Algorithm);
 }
Пример #42
0
        /// <summary>
        /// Defines a tool which can be downloaded if missing from an URL
        /// </summary>
        /// <param name="name">Unique name of this tool</param>
        /// <param name="defaultInstallLocation">Default installation location where the tool can be found</param>
        /// <param name="executableName">File name of the executable to be ran</param>
        /// <param name="url">The URL where the tool can be downloaded from </param>
        /// <param name="isDotNETProcess">If <c>true</c> the process will be executed with mono when not running on MS CLR</param>
        /// <param name="parameters">Application parameters</param>
        public DownloadableExternalTool(string name, string defaultInstallLocation, string executableName, Uri url, bool isDotNETProcess, IParameters parameters)
            : base(name, parameters)
        {
            this.defaultInstallLocation = defaultInstallLocation;
            this.executableName         = executableName;
            this.url        = url;
            isDotNetProcess = isDotNETProcess;

            bariInstallLocation =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                             "bari", "tools", name);
        }
Пример #43
0
        public CSharpOperation(string outKey, string outType, string script, Dictionary <string, Script> scripts, IParameters parameters)
            : base(string.Empty, outKey)
        {
            var csc = new CSharpCodeProvider();
            var ca  = Assembly.GetExecutingAssembly();
            var cp  = new CompilerParameters {
                GenerateInMemory = true
            };
            var testRow = new Row();

            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add("System.Core.dll");
            cp.ReferencedAssemblies.Add("mscorlib.dll");
            cp.ReferencedAssemblies.Add(ca.Location);

            var scriptBuilder = new StringBuilder(string.Empty);

            foreach (var s in scripts)
            {
                scriptBuilder.AppendLine(string.Format("// {0} script", s.Value.Name));
                scriptBuilder.AppendLine(s.Value.Content);
            }

            var castBuilder = new StringBuilder(string.Empty);

            if (!parameters.Any())
            {
                castBuilder.AppendLine(String.Format("{1} {0} = ({1}) row[\"{0}\"];", OutKey, Common.ToSystemType(outType)));
                testRow[OutKey] = new DefaultFactory(Logger).Convert(null, outType);
            }
            else
            {
                var map = Common.GetLiteral();
                foreach (var pair in parameters)
                {
                    if (pair.Value.HasValue())
                    {
                        castBuilder.AppendLine(String.Format("{0} {1} = {2};", Common.ToSystemType(pair.Value.SimpleType), pair.Value.Name, map[pair.Value.SimpleType](pair.Value.Value)));
                    }
                    else
                    {
                        castBuilder.AppendLine(String.Format("{1} {0} = ({1}) row[\"{0}\"];", pair.Value.Name, Common.ToSystemType(pair.Value.SimpleType)));
                    }
                    testRow[pair.Value.Name] = new DefaultFactory(Logger).Convert(null, pair.Value.SimpleType);
                }
            }

            var code = string.Format(@"using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Transformalize.Operations.Transform;
using Transformalize.Libs.Rhino.Etl;

{0}

public class Transformer : ITransformer
{{
    public object Transform(Row row)
    {{
        {1}
        //User's script
        {2}
    }}
}}", scriptBuilder, castBuilder, script);

            Logger.EntityDebug(EntityName, "Compiling this code:");
            Logger.EntityDebug(EntityName, code);

            var res = csc.CompileAssemblyFromSource(
                cp,
                code
                );

            if (res.Errors.Count == 0)
            {
                var type = res.CompiledAssembly.GetType("Transformer");
                _transformer = (ITransformer)Activator.CreateInstance(type);
                try {
                    var test = _transformer.Transform(testRow);
                    Logger.EntityDebug(EntityName, "CSharp transform compiled and passed test. {0}", test);
                } catch (Exception e) {
                    Logger.EntityDebug(EntityName, "CSharp transform compiled but failed test. {0}", e.Message);
                    Logger.EntityDebug(EntityName, e.StackTrace);
                }
            }
            else
            {
                foreach (var error in res.Errors)
                {
                    Logger.EntityError(EntityName, error.ToString());
                }
                throw new TransformalizeException(Logger, EntityName, "Failed to compile code. {0}", code);
            }

            Name = string.Format("CSharpOperation ({0})", outKey);
        }
Пример #44
0
        internal static IBufferedCipher CreateBufferedCipher(string name, AlgorithmMode algorithmMode, IParameters <Algorithm> parameters, Org.BouncyCastle.Crypto.Internal.IBlockCipher baseCipher)
        {
            Org.BouncyCastle.Crypto.Internal.IBlockCipher cipher;

            switch (algorithmMode)
            {
            case AlgorithmMode.ECB:
                cipher = baseCipher;
                break;

            default:
                throw new ArgumentException("Unknown algorithm mode passed to " + name + ".Provider: " + algorithmMode);
            }

            return(new BufferedBlockCipher(cipher));
        }
Пример #45
0
 /// <summary>
 /// Initializes the tool runner
 /// </summary>
 /// <param name="name">Name of the external tool, for debugging and error handling purposes</param>
 /// <param name="parameters">Parameters, to determine if running in mono mode or not</param>
 protected ExternalTool(string name, IParameters parameters)
 {
     this.name       = name;
     this.parameters = parameters;
 }
Пример #46
0
 protected Constitutive(IParameters parameters) => Parameters = parameters;
Пример #47
0
 public static void OnNavigatedTo(View view, IParameters parameters)
 {
     InvokeActionOnViewAndStateObjects <INavigationAware>(view, x => x.OnNavigatedTo(parameters));
 }
Пример #48
0
        public static IResponse <T> Delete <T>(this IDataService <T> service, IParameters parameters) where T : class, new()
        {
            IMessageContext <T> context = new MessageContext <T>().Delete(parameters);

            return(service.Delete(context).Response);
        }
Пример #49
0
 /// <summary>
 /// Defines a tool which can be downloaded if missing from an URL
 /// </summary>
 /// <param name="name">Unique name of this tool</param>
 /// <param name="defaultInstallLocation">Default installation location where the tool can be found</param>
 /// <param name="executableName">File name of the executable to be ran</param>
 /// <param name="url">The URL where the tool archive can be downloaded from </param>
 /// <param name="isDotNETProcess">If <c>true</c> the process will be executed with mono when not running on MS CLR</param>
 /// <param name="parameters">Application parameters</param>
 protected DownloadableSelfExtractingExternalTool(string name, string defaultInstallLocation, string executableName, Uri url, bool isDotNETProcess, IParameters parameters)
     : base(name, defaultInstallLocation, executableName, url, isDotNETProcess, parameters)
 {
 }
Пример #50
0
 public static Constitutive From(ConstitutiveModel constitutiveModel, IParameters parameters) =>
 constitutiveModel switch
 {
Пример #51
0
        //***********************************************************************************************
        #endregion

        #region 重写基类的方法

        public override void Init(IDBQuery dbHelper, IBizDataTransferCenter dataTransCenter, IStationInfo stationInfo, ILoginUser userData, IParameters parameters, ISysLog sysLog)
        {
            base.Init(dbHelper, dataTransCenter, stationInfo, userData, parameters, sysLog);
            //初始化ApplyControl
            applyControl.Init(_dbQuery, _dataTransCenter, _stationInfo, _userData, _parameters, _sysLog);
            SetButtonState(ButtonState.bsNormal);
        }
Пример #52
0
 public VelocityOperation(string outKey, string outType, string template, IEnumerable <KeyValuePair <string, Template> > templates, IParameters parameters)
     : base(outKey, outType, template, templates, parameters)
 {
     _context = new VelocityContext();
     Name     = "Velocity (" + outKey + ")";
 }
Пример #53
0
 /// <summary>
 /// Constructs the MSBuild runner
 /// </summary>
 /// <param name="parameters">User defined parameters for bari</param>
 /// <param name="path">Path to MSBuild.exe</param>
 protected MSBuild(IParameters parameters, string path)
     : base("msbuild", path,
            "MSBuild.exe", new Uri("http://www.microsoft.com/en-us/download/details.aspx?id=17851"), false, parameters)
 {
     this.parameters = parameters;
 }
Пример #54
0
 public PixelFilter(IParameters parameters) : base(parameters)
 {
 }
Пример #55
0
        public static IResponse <T> Put <T>(this IDataService <T> service, T model, IParameters parameters) where T : class, new()
        {
            IMessageContext <T> context = new MessageContext <T>().Put(model, parameters);

            return(service.Put(context).Response);
        }
Пример #56
0
 public abstract Pixel ProcessPixel(Pixel original, IParameters parameters);
Пример #57
0
 public FormParameters(IParameters parameters)
 {
     InitializeComponent();
     this.parameters = parameters;
     Init(parameters);
 }
Пример #58
0
 private PrtgUrl GetPrtgUrl(XmlFunction function, IParameters parameters) =>
 new PrtgUrl(prtgClient.connectionDetails, function, parameters);
Пример #59
0
 public abstract T WithParams <T>(IParameters args);
Пример #60
0
 public void MeasurementsChanged(IParameters weatherParameters)
 {
     _weatherParameters = weatherParameters;
     NotifyObservers(weatherParameters);
 }