コード例 #1
0
ファイル: IdleXmlInterpreter.cs プロジェクト: g4idrijs/DIPS
        /// <summary>
        /// Converts the provided Xml back into the appropriate parameter
        /// object for the algorithm
        /// </summary>
        /// <param name="parameterXml">The <see cref="XElement"/> describing the properties
        /// within the object.</param>
        /// <returns>The appropriate object used to describe the parameters
        /// for the process.</returns>
        public ICloneable CreateObject(XElement parameterXml)
        {
            IdleProperties p = new IdleProperties();

            if (parameterXml == null)
            {
                return(p);
            }

            XElement props = parameterXml.Descendants("property").FirstOrDefault();

            if (props == null)
            {
                return(p);
            }

            XAttribute secondsAttr = props.Attribute("seconds");

            if (secondsAttr != null)
            {
                int seconds = 0;
                int.TryParse(secondsAttr.Value, out seconds);
                p.Seconds = seconds;
            }

            return(p);
        }
コード例 #2
0
ファイル: Idle.cs プロジェクト: g4idrijs/DIPS
        /// <summary>
        /// Executes the algorithm represented by this <see cref="AlgorithmPlugin"/>.
        /// </summary>
        /// <param name="parameterObject">An object of the type provided by the
        /// <see cref="AlgorithmAttribute"/> describing the properties used by this
        /// <see cref="AlgorithmPlugin"/>.</param>
        /// <exception cref="AlgorithmException">an internal exception has occured. This
        /// is accessed through the inner exception property.</exception>
        public override void Run(object parameterObject)
        {
            IdleProperties p = parameterObject as IdleProperties;

            if (p != null)
            {
                // 'Seconds' is actually ms, so multiply up to seconds
                Thread.Sleep(p.Seconds * 1000);
            }
        }
コード例 #3
0
ファイル: IdleXmlInterpreter.cs プロジェクト: g4idrijs/DIPS
        /// <summary>
        /// Converts the parameter object provided by the
        /// <see cref="AlgorithmDefinition"/> containing the properties
        /// to persist.
        /// </summary>
        /// <param name="parameterObject">The value of the algorithms
        /// parameter object</param>
        /// <returns>The <see cref="XElement"/> describing the properties
        /// within the object.</returns>
        public XElement CreateXml(ICloneable parameterObject)
        {
            IdleProperties p = parameterObject as IdleProperties;

            if (p == null)
            {
                return(new XElement("properties"));
            }

            XElement secondsE = new XElement("property",
                                             new XAttribute("seconds", p.Seconds));

            return(new XElement("properties", secondsE));
        }