public void BorderStyleDisabledCustom()
        {
            var propertyIndex = 9;
            var expectedValue = EnumHelpers.GetRandomValue <CSSBorderStyle>(SuggestedActionsOptions.Defaults.BorderStyle);

            var src = new SuggestedActionsOptions(true)
            {
                BorderStyle = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue);
        }
Ejemplo n.º 2
0
            public ChromaScalerConfigDialog()
            {
                InitializeComponent();

                var descs = EnumHelpers.GetDescriptions <Presets>().Where(d => d != "Custom");

                foreach (var desc in descs)
                {
                    PresetBox.Items.Add(desc);
                }

                PresetBox.SelectedIndex = (int)Presets.Custom;
            }
        public void LayoutCustom()
        {
            var propertyIndex = 2;
            var expectedValue = EnumHelpers.GetRandomValue <SuggestedActionLayoutSetting>(
                SuggestedActionsCommonOptions.Defaults.Layout);

            var src = new SuggestedActionsCommonOptions {
                Layout = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue);
        }
            public ResizerConfigDialog()
            {
                InitializeComponent();

                var descs = EnumHelpers.GetDescriptions <ResizerOption>();

                foreach (var desc in descs)
                {
                    listBox.Items.Add(desc);
                }

                listBox.SelectedIndex = 0;
            }
        public async Task <IActionResult> Get(string listFor, string listForId)
        {
            var benefitForType = EnumHelpers.GetEnum <BenefitForType>(listFor);

            var benefits = await _benefitsViewService.GetForCategorised(benefitForType, listForId);

            if (benefits == null)
            {
                return(NotFound($"Benefits not found for type {listForId} with id {listFor}."));
            }

            return(Ok(benefits));
        }
            public ImageProcessorConfigDialog()
            {
                InitializeComponent();

                var descs = EnumHelpers.GetDescriptions <ImageProcessorUsage>();

                foreach (var desc in descs)
                {
                    comboBoxUsage.Items.Add(desc);
                }

                comboBoxUsage.SelectedIndex = 0;
            }
Ejemplo n.º 7
0
        public void BackgroundColorBotCustom()
        {
            var propertyIndex = 3;
            var expectedValue = EnumHelpers.GetRandomValue <KnownColor>().ToString();

            var aa = new AvatarOptions(true)
            {
                BackgroundColor = expectedValue
            };
            var so = PopulateOptions(aa);

            AssertPopulatedProperty(so, propertyIndex, expectedValue);
        }
        private Permission[] GetPermissions(string policyName)
        {
            var permissionsStart             = policyName.Substring(POLICY_PREFIX.Length);
            var permissions                  = permissionsStart.Split('|', StringSplitOptions.RemoveEmptyEntries);
            List <Permission> permissionList = new List <Permission>();

            foreach (string permission in permissions)
            {
                permissionList.Add(EnumHelpers <Permission> .GetValueFromName(permission));
            }

            return(permissionList.ToArray());
        }
Ejemplo n.º 9
0
        static void CreateDds(GraphicsDevice device, TileSetLoader loader, string dstPath)
        {
            int numDistinctBitmaps = EnumHelpers.GetEnumMax <SymbolID>() + 1;

            const int bytesPerPixel = 4;
            int       maxTileSize   = 64;
            int       mipLevels     = 6;   // 64, 32, 16, 8, 4, 2

            var atlasTexture = Texture2D.New(device, maxTileSize, maxTileSize, mipLevels,
                                             SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm, TextureFlags.None, numDistinctBitmaps,
                                             D3D11.ResourceUsage.Default);

            //int autoGenMipLevel = 0;

            for (int mipLevel = 0; mipLevel < mipLevels; ++mipLevel)
            {
                int tileSize = maxTileSize >> mipLevel;

                /*
                 * if (tileSet.HasTileSize(tileSize) == false)
                 * {
                 *      autoGenMipLevel = mipLevel - 1;
                 *      break;
                 * }
                 */

                // leave the first one (Undefined) empty
                for (int i = 1; i < numDistinctBitmaps; ++i)
                {
                    var bmp = loader.GetTileBitmap((SymbolID)i, tileSize);

                    int pitch = tileSize * bytesPerPixel;

                    var arr = new uint[tileSize * tileSize];

                    bmp.CopyPixels(arr, pitch, 0);

                    using (var txt = Texture2D.New(device, tileSize, tileSize, SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm, arr))
                        device.Copy(txt, 0, atlasTexture, atlasTexture.GetSubResourceIndex(i, mipLevel));
                }
            }

            // Generate mipmaps for the smallest tiles
            //atlasTexture.FilterTexture(device.ImmediateContext, autoGenMipLevel, FilterFlags.Triangle);

            string path = Path.Combine(dstPath, "TileSet.dds");

            atlasTexture.Save(path, ImageFileType.Dds);

            Console.WriteLine("Generated TileSet to {0}", path);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Get your friend updates.
        /// </summary>
        /// <param name="type">An update type.</param>
        /// <param name="filter">An update filter.</param>
        /// <param name="maxUpdates">A maximum amount of updates.</param>
        /// <returns>Readonly friends update list.</returns>
        /// <remarks>Get the same data you see on your homepage.</remarks>
        public async Task <IReadOnlyList <Update> > GetFriendsUpdates(
            UpdateType?type     = null,
            UpdateFilter?filter = null,
            int?maxUpdates      = null)
        {
            var endpoint = @"updates/friends";

            var parameters = new List <Parameter>();

            if (type.HasValue)
            {
                var parameter = new Parameter
                {
                    Name  = EnumHelpers.QueryParameterKey <UpdateType>(),
                    Value = EnumHelpers.QueryParameterValue(type.Value),
                    Type  = ParameterType.QueryString
                };

                parameters.Add(parameter);
            }

            if (filter.HasValue)
            {
                var parameter = new Parameter
                {
                    Name  = EnumHelpers.QueryParameterKey <UpdateFilter>(),
                    Value = EnumHelpers.QueryParameterValue(filter.Value),
                    Type  = ParameterType.QueryString
                };

                parameters.Add(parameter);
            }

            if (maxUpdates.HasValue)
            {
                var parameter = new Parameter
                {
                    Name  = "max_updates",
                    Value = maxUpdates.Value,
                    Type  = ParameterType.QueryString
                };

                parameters.Add(parameter);
            }

            var res = await Connection.ExecuteRaw(endpoint, parameters);

            var paginated = await Connection.ExecuteRequest <PaginatedList <Update> >(endpoint, parameters, null, "updates");

            return(paginated?.List ?? new List <Update>());
        }
Ejemplo n.º 11
0
        public static T FromStringConstant <T>(this string value) where T : struct
        {
            var option = typeof(T).GetTypeInfo()
                         .DeclaredFields
                         .FirstOrDefault(
                f => f.GetCustomAttributes(
                    typeof(StringConstantAttribute),
                    false)
                .Any(a => ((StringConstantAttribute)a).GetStringConstant() == value));

            return(option == null
                       ? EnumHelpers.Default <T>()
                       : Enum <T> .Parse(option.Name));
        }
Ejemplo n.º 12
0
        private async void Connect()
        {
            try
            {
                Error = "";
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(Ip), Port);
                ConnectInProgress = true;
                Error             = "Csatlakozás folyamatban...";
                await _client.Connect(endpoint, PlayerName);

                ConnectionStatus = $"Csatlakozva, kapott szín: {EnumHelpers.GetDescription(_client.Player)}\nJátékfázis: {EnumHelpers.GetDescription(_client.GameStage)}";
                Error            = "";
                _playerList.SynchronizeListWithClient();
                SelectedGameStage = _client.GameStage;
                if (SelectedGameStage == GameStage.First)
                {
                    SelectedLayout = ShipLayout.Small;
                }
                else if (SelectedGameStage == GameStage.Second)
                {
                    SelectedLayout = ShipLayout.Medium;
                }
                else
                {
                    LayoutOptions = new ObservableCollection <ShipLayout>()
                    {
                        ShipLayout.BigLong,
                        ShipLayout.BigWide
                    };
                    SelectedLayout = ShipLayout.BigWide;
                }
                OnPropertyChanged(nameof(IsConnected));
            }
            catch (ConnectionRefusedException)
            {
                Error = "A megadott játékhoz már nem lehet csatlakozni.";
            }
            catch (TimeoutException)
            {
                Error = "Nem jött létre a kapcsolat az időlimiten belül.";
            }
            catch (Exception)
            {
                Error = $"A megadott címen nem található játék!";
            }
            finally
            {
                ConnectInProgress = false;
            }
        }
Ejemplo n.º 13
0
        private object Deserialize(string str)
        {
            var cache = typeof(TEnum).GetTypeCache();

            foreach (var field in cache.Cache.Fields)
            {
                var attribute = field.GetAttribute <DescriptionAttribute>();

                if (attribute != null)
                {
                    if (attribute.Description == str)
                    {
                        return((TEnum)field.Field.GetValue(null));
                    }
                }
                else
                {
                    if (field.Field.Name == str)
                    {
                        return((TEnum)field.Field.GetValue(null));
                    }
                }
            }

            //Failed to resolve value to DescriptionAttribute. Try XmlEnum
            var val = EnumHelpers.XmlToEnum(str, typeof(TEnum), typeof(XmlEnumAttribute), false, true, false);

            if (val != null)
            {
                return(val);
            }

            TEnum value;

            if (Enum.TryParse(str, true, out value))
            {
                var description = ((Enum)(object)value).GetEnumFieldCache().GetAttribute <DescriptionAttribute>();

                if (description != null)
                {
                    StringValue = description.Description;
                }

                return(value);
            }

            return(null);

            //its either gonna be a description, xmlenum or the value itself
        }
Ejemplo n.º 14
0
        public IActionResult Index(User user = null)
        {
            if (user == null)
            {
                return(NotFound());
            }

            ViewData["Role"]          = user.GetRole();
            ViewData["userId"]        = user.UserId;
            ViewData["EditViewModel"] = new EditViewModel(user);
            ViewData["Countries"]     = EnumHelpers.ToSelectList <Country>();
            ViewData["Genders"]       = EnumHelpers.ToSelectList <Gender>();
            return(View("Index"));
        }
Ejemplo n.º 15
0
            private PieceTypes GetPieceType(string pieceType)
            {
                if (string.IsNullOrWhiteSpace(pieceType))
                {
                    return(PieceTypes.Normal);
                }

                if (!EnumHelpers.IsValue <PieceTypes>(pieceType[0]))
                {
                    throw new ArgumentException($"Invalid piece type specificed. {pieceType} is not recognized");
                }

                return((PieceTypes)pieceType[0]);
            }
        public List <FunctionalityType> GetPermissions(int userId)
        {
            List <FunctionalityType> result;

            if (AppUserRoleRepository.CheckIfIsAdmin(userId))
            {
                result = EnumHelpers.GetEnumList <FunctionalityType>();
            }
            else
            {
                result = AppUserRoleRepository.GetUserFunctionalities(userId);
            }
            return(result);
        }
Ejemplo n.º 17
0
        public LivingObject(World world, ObjectID objectID)
            : base(world, objectID)
        {
            this.IsLiving = true;

            // XXX Create only for dwarves
            m_enabledLabors = new BitArray(EnumHelpers.GetEnumMax <LaborID>() + 1);
            m_enabledLabors.SetAll(true);

            m_armorSlots    = new ObservableCollection <Tuple <ArmorSlot, ItemObject> >();
            this.ArmorSlots = new ReadOnlyObservableCollection <Tuple <ArmorSlot, ItemObject> >(m_armorSlots);

            this.Trace = new MyTraceSource("Client.LivingObject");
        }
Ejemplo n.º 18
0
        private void PopulateAlbumDetails()
        {
            Title = string.Empty;

            var album = Album?.Title == AddNew ? null : Album;

            Title       = album?.Title ?? string.Empty;
            ReleaseType = album?.ReleaseType ?? EnumHelpers.GetDefaultValue <ReleaseType>();
            Year        = album?.Year ?? string.Empty;
            DiscCount   = album?.DiscCount.ToString() ?? string.Empty;
            UpdateArtwork(album?.Artwork);

            _disc.PopulateDiscDetails();
        }
Ejemplo n.º 19
0
        private void SetListData(SipAccountFormViewModel model)
        {
            model.Owners = _ownersRepository.GetAll();
            model.Owners.Insert(0, new Owner {
                Id = Guid.Empty, Name = string.Empty
            });

            model.CodecTypes = _codecTypeRepository.GetAll(false);
            model.CodecTypes.Insert(0, new CodecType {
                Id = Guid.Empty, Name = string.Empty
            });

            model.AccountTypes = EnumHelpers.EnumSelectList <SipAccountType>().OrderBy(e => e.Text).ToList();
        }
Ejemplo n.º 20
0
        public ActionResult Index(long themeId)
        {
            var theme = _dal.Get <Theme>(themeId);
            var model =
                new ThemeViewModel(
                    EnumHelpers.Enumerate <Opinion>()
                    .Select(
                        _ =>
                        new ThemeOpinionViewModel(_, theme.Comments.Where(c => c.Opinion == _).ToArray()))
                    .ToArray(),
                    theme);

            return(View(model));
        }
Ejemplo n.º 21
0
        public ActionResult Login(AuthorizeUser user, string ReturnUrl)
        {
            try
            {
                var emp = _employeeServices.Login(user.Username, user.Password);

                if (emp == null)
                {
                    ViewBag.Message = "Invalid username/password";
                    return(View("Login"));
                }

                string role = emp.Position;

                if (ReturnUrl.IsNullOrEmpty())
                {
                    if (role.Equals(EnumHelpers.GetDescription(Role.FRONT_TEAM_MEMBER)) || role.Equals(EnumHelpers.GetDescription(Role.PRODUCTION_TEAM_MEMBER)))
                    {
                        ReturnUrl = string.Format("/Shift/EmployeeView?empId={0}", emp.EmployeeId);
                    }
                    else
                    {
                        ReturnUrl = "/Shift";
                    }
                }

                string userData = JsonConvert.SerializeObject(emp);

                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1, emp.EmployeeId,
                    DateTime.Now, DateTime.Now.AddMinutes(30),
                    false, userData
                    );

                string encryptTicket = FormsAuthentication.Encrypt(authTicket);

                HttpCookie userCookie = new HttpCookie("userCookie", encryptTicket);
                Response.Cookies.Add(userCookie);

                //FormsAuthentication.SetAuthCookie(emp.EmployeeId, false);

                return(Redirect(ReturnUrl));
            }catch (Exception ex)
            {
                ViewBag.Message = "An internal error happend. Please try again later.";

                return(View("Login"));
            }
        }
        public IActionResult GetPostsVeiculos([FromQuery] ListPostsInputModel data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var results = _service.ListPosts(data, GetVirtualPath());

                #region Customization
                var comunications = new List <ComunicationViewModel>();
                foreach (var item in results)
                {
                    var comunication = new ComunicationViewModel(
                        item.title,
                        item.content,
                        item.createdAt
                        );

                    var imageURL = item.files.FirstOrDefault(i => i.session == EnumHelpers.GetDescription(FileSessions.title));
                    comunication.imageURL = imageURL == null ? "" : imageURL.name;

                    var optional = item.files.FirstOrDefault(i => i.session == EnumHelpers.GetDescription(FileSessions.optional));
                    if (optional != null)
                    {
                        var extension = $".{optional.name.Split('.')[optional.name.Split('.').Count() - 1]}";
                        if (TypeExtensions.IsVideoExtension(extension))
                        {
                            comunication.video = optional.name;
                        }
                        else if (TypeExtensions.IsAudioExtension(extension))
                        {
                            comunication.audio = optional.name;
                        }
                    }

                    comunications.Add(comunication);
                }
                #endregion

                return(Ok(comunications));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message.ToString()));
            }
        }
Ejemplo n.º 23
0
        public static bool TryFind(string value, bool ignoreCase, out T result)
        {
            var found = EnumHelpers.TryFind(typeof(T), value, ignoreCase, out var _result);

            if (found)
            {
                result = (T)_result;
            }
            else
            {
                result = default;
            }

            return(found);
        }
Ejemplo n.º 24
0
    static DummySceneController()
    {
#if !UNITY_WEBGL
        Data = EnumHelpers.GetValues <GameModeSelection>().Select(x => new
        {
            Mode    = x,
            Manager = (IGameManager)Activator.CreateInstance(x.GetAttribute <GameModeAttribute>().ManagerType),
        }).
               Where(x => Directory.Exists(Settings.GameDirectories.TryGetItem(x.Mode))).
               SelectMany(x => x.Manager.GetLevels(new GameSettings(x.Mode, Settings.GameDirectories[x.Mode], 1, 1)).
                          SelectMany(vol => vol.Worlds.SelectMany(world => world.Maps.Select(map => new SettingsData(x.Mode, vol.Name, world.Index, map))))).ToArray();
        Index = Data.FindItemIndex(x => x.GameModeSelection == Settings.SelectedGameMode && (x.Volume == null || x.Volume == Settings.EduVolume) && x.World == Settings.World && x.Level == Settings.Level);
        Debug.Log($"Screenshot enumeration from {Index} with {Data.Length - Index} items");
#endif
    }
Ejemplo n.º 25
0
        public ActionResult GetOrganisationDetailsForOrganisation(Guid organisationId)
        {
            if (organisationId != null)
            {
                Organisation organisationDetails = OrganisationHelpers.GetOrganisation(organisationId);

                if (organisationDetails != null)
                {
                    string businessTypeText = EnumHelpers.GetDescription(organisationDetails.BusinessType);
                    return(Json(new { organisationDetails, businessTypeText, success = true }));
                }
                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
Ejemplo n.º 26
0
    public override void WriteJson(
        JsonWriter writer,
        object value,
        JsonSerializer serializer)
    {
        if (value == null)
        {
            writer.WriteNull();
            return;
        }

        EnumValue result = EnumHelpers.GetEnumValue(value, value.GetType());

        serializer.Serialize(writer, result);
    }
        public static FontStyle?ParseFontStyle(string fontStyleString)
        {
#if WINDOWS_UWP
            return(EnumHelpers.ParseNullable <FontStyle>(fontStyleString));
#else
            switch (fontStyleString)
            {
            case "normal": return(FontStyles.Normal);

            case "italic": return(FontStyles.Italic);

            default: return(null);
            }
#endif
        }
Ejemplo n.º 28
0
    public static List <EnumHelpers> ConvertEnumToList(Type tnt)
    {
        Array enumValueList         = Enum.GetValues(tnt);
        List <EnumHelpers> enumList = new List <EnumHelpers>();

        foreach (int item in enumValueList)
        {
            EnumHelpers enDto = new EnumHelpers();
            enDto.ID          = item;
            enDto.Name        = Enum.GetName(tnt, item);
            enDto.Description = GetEnumDescription((Enum)Enum.ToObject(tnt, enDto.ID));
            enumList.Add(enDto);
        }
        return(enumList);
    }
Ejemplo n.º 29
0
    public T EditorField <T>(string label, T value, bool isVisible = true, Func <string[]> getEnumOptions = null, Rect?rect = null)
        where T : Enum
    {
        if (!isVisible)
        {
            return(value);
        }

        if (!EnumOptions.ContainsKey(label))
        {
            EnumOptions[label] = getEnumOptions == null?EnumHelpers.GetValues <T>().Select(x => x.ToString()).ToArray() : getEnumOptions();
        }

        return((T)(object)EditorGUI.Popup(rect ?? GetNextRect(ref YPos), label, (int)(object)value, EnumOptions[label]));
    }
Ejemplo n.º 30
0
        public IActionResult ObterPaginado(
            [FromServices] IClienteRepository clienteRepository,
            [FromQuery] int pagina     = 1,
            [FromQuery] int quantidade = 8,
            [FromQuery] string coluna  = "nomeCompleto_RazaoSocial",
            [FromQuery] string direcao = "asc",
            [FromQuery] string nomeCompleto_RazaoSocial = null,
            [FromQuery] string cpF_CNPJ = null)
        {
            var resultado = clienteRepository.ObterPaginado(
                EnumHelpers.ParseOrDefault(coluna, ClienteSort.NomeCompleto_RazaoSocial), string.IsNullOrEmpty(direcao) || direcao.Equals("asc"),
                pagina, quantidade, DataString.FromNullableString(nomeCompleto_RazaoSocial), DataString.FromNullableString(cpF_CNPJ));

            return(Result(resultado));
        }