Example #1
0
        /// <summary>
        /// Creates a new instance of output parameter for the given property.
        /// </summary>
        private static BaseParameter CreateOutputParameter(GisTool tool, PropertyInfo prop, OutputAttribute attr)
        {
            var param = CreateParameter(prop.PropertyType, prop);

            param.ControlHint = prop.GetAttribute <ControlHintAttribute>();

            param.Tool         = tool;
            param.ToolProperty = prop;

            param.Name        = prop.Name;
            param.DisplayName = attr.DisplayName;
            param.Required    = true;
            param.IsInput     = false;
            param.Index       = attr.Index;

            var olp = param as OutputLayerParameter;

            if (olp != null)
            {
                var layerAttr = prop.GetAttribute <OutputLayerAttribute>();
                if (layerAttr != null)
                {
                    olp.DefaultValue    = layerAttr.NameTemplate;
                    olp.SupportInMemory = layerAttr.SupportsInMemory;
                    olp.LayerType       = layerAttr.LayerType;
                }
            }

            return(param);
        }
Example #2
0
        /// <summary>
        /// Creates parameter object for each property of the tool marked as input or output.
        /// </summary>
        public static IEnumerable <BaseParameter> CreateParameters(this GisTool tool)
        {
            var properties = tool.GetType().GetProperties();

            foreach (var prop in properties)
            {
                var attrInput = prop.GetAttribute <InputAttribute>();
                if (attrInput != null)
                {
                    yield return(CreateInputParameter(tool, prop, attrInput));
                }

                var attrOutput = prop.GetAttribute <OutputAttribute>();
                if (attrOutput != null)
                {
                    yield return(CreateOutputParameter(tool, prop, attrOutput));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new instance of the input parameter for the property.
        /// </summary>
        private static BaseParameter CreateInputParameter(GisTool tool, PropertyInfo prop, InputAttribute attr)
        {
            var param = CreateParameter(prop.PropertyType, prop);

            param.ControlHint = prop.GetAttribute <ControlHintAttribute>();

            param.IsInput      = true;
            param.Tool         = tool;
            param.ToolProperty = prop;
            param.Name         = prop.Name;
            param.Index        = attr.Index;
            param.DisplayName  = attr.DisplayName;
            param.Required     = !attr.Optional;
            param.SectionName  = attr.SectionName;

            HandleRangeAttribute(param, prop);

            HandleDefaultValueAttribute(param, prop);

            return(param);
        }