Пример #1
0
        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);
            }
        }
Пример #2
0
 public TypedValueBridge(TypeBridge type, ValueBridge name) : base(name)
 {
     Type  = type;
     Value = name;
 }
Пример #3
0
 public TypedValueBridge(RewriteDesign design, ValueBridge value) : base(value)
 {
     Type  = value.GetType(design);
     Value = value;
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
 public new TypedValueBridge this[ValueBridge i] => new TypedValueBridge(ItemType, this.ArrayAccess(i));
Пример #6
0
 public RewrittenValueBridge(ExpressionSyntax old) : base(old)
 {
     New = Old = old;
 }
Пример #7
0
 public RewrittenValueBridge(ExpressionSyntax old, ExpressionSyntax @new) : base(@new ?? old)
 {
     Old = old;
     New = Value;
 }
Пример #8
0
 public RewrittenValueBridge(ValueBridge old, ValueBridge @new) : base(@new?.Value == null ? old : @new)
 {
     Old = old;
     New = Value;
 }
Пример #9
0
 public ValueBridge this[ValueBridge i] => this.ArrayAccess(i);