Exemple #1
0
 public ValueSpecification(string valueName, ComputationTargetSpecification targetSpecification, ValueProperties properties)
 {
     ArgumentChecker.NotNull(valueName, "valueName");
     ArgumentChecker.NotNull(targetSpecification, "targetSpecification");
     ArgumentChecker.NotNull(properties, "properties");
     _valueName           = string.Intern(valueName); //Should be a small static set
     _targetSpecification = targetSpecification;
     _properties          = properties;
 }
            public override bool Equals(ValueProperties other)
            {
                var nearlyInfiniteValueProperties = other as NearlyInfiniteValueProperties;

                if (nearlyInfiniteValueProperties == null)
                {
                    return(false);
                }
                return(nearlyInfiniteValueProperties.Without.SetEquals(nearlyInfiniteValueProperties.Without));
            }
Exemple #3
0
        public static ValueRequirement FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            ValueProperties constraints = deserializer.FromField <ValueProperties>(ffc.GetByName("constraints")) ?? ValueProperties.Create();

            var computationTargetType       = ffc.GetValue <string>("computationTargetType");
            var computationTargetIdentifier = GetUniqueIdentifier(ffc, deserializer, "computationTargetIdentifier");
            var targetSpec = new ComputationTargetSpecification(EnumBuilder <ComputationTargetType> .Parse(computationTargetType), computationTargetIdentifier);
            var valueName  = ffc.GetValue <string>("valueName");

            return(new ValueRequirement(valueName, targetSpec, constraints));
        }
            public override bool IsSatisfiedBy(ValueProperties properties)
            {
                //Common case first
                var finProps = properties as FiniteValueProperties;

                if (finProps != null)
                {
                    foreach (var propertyValue in PropertyValues)
                    {
                        if (_optional != null && _optional.Contains(propertyValue.Key))
                        {
                            continue;
                        }
                        ISet <string> other;
                        if (!finProps.PropertyValues.TryGetValue(propertyValue.Key, out other))
                        {
                            return(false);
                        }
                        if (!other.Any() || !propertyValue.Value.Any())
                        {
                            //wildcards
                            continue;
                        }
                        if (!propertyValue.Value.IsSubsetOf(other))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                if (InfiniteValueProperties.Instance.IsSatisfiedBy(properties))
                {
                    return(true);
                }
                if (properties is EmptyValueProperties)
                {
                    return(false);
                }
                var niProps = properties as NearlyInfiniteValueProperties;

                if (niProps != null)
                {
                    return(!niProps.Without.Any(p => PropertyValues.ContainsKey(p) && (_optional == null || !_optional.Contains(p))));
                }
                throw new ArgumentException();
            }
            public override bool Equals(ValueProperties other)
            {
                var finiteOther = other as FiniteValueProperties;

                if (finiteOther == null)
                {
                    return(false);
                }

                if (_optional == null ^ finiteOther._optional == null)
                {
                    return(false);
                }
                if (_optional != null && !_optional.SetEquals(finiteOther._optional))
                {
                    return(false);
                }
                if (PropertyValues.Count != finiteOther.PropertyValues.Count)
                {
                    return(false);
                }
                foreach (var propertyValue in PropertyValues)
                {
                    var           value = propertyValue.Value;
                    ISet <string> otherValue;
                    if (!finiteOther.PropertyValues.TryGetValue(propertyValue.Key, out otherValue))
                    {
                        return(false);
                    }
                    if (!value.SetEquals(otherValue))
                    {
                        return(false);
                    }
                }
                return(true);
            }
 public override bool Equals(ValueProperties other)
 {
     return(ReferenceEquals(Instance, other));
 }
 public override bool IsSatisfiedBy(ValueProperties properties)
 {
     return(true);
 }
 public override bool IsSatisfiedBy(ValueProperties properties)
 {
     return(InfiniteValueProperties.Instance.IsSatisfiedBy(properties) ||
            (properties is NearlyInfiniteValueProperties &&
             ((NearlyInfiniteValueProperties)properties).Without.IsSubsetOf(Without)));
 }
 public override bool IsSatisfiedBy(ValueProperties properties)
 {
     return(properties == Instance);
 }
Exemple #10
0
 public ValueRequirement(string valueName, ComputationTargetSpecification targetSpecification, ValueProperties constraints)
 {
     _valueName           = string.Intern(valueName); //Should be small static set
     _constraints         = constraints;
     _targetSpecification = targetSpecification;
 }
Exemple #11
0
 public ValueRequirement(string valueName, ComputationTargetSpecification targetSpecification) : this(valueName, targetSpecification, ValueProperties.Create())
 {
 }