コード例 #1
0
        /// <summary>
        /// Sets the data value if empty.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="propertyKey">The property key.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="EngineException">
        /// No input property with key {propertyKey} has been registered for this element.
        /// or
        /// No output property with key {propertyKey} has been registered for this element.
        /// </exception>
        public void SetDataValueIfEmpty(EngineDataDirection direction, string propertyKey, IEngineData value)
        {
            switch (direction)
            {
            case EngineDataDirection.Input:
                var ip  = inputProperties.SingleOrDefault(p => p.Key == propertyKey);
                var ipE = moduleEntry.InputProperties.SingleOrDefault(p => p.Key == propertyKey);

                if (ip == null)
                {
                    throw new EngineException(logger, $"No input property with key {propertyKey} has been registered for this module.");
                }
                if (!ip.Value.IsFilled)
                {
                    ip.Value  = value;
                    ipE.Value = ip.Value.WriteToStringValue();
                }
                break;

            case EngineDataDirection.Output:
                var op  = outputProperties.SingleOrDefault(p => p.Key == propertyKey);
                var opE = moduleEntry.OutputProperties.SingleOrDefault(p => p.Key == propertyKey);

                if (op == null)
                {
                    throw new EngineException(logger, $"No output property with key {propertyKey} has been registered for this module.");
                }
                if (!op.Value.IsFilled)
                {
                    op.Value  = value;
                    opE.Value = op.Value.WriteToStringValue();
                }
                break;
            }
        }
コード例 #2
0
        public void SetDataValueIfEmpty(EngineDataDirection direction, string propertyKey, DataType dataType, string persistingValue)
        {
            var engineDataType = AssembliesExtensions.GetTypesImplementingInterface <IEngineData>()
                                 .FirstOrDefault(ed => (DataType)ed.GetProperty("DataTypeConst").GetValue(ed) == dataType);

            var engineDataValue = (IEngineData)Activator.CreateInstance(engineDataType);

            engineDataValue.ReadFromStringValue(persistingValue);

            SetDataValueIfEmpty(direction, propertyKey, engineDataValue);
        }
コード例 #3
0
        /// <summary>
        /// Gets the data value.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="propertyKey">The property key.</param>
        /// <returns></returns>
        /// <exception cref="EngineException">No input property with key {propertyKey} has been registered for this element.
        /// or
        /// No output property with key {propertyKey} has been registered for this element.</exception>
        public IEngineData GetDataValue(EngineDataDirection direction, string propertyKey)
        {
            switch (direction)
            {
            case EngineDataDirection.Input:
                var ip = inputProperties.SingleOrDefault(p => p.Key == propertyKey);
                if (ip == null)
                {
                    throw new EngineException(logger, $"No input property with key {propertyKey} has been registered for this module.");
                }
                return(ip.Value);

            case EngineDataDirection.Output:
                var op = outputProperties.SingleOrDefault(p => p.Key == propertyKey);
                if (op == null)
                {
                    throw new EngineException(logger, $"No output property with key {propertyKey} has been registered for this module.");
                }
                return(op.Value);
            }
            return(null);
        }