Esempio n. 1
0
 private static void CheckMandatoryFlowObjectProperty(object flowObject,
                                                      FlowObjectProperty flowObjectProperty, ICollection <string> missingPropertyNames)
 {
     if (flowObjectProperty.IsNotNullValue && (flowObjectProperty.PropertyInfo.GetValue(flowObject) == null))
     {
         missingPropertyNames.Add(flowObjectProperty.PropertyInfo.Name);
     }
 }
Esempio n. 2
0
 private static void SetFlowResponseProperty(TFlowResponse flowResponse,
                                             FlowObjectProperty flowResponseProperty, FlowValues flowValues)
 {
     if (flowValues.TryGetValue(flowResponseProperty.PropertyInfo.Name, out var flowValue))
     {
         flowResponseProperty.PropertyInfo.SetValue(flowResponse, flowValue);
     }
 }
Esempio n. 3
0
        public FlowValueOutputBinding GetOutputBinding(FlowObjectProperty flowObjectProperty)
        {
            var binding =
                this.Outputs.Find(i => i.Property.Name == flowObjectProperty.Name)
                ?? new FlowValueOutputBinding(flowObjectProperty);

            return(binding);
        }
Esempio n. 4
0
        public FlowObjectType(Type type)
        {
            var publicInstanceProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            var internalPropertyNames = new[]
            {
                nameof(IFlowStepRequest.FlowContext),
                nameof(DecisionFlowStepBase.Branches),
                nameof(FlowResponse.CorrelationId),
                nameof(FlowResponse.RequestId),
                nameof(FlowResponse.FlowInstanceId),
                nameof(FlowResponse.Trace)
            };

            var externalProperties =
                Array.FindAll(publicInstanceProperties, p =>
                              !Regex.IsMatch(p.Name, $"({string.Join("|", internalPropertyNames)})"));

            var flowObjectProperties = new List <FlowObjectProperty>();

            foreach (var externalProperty in externalProperties)
            {
                var customAttributes = externalProperty.GetCustomAttributes(inherit: false);

                var flowObjectProperty = new FlowObjectProperty
                {
                    Name                = externalProperty.Name,
                    PropertyInfo        = externalProperty,
                    IsNotNullValue      = customAttributes.Any(a => a is NotNullValueAttribute),
                    IsPrivate           = customAttributes.Any(a => a is SensitiveValueAttribute),
                    IsDictionaryBinding =
                        externalProperty.PropertyType.IsGenericType &&
                        externalProperty.PropertyType.GetGenericTypeDefinition() == typeof(FlowValueDictionary <>),
                    IsOverridableValue = customAttributes.Any(a => a is OverridableValueAttribute),
                    Description        =
                        ((DescriptionAttribute)customAttributes.FirstOrDefault(a => a is DescriptionAttribute))?.Description,
                };

                if (flowObjectProperty.IsDictionaryBinding)
                {
                    flowObjectProperty.DictionaryValueType = externalProperty.PropertyType.GenericTypeArguments.First();
                    flowObjectProperty.DictionaryType      =
                        typeof(FlowValueDictionary <>).MakeGenericType(flowObjectProperty.DictionaryValueType);
                }

                flowObjectProperties.Add(flowObjectProperty);
            }

            Properties = flowObjectProperties.ToArray();
        }
Esempio n. 5
0
        internal FlowValueInputBinding GetInputBinding(FlowObjectProperty flowObjectProperty)
        {
            var binding =
                this.Inputs.Find(i => i.Property.Name == flowObjectProperty.Name)
                ?? (flowObjectProperty.IsDictionaryBinding
                    ? new FlowValueInputBinding(flowObjectProperty)
            {
                FlowValueSelector = new FlowValueTypeSelector(flowObjectProperty.DictionaryValueType)
            }
                    : new FlowValueInputBinding(flowObjectProperty)
            {
                FlowValueSelector = new FlowValueSingleSelector(flowObjectProperty.Name)
            });

            return(binding);
        }
Esempio n. 6
0
 protected FlowValueBinding(FlowObjectProperty property)
 {
     this.Property = property ?? throw new ArgumentNullException(nameof(property));
 }
Esempio n. 7
0
 public FlowValueInputBinding(FlowObjectProperty property) : base(property)
 {
 }