public override Task SafeExecute(QueryContext <IProcessor> args)
        {
            // Get needed properties.
            var element   = args.GetPropertyValueOrNull <XElement>(GetProcessorProperties.XElement);
            var attribute = args.GetPropertyValueOrNull <string>(GetProcessorProperties.ProcessorTypeAttribute);

            // Check attribute presence.
            XAttribute typeAttribute = element.Attribute(attribute);

            if (typeAttribute == null)
            {
                args.AddWarning($"Attribute that should contain processor type [{attribute}] was not found. Try reviewing the XML element.");
                return(Done);
            }

            // Get processor type name and assembly.
            var processorType = typeAttribute.Value;

            // Add property to the dictionary.
            if (!string.IsNullOrWhiteSpace(processorType))
            {
                args.AddOrSkipPropertyIfExists(GetProcessorProperties.ProcessorTypeString, processorType);
            }
            else
            {
                args.AddWarning("The processor type contains an empty string.");
            }

            return(Done);
        }
Beispiel #2
0
        public override Task SafeExecute(QueryContext <IProcessor> args)
        {
            var instance = args.GetPropertyValueOrNull <object>(GetProcessorProperties.Instance);

            if (!(instance is IProcessor result))
            {
                args.AddWarning("Cannot create a processor that is not inherited from IProcessor.");
                return(Done);
            }

            args.SetResultWithInformation(result, $"Processor created.");

            return(Done);
        }
        public override Task SafeExecute(QueryContext <IProcessor> args)
        {
            var type       = args.GetPropertyValueOrNull <string>(GetProcessorProperties.ProcessorTypeString);
            var typeObject = Type.GetType(type);

            if (typeObject == null)
            {
                args.AddWarning($"Cannot obtain a type of the processor [{type}].");
                return(Done);
            }

            args.AddOrSkipPropertyIfExists(GetProcessorProperties.ProcessorType, typeObject);
            return(Done);
        }