protected CompositeModelInfo ResolveModelInfo(
            SetQuery <CompositeModelInfo> set,
            IEnumerable <Type> types
            )
        {
            CompositeModelInfo result = null;

            CompositeModelInfo[] modelInfos = set.Where(kvp => types.All(type => kvp.Model.PublicTypes.Any(pType => type.IsAssignableFrom(pType) || (type.IsGenericType() && pType.Equals(type.GetGenericTypeDefinition()))))).Select(kvp => kvp).ToArray();
            if (modelInfos.Length > 0)
            {
                if (modelInfos.Length == 1)
                {
                    result = modelInfos[0];
                }
                else
                {
                    result = modelInfos.FirstOrDefault(info => types.All(type => info.Model.PublicTypes.Contains(type)));
                    if (result == null)
                    {
                        throw new AmbiguousTypeException(types, modelInfos.Select(info => info.Model.PublicTypes));
                    }
                }
            }
            if (result == null)
            {
                throw new NoSuchCompositeTypeException(types);
            }
            return(result);
        }
        public override int GetHashCode()
        {
            int hashCode = 1871698487;

            if (SortedAttributeQuery != null)
            {
                hashCode += SortedAttributeQuery.GetHashCode();
            }

            if (ExactQuery != null)
            {
                hashCode += ExactQuery.GetHashCode();
            }

            if (SetQuery != null)
            {
                hashCode += SetQuery.GetHashCode();
            }

            if (PrefixQuery != null)
            {
                hashCode += PrefixQuery.GetHashCode();
            }

            if (RangeQuery != null)
            {
                hashCode += RangeQuery.GetHashCode();
            }

            if (TextQuery != null)
            {
                hashCode += TextQuery.GetHashCode();
            }

            if (ItemsForTaxQuery != null)
            {
                hashCode += ItemsForTaxQuery.GetHashCode();
            }

            if (ItemsForModifierListQuery != null)
            {
                hashCode += ItemsForModifierListQuery.GetHashCode();
            }

            if (ItemsForItemOptionsQuery != null)
            {
                hashCode += ItemsForItemOptionsQuery.GetHashCode();
            }

            if (ItemVariationsForItemOptionValuesQuery != null)
            {
                hashCode += ItemVariationsForItemOptionValuesQuery.GetHashCode();
            }

            return(hashCode);
        }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"SortedAttributeQuery = {(SortedAttributeQuery == null ? "null" : SortedAttributeQuery.ToString())}");
     toStringOutput.Add($"ExactQuery = {(ExactQuery == null ? "null" : ExactQuery.ToString())}");
     toStringOutput.Add($"SetQuery = {(SetQuery == null ? "null" : SetQuery.ToString())}");
     toStringOutput.Add($"PrefixQuery = {(PrefixQuery == null ? "null" : PrefixQuery.ToString())}");
     toStringOutput.Add($"RangeQuery = {(RangeQuery == null ? "null" : RangeQuery.ToString())}");
     toStringOutput.Add($"TextQuery = {(TextQuery == null ? "null" : TextQuery.ToString())}");
     toStringOutput.Add($"ItemsForTaxQuery = {(ItemsForTaxQuery == null ? "null" : ItemsForTaxQuery.ToString())}");
     toStringOutput.Add($"ItemsForModifierListQuery = {(ItemsForModifierListQuery == null ? "null" : ItemsForModifierListQuery.ToString())}");
     toStringOutput.Add($"ItemsForItemOptionsQuery = {(ItemsForItemOptionsQuery == null ? "null" : ItemsForItemOptionsQuery.ToString())}");
     toStringOutput.Add($"ItemVariationsForItemOptionValuesQuery = {(ItemVariationsForItemOptionValuesQuery == null ? "null" : ItemVariationsForItemOptionValuesQuery.ToString())}");
 }
        public CompositeModelInfo GetCompositeModelInfo(CompositeModelType modelType, IEnumerable <Type> compositeTypes)
        {
            ArgumentValidator.ValidateNotNull("Composite model type", modelType);
            ArgumentValidator.ValidateNotNull("Composite types", compositeTypes);

            CompositeModelInfo            result = null;
            SetQuery <CompositeModelInfo> dic    = null;

            if (this._compositeModels.TryGetValue(modelType, out dic))
            {
                result = this.ResolveModelInfo(dic, compositeTypes);
            }
            return(result);
        }
        public ModelInfoContainerImpl(
            DictionaryQuery <CompositeModelType, CompositeModelTypeInstanceScopeSupport> modelSupport,
            SetQuery <CompositeModel> models,
            ApplicationValidationResultIQ validationResult,
            DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults,
            CollectionsFactory collectionsFactory,
            Type genericPropertyMixinType,
            Type genericEventMixinType
            )
        {
            ArgumentValidator.ValidateNotNull("Model support", modelSupport);
            ArgumentValidator.ValidateNotNull("Models", models);
            ArgumentValidator.ValidateNotNull("Validation result", validationResult);

            PublicCompositeTypeGenerationResult[] typeGenResults = new PublicCompositeTypeGenerationResult[models.Count];
            Int32 gIdx = 0;

            foreach (CompositeModel model in models)
            {
                typeGenResults[gIdx] = loadingResults[model];
                ++gIdx;
            }

            this._compositeModels = collectionsFactory.NewDictionaryProxy <CompositeModelType, SetQuery <CompositeModelInfo> >(
                models
                .Select(model => model.ModelType)
                .Distinct()
                .ToDictionary(
                    modelType => modelType,
                    modelType2 =>
                    collectionsFactory.NewSetProxy <CompositeModelInfo>(new HashSet <CompositeModelInfo>(models
                                                                                                         .Select((modelInner, idx) => new KeyValuePair <CompositeModel, PublicCompositeTypeGenerationResult>(modelInner, typeGenResults[idx]))
                                                                                                         .Where(kvp => kvp.Key.ModelType.Equals(modelType2))
                                                                                                         .Select(kvp => new ModelInfoImpl(kvp.Key, kvp.Value, collectionsFactory)),
                                                                                                         ReferenceEqualityComparer <CompositeModelInfo> .ReferenceBasedComparer)).CQ
                    )
                ).CQ;
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CatalogQuery other &&
                   ((SortedAttributeQuery == null && other.SortedAttributeQuery == null) || (SortedAttributeQuery?.Equals(other.SortedAttributeQuery) == true)) &&
                   ((ExactQuery == null && other.ExactQuery == null) || (ExactQuery?.Equals(other.ExactQuery) == true)) &&
                   ((SetQuery == null && other.SetQuery == null) || (SetQuery?.Equals(other.SetQuery) == true)) &&
                   ((PrefixQuery == null && other.PrefixQuery == null) || (PrefixQuery?.Equals(other.PrefixQuery) == true)) &&
                   ((RangeQuery == null && other.RangeQuery == null) || (RangeQuery?.Equals(other.RangeQuery) == true)) &&
                   ((TextQuery == null && other.TextQuery == null) || (TextQuery?.Equals(other.TextQuery) == true)) &&
                   ((ItemsForTaxQuery == null && other.ItemsForTaxQuery == null) || (ItemsForTaxQuery?.Equals(other.ItemsForTaxQuery) == true)) &&
                   ((ItemsForModifierListQuery == null && other.ItemsForModifierListQuery == null) || (ItemsForModifierListQuery?.Equals(other.ItemsForModifierListQuery) == true)) &&
                   ((ItemsForItemOptionsQuery == null && other.ItemsForItemOptionsQuery == null) || (ItemsForItemOptionsQuery?.Equals(other.ItemsForItemOptionsQuery) == true)) &&
                   ((ItemVariationsForItemOptionValuesQuery == null && other.ItemVariationsForItemOptionValuesQuery == null) || (ItemVariationsForItemOptionValuesQuery?.Equals(other.ItemVariationsForItemOptionValuesQuery) == true)));
        }
Example #7
0
 internal SetQueryOfMutablesImpl(SetQuery <TValueImmutable> immutableQuery, SetQueryOfQueries <TValueQuery, TValueImmutable> cmq, SetState <TValue> state)
     : base(immutableQuery, cmq, state)
 {
     this._state = state;
 }
Example #8
0
 internal FastSetQueryOfQueriesImpl(SetQuery <TValueImmutable> immutableQuery, FastSetState <TValue, TValueQuery, TValueImmutable> state)
     : base(immutableQuery, state)
 {
     this._state = state;
 }
Example #9
0
 internal SetQueryOfQueriesImpl(SetQuery <TValueImmutable> iq, SetState <TValue> state)
     : base(iq, state)
 {
     this._state = state;
 }