public CollectionValueBridge(RewriteDesign design, ITypeSymbol type, ValueBridge name, bool reuse) : base(null as TypeSyntax, name) { ItemType = SyntaxFactory.ParseTypeName(SymbolExtensions.GetItemType(type).ToDisplayString()); Type = SyntaxFactory.ParseTypeName(type.ToDisplayString()); if (type is IArrayTypeSymbol) { CollectionType = CollectionType.Array; } else { var displayString = type.ToDisplayString(); if (displayString.StartsWith("LinqRewrite.Core.SimpleList.SimpleList<")) { CollectionType = CollectionType.SimpleList; } else if (displayString.StartsWith("System.Collections.Generic.List<")) { CollectionType = CollectionType.List; } else if (displayString.StartsWith("System.Collections.Generic.IList<") || type.AllInterfaces.Any(x => x.ToDisplayString().StartsWith("System.Collections.Generic.IList<"))) { CollectionType = CollectionType.IList; } else { CollectionType = CollectionType.IEnumerable; } } Count = CodeCreationService.CreateCollectionCount(Value, CollectionType); if (CollectionType == CollectionType.IEnumerable) { return; } if (reuse) { Value = name.ReusableConst(design, Type, CollectionType == CollectionType.SimpleList ? true : (bool?)null); } if (reuse) { Count = Count.ReusableConst(design, Int); } }
public CollectionValueBridge(RewriteDesign design, TypeBridge collectionType, TypeBridge itemType, ValueBridge name, bool reuse) : base(collectionType, name) { ItemType = itemType; if (collectionType.Type is ArrayTypeSyntax) { CollectionType = CollectionType.Array; } else { var displayString = collectionType.Type.ToString(); if (displayString.StartsWith("LinqRewrite.Core.SimpleList.SimpleList<")) { CollectionType = CollectionType.SimpleList; } else if (displayString.StartsWith("System.Collections.Generic.List<")) { CollectionType = CollectionType.List; } else if (displayString.StartsWith("System.Collections.Generic.IList<")) { CollectionType = CollectionType.IList; } else { CollectionType = CollectionType.IEnumerable; } } Count = CodeCreationService.CreateCollectionCount(Value, CollectionType); if (CollectionType == CollectionType.IEnumerable) { return; } if (reuse) { Value = name.ReusableConst(design, Type, CollectionType == CollectionType.SimpleList ? true : (bool?)null); } if (reuse) { Count = Count.ReusableConst(design, Int); } }