Пример #1
0
        public DeviceTemplate(string name, JArray jobs)
        {
            Name = name;

            var jobDescs = new HashSet <JobDesc>();

            foreach (var job in jobs)
            {
                var jobName  = job.Value <string>("name");
                var interval = job.Value <int>("interval");

                if (interval <= 0)
                {
                    throw new ApplicationException(string.Format(CultureInfo.InvariantCulture, "{0}.interval = {1}. Please assign it a positive value to avoid tight loop without interval", name, interval));
                }

                var sourceDesc = FilterDesc.Create(job["sourceFilter"]);

                var intermedias     = job["intermediaFilters"] as JArray;
                var intermediaDescs = intermedias == null || intermedias.Count == 0 ?
                                      new List <FilterDesc>() :
                                      intermedias.Select(t => FilterDesc.Create(t));

                var sinkDesc = FilterDesc.Create(job["sinkFilter"]);

                var jobDesc = new JobDesc(jobName, interval, sourceDesc, intermediaDescs, sinkDesc);
                jobDescs.Add(jobDesc);
            }

            Jobs = jobDescs;
        }
Пример #2
0
        public JobDesc(string name, int interval, FilterDesc source, IEnumerable <FilterDesc> intermedias, FilterDesc sink)
        {
            Name     = name;
            Interval = interval;

            if (source == null)
            {
                throw new ApplicationException(string.Format(CultureInfo.InvariantCulture, "Missing source filter in job {0}", Name));
            }
            Source = source;

            Intermedias = new List <FilterDesc>(intermedias);

            if (sink == null)
            {
                throw new ApplicationException(string.Format(CultureInfo.InvariantCulture, "Missing sink filter in job {0}", Name));
            }
            Sink = sink;
        }