Пример #1
0
        internal ImmutableCollection(IEnumerable <T> elements)
        {
            this.elements = elements;
            if (elements == null)
            {
                countGetter = null;
                return;
            }

            kind = EnumKind.Unknown;
            if (elements is LinkedList <T> )
            {
                kind = EnumKind.LinkedList;
            }
            else if (elements is List <T> )
            {
                kind = EnumKind.List;
            }
            else if (elements is Set <T> )
            {
                kind = EnumKind.Set;
            }

            if (kind != EnumKind.Unknown)
            {
                countGetter = null;
                return;
            }

            var countProps = elements.GetType().FindMembers(
                MemberTypes.Property,
                BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance,
                FilterCounters,
                null);

            if (countProps.Length == 1)
            {
                countGetter = ((PropertyInfo)countProps[0]).GetGetMethod();
            }
            else
            {
                countGetter = null;
            }
        }
Пример #2
0
        internal static int s_ConfigurationChangeEnumToNumber = 0; // 0 - disabled, 1 - with attribute only, 2 - all enums

        public static EnumKind IsEnum(TypeReference type)          // checks if type is Enum and should be converted to JS number
        {
            var      typedef = GetTypeDefinition(type);
            bool     isEnum  = (typedef != null) && typedef.IsEnum;
            EnumKind result  = 0;

            if (isEnum)
            {
                var attributes = typedef.CustomAttributes;
                result = (s_ConfigurationChangeEnumToNumber == 2) ||
                         (s_ConfigurationChangeEnumToNumber > 0 &&
                          attributes.Count > 0 &&
                          attributes.Any(ca => ca.AttributeType.FullName == "JSIL.Meta.JSChangeEnumToNumber")) ? EnumKind.ChangeToNumber : EnumKind.IsEnum;
                result |= (attributes.Count > 0 &&
                           attributes.Any(ca => ca.AttributeType.FullName == "System.FlagsAttribute")) ? EnumKind.FlagIsFlags : 0;
            }

            return(result);
        }
Пример #3
0
 public Car(int id, string name, DateTime yearOfProduction, decimal price, string img, string model, EnumKind typeOfFuel,
            EnumState state, int mileage)
 {
     this.Id               = id;
     this.Name             = name;
     this.YearOfProduction = yearOfProduction;
     this.Img              = img;
     this.Model            = model;
     this.TypeOfFuel       = typeOfFuel;
     this.State            = state;
     this.Mileage          = mileage;
 }
Пример #4
0
 public Enum(EnumKind enumKind, IEnumerable <long> values)
 {
     EnumKind   = enumKind;
     EnumValues = values;
 }
Пример #5
0
 public Enum(EnumKind enumKind, IEnumerable <int> values)
     : this(enumKind, values.Select(x => Convert.ChangeType(x, typeof(long))).Cast <long>())
 {
 }
Пример #6
0
 public EnumValidator(EnumKind enumKind, IEnumerable <long> values)
 {
     _enumKind       = enumKind;
     _expectedValues = values.Select(x => x.ToString()).ToList();
 }