Ejemplo n.º 1
0
        public override MultiValue VisitArrayCreation(IArrayCreationOperation operation, StateValue state)
        {
            var value = base.VisitArrayCreation(operation, state);

            // Don't track multi-dimensional arrays
            if (operation.DimensionSizes.Length != 1)
            {
                return(TopValue);
            }

            // Don't track large arrays for performance reasons
            if (operation.Initializer?.ElementValues.Length >= MaxTrackedArrayValues)
            {
                return(TopValue);
            }

            var arrayValue = ArrayValue.Create(Visit(operation.DimensionSizes[0], state));
            var elements   = operation.Initializer?.ElementValues.Select(val => Visit(val, state)).ToArray() ?? System.Array.Empty <MultiValue> ();

            foreach (var array in arrayValue.Cast <ArrayValue> ())
            {
                for (int i = 0; i < elements.Length; i++)
                {
                    array.IndexValues.Add(i, elements[i]);
                }
            }

            return(arrayValue);
        }
Ejemplo n.º 2
0
        public override MultiValue VisitFieldReference(IFieldReferenceOperation fieldRef, StateValue state)
        {
            var field = fieldRef.Field;

            switch (field.Name)
            {
            case "EmptyTypes" when field.ContainingType.IsTypeOf("System", "Type"): {
                return(ArrayValue.Create(0));
            }

            case "Empty" when field.ContainingType.IsTypeOf("System", "String"): {
                return(new KnownStringValue(string.Empty));
            }
            }

            if (TryGetConstantValue(fieldRef, out var constValue))
            {
                return(constValue);
            }

            if (fieldRef.Field.Type.IsTypeInterestingForDataflow())
            {
                return(new FieldValue(fieldRef.Field));
            }

            return(TopValue);
        }
Ejemplo n.º 3
0
 public override Value GetValue(UserItem item)
 {
     if (item.Item is Audio audio)
     {
         return(ArrayValue <StringValue> .Create(audio.AlbumArtists.Select(StringValue.Create).ToArray()));
     }
     return(Value.None);
 }
Ejemplo n.º 4
0
        public override Value GetValue(UserItem item)
        {
            if (item.Item is Video video && video.SupportsPeople)
            {
                var peoples = BaseItem.LibraryManager.GetItemPeople(item.Item);

                return(ArrayValue <StringValue> .Create(peoples.Where(x => PersonTypes.Any(x.IsType))
                                                        .Select(x => x.Name)?.Select(StringValue.Create).ToArray()));
            }

            return(Value.None);
        }
 public override Value GetValue(UserItem item)
 {
     return(ArrayValue <StringValue> .Create(item.Item.Tags?.Select(StringValue.Create).ToArray()));
 }