Ejemplo n.º 1
0
        protected override GameObject ErzeugeEintragAdapter(IKartenelement eintraege)
        {
            int        kachelId        = 0;
            GameObject neuesGameObject = new GameObject();

            neuesGameObject.name = EnumHandler.AlsString(eintraege.Tabelle());
            foreach (Rect feld in StadtplanModul.Instance.GetAbmessung(eintraege.Id).Felder)
            {
                var kachel = Instantiate(this.kartenelementKachelPrefab);
                if (typeof(Umwelt).IsAssignableFrom(eintraege.GetType()))
                {
                    kachel.AddComponent <UmweltKachelAdapter>();
                    kachel.GetComponent <UmweltKachelAdapter>().Kartenelement = (Umwelt)eintraege;
                }
                else
                {
                    kachel.AddComponent <GebaeudeKachelAdapter>();
                    kachel.GetComponent <GebaeudeKachelAdapter>().Kartenelement = (Gebaeude)eintraege;
                }
                kachel.name = eintraege.KartenelementArt.ToString() + "-" + eintraege.Id + "_" + kachelId++;
                var sprite = this.GetSprite(eintraege.KartenelementAussehen);
                kachel.GetComponent <SpriteRenderer>().sprite = sprite;
                kachel.transform.position   = new Vector3(feld.x + (feld.width / 2), feld.y - (feld.height / 2), -1);
                kachel.transform.localScale = this.GetObjektScale(sprite, feld.size) * 4;
                kachel.transform.SetParent(neuesGameObject.transform);
                kachel.SetActive(true);
            }
            return(neuesGameObject);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Serialize dictionary.
        /// </summary>
        /// <param name="resourceManager">the resource manager</param>
        /// <returns></returns>
        private JObject SerializeDictionary <TResourceCode>(ResourceManager resourceManager)
            where TResourceCode : struct, IConvertible
        {
            try
            {
                JObject serializedDictionary = new JObject();

                foreach (CultureInfo culture in this.cultures)
                {
                    serializedDictionary[culture.TwoLetterISOLanguageName] = new JObject();

                    IEnumerable <TResourceCode> resourceCodes = EnumHandler.GetValues <TResourceCode>().Where(rc => !this.IsServerErrorResource <TResourceCode>(rc));

                    foreach (TResourceCode resourceCode in resourceCodes)
                    {
                        string message = resourceManager.GetString(resourceCode.ToString(), culture);
                        serializedDictionary[culture.TwoLetterISOLanguageName][resourceCode.ToString()] = message;
                    }
                }

                return(serializedDictionary);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public bool IsClientErrorResource <TResourceCode>(TResourceCode resourceCode)
            where TResourceCode : struct, IConvertible
        {
            try
            {
                if (!typeof(TResourceCode).IsEnum)
                {
                    throw new ArgumentException("Le type TResourceCode doit être une énumération.");
                }

                LocalizationUtilityAttribute localizationUtility = EnumHandler.GetCustomAttributeOnType <TResourceCode, LocalizationUtilityAttribute>();

                if (localizationUtility == null)
                {
                    throw new ArgumentException("Le type doit être une ressource de traduction.");
                }

                ResourceCodeDetailsAttribute details = EnumHandler.GetCustomAttributeOnValue <TResourceCode, ResourceCodeDetailsAttribute>(resourceCode);

                bool result = (details.SolutionPart == ESolutionPart.ClientError);
                return(result);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
 internal byte GetEnumValId(Type type, object val)
 {
     if (!EnumType2EnumHandler.ContainsKey(type))
     {
         EnumType2EnumHandler[type] = new EnumHandler(type);
     }
     return(EnumType2EnumHandler[type].GetEnumValId(val));
 }
Ejemplo n.º 5
0
        private void ShowError()
        {
            string erroMessage = "Problema de Conectividad";

            Log.Warn(erroMessage);

            _messageDialog.SimpleMessageDialogAsync(erroMessage, EnumHandler.GetDescriptionFromEnumValue(ErrorStatus.Warning));
        }
Ejemplo n.º 6
0
 public override void GetInhalt(List <IDatenbankEintrag> eintraege)
 {
     if (eintraege.Count > 0)
     {
         this.SetInhalt(this.ErzeugeEintragAdapters(eintraege), null);
         this.SetzeTitel(StringHelfer.Ucfirst(EnumHandler.AlsString(eintraege[0].Tabelle())));
     }
 }
Ejemplo n.º 7
0
        protected override GameObject ErzeugeEintragAdapter(IDatenbankEintrag eintrag)
        {
            var menueEintrag = Instantiate(this.menueEintragPrefab);

            menueEintrag.GetComponentInChildren <MenueEintragAdapter>().Eintrag = eintrag;
            menueEintrag.GetComponentInChildren <Text>().text = StringHelfer.Ucfirst(EnumHandler.AlsString(eintrag.Tabelle()));
            return(menueEintrag);
        }
Ejemplo n.º 8
0
        internal static void RegisterEnumTypeGlobally <TEnum>(string pgName) where TEnum : struct
        {
            if (_globalEnumRegistrations == null)
            {
                _globalEnumRegistrations = new ConcurrentDictionary <string, TypeHandler>();
            }

            _globalEnumRegistrations[pgName] = new EnumHandler <TEnum>();
        }
Ejemplo n.º 9
0
 protected override void InitForm()
 {
     institutArtText.GetComponent <Text>().text  = StringHelfer.Ucfirst(EnumHandler.AlsString(this.Eintrag.InstitutArt));
     beschreibungText.GetComponent <Text>().text = this.Eintrag.Beschreibung;
     foreach (Teilaufgabe teilaufgabe in ModelHandler.Instance.GetInstitutNaechsteTeilaufgaben(this.Eintrag.InstitutArt))
     {
         GameObject teilaufgabeInfo = FormModul.Instance.ErzeugeInfoEintrag(teilaufgabe.Dialog.MenueText);
         teilaufgabeInfo.transform.SetParent(aufgabenListe.transform);
     }
 }
        private ExternalLoginTokenType getExternalLoginType(OAuthGrantResourceOwnerCredentialsContext context)
        {
            string[] HeaderValues;
            if (context.Request.Headers.TryGetValue("ExternalLoginType", out HeaderValues))
            {
                var HeaderValue = HeaderValues[0];

                return(EnumHandler.ParseEnum <ExternalLoginTokenType>(HeaderValue, ExternalLoginTokenType.None));
            }

            return(ExternalLoginTokenType.None);
        }
Ejemplo n.º 11
0
        private static EnumHandler RegisterEnum(Type enumType)
        {
            var enumInfo = new EnumHandler(enumType);

            lock (_lock) {
                // copy-add-replace
                var newDict = new Dictionary <Type, EnumHandler>(_enumsInfoLookup);
                newDict[enumType] = enumInfo;
                _enumsInfoLookup  = newDict;
            }
            return(enumInfo);
        }
        private void BuildToSqlParameters(string parameters, out SqlParameter[] sqlParameters)
        {
            try
            {
                sqlParameters = new SqlParameter[] { };

                foreach (string parameter in parameters.Split(','))
                {
                    Match matches = Regex.Match(parameter, StoredProcedureAttribute.parametersPattern, RegexOptions.IgnoreCase);

                    if (!matches.Groups.Any(g => g.Name == "parameterName"))
                    {
                        throw new ArgumentException("");
                    }

                    if (!matches.Groups.Any(g => g.Name == "dbType"))
                    {
                        throw new ArgumentException("");
                    }

                    if (!matches.Groups.Any(g => g.Name == "direction"))
                    {
                        throw new ArgumentException("");
                    }

                    if (!matches.Groups["parameterName"].Success)
                    {
                        throw new ArgumentException("");
                    }

                    if (!matches.Groups["dbType"].Success)
                    {
                        throw new ArgumentException("");
                    }

                    if (!matches.Groups["direction"].Success)
                    {
                        throw new ArgumentException("");
                    }

                    string             parameterName = matches.Groups["parameterName"].Value;
                    DbType             dbType        = EnumHandler.GetEnumFromString <DbType>(matches.Groups["dbType"].Value);
                    ParameterDirection direction     = EnumHandler.GetEnumFromString <ParameterDirection>(matches.Groups["direction"].Value);

                    SqlParameter sqlParameter = new SqlParameter()
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 13
0
        internal void RegisterEnumType <TEnum>(string pgName) where TEnum : struct
        {
            var backendTypeInfo = _backendTypes.FirstOrDefault(t => t.Name == pgName);

            if (backendTypeInfo == null)
            {
                throw new Exception(String.Format("An enum with the name {0} was not found in the database", pgName));
            }

            var handler = new EnumHandler <TEnum>();

            ActivateEnumType(handler, backendTypeInfo);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Get a string from the dictionary.
        /// </summary>
        /// <typeparam name="T">The resource serial type.</typeparam>
        /// <param name="resource">The resource serial.</param>
        /// <param name="culture">The user cutlure.</param>
        /// <returns></returns>
        public IResourceResult <TResourceCode> GetResourceResult <TResourceCode>(TResourceCode resourceCode, CultureInfo culture, params object[] args)
            where TResourceCode : struct, IConvertible
        {
            try
            {
                if (!typeof(TResourceCode).IsEnum)
                {
                    throw new ArgumentException("Le type TResourceCode doit être une énumération.");
                }

                LocalizationUtilityAttribute localizationUtility = EnumHandler.GetCustomAttributeOnType <TResourceCode, LocalizationUtilityAttribute>();

                if (localizationUtility == null)
                {
                    throw new ArgumentException("Le type doit être une ressource de traduction.");
                }

                ResourceCodeDetailsAttribute resourceCodeDetails = EnumHandler.GetCustomAttributeOnValue <TResourceCode, ResourceCodeDetailsAttribute>(resourceCode);
                ResourceManager rm = this.GetResourceManager <TResourceCode>();

                IResourceResult <TResourceCode> resourceResult = null;

                // Set result
                if (resourceCodeDetails.ResourceType == EResourceType.Object)
                {
                    resourceResult = new ResourceResult <TResourceCode>(localizationUtility, resourceCodeDetails, resourceCode, rm.GetObject(resourceCode.ToString()));
                }
                if (resourceCodeDetails.ResourceType == EResourceType.Stream)
                {
                    resourceResult = new ResourceResult <TResourceCode>(localizationUtility, resourceCodeDetails, resourceCode, rm.GetStream(resourceCode.ToString()));
                }
                if (resourceCodeDetails.ResourceType == EResourceType.String)
                {
                    resourceResult = new ResourceResult <TResourceCode>(localizationUtility, resourceCodeDetails, resourceCode, rm.GetString(resourceCode.ToString()), args);
                }

                // Format result
                if (resourceCodeDetails.ResourceType == EResourceType.String &&
                    args != null &&
                    args.Any())
                {
                    resourceResult.StringContent = string.Format(resourceResult.StringContent, args);
                }

                return(resourceResult);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Get resource manager from a resource serial.
        /// </summary>
        /// <typeparam name="T">The resource Type.</typeparam>
        /// <param name="resourceCode">Thez resource serial.</param>
        /// <returns></returns>
        private ResourceManager GetResourceManager <TResourceCode>()
            where TResourceCode : struct, IConvertible
        {
            if (!typeof(TResourceCode).IsEnum)
            {
                throw new ArgumentException("Le type TResourceCode doit être une énumération.");
            }

            LocalizationUtilityAttribute localizationUtility = EnumHandler.GetCustomAttributeOnType <TResourceCode, LocalizationUtilityAttribute>();
            PropertyInfo    propertyInfo    = localizationUtility.ResourceManagerType.GetProperty("ResourceManager", BindingFlags.Public | BindingFlags.Static);
            ResourceManager resourceManager = propertyInfo.GetValue(null, null) as ResourceManager;

            return(resourceManager);
        }
Ejemplo n.º 16
0
        internal static void MapEnumGlobally <TEnum>([CanBeNull] string pgName, [CanBeNull] INpgsqlNameTranslator nameTranslator) where TEnum : struct
        {
            if (nameTranslator == null)
            {
                nameTranslator = DefaultNameTranslator;
            }
            if (pgName == null)
            {
                pgName = GetPgName <TEnum>(nameTranslator);
            }

            _globalMappingChangeCounter++;
            _globalEnumMappings[pgName] = new EnumHandler <TEnum> .Factory(nameTranslator);
        }
Ejemplo n.º 17
0
 public string GetEintragInhalt()
 {
     return(StringHelfer.Ucfirst(EnumHandler.AlsString(this.eintrag.Tabelle())));
 }
Ejemplo n.º 18
0
        private Rate TryGetPreviousRate(Rate currentRate)
        {
            Rate previousRate = new Rate(currentRate.Name);

            try
            {
                if (IsPreviousDateErlierThanNow(previousRate))
                {
                    previousRate.Compra = double.Parse(_localSettings.TryGetValue(currentRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Buy)));
                    previousRate.Venta  = double.Parse(_localSettings.TryGetValue(currentRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Sell)));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(previousRate);
        }
Ejemplo n.º 19
0
 private void UpdatePreviousRate(Rate previousRate, double buy, double sell)
 {
     _localSettings.UpdateSetting(previousRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Buy), buy.ToString());
     _localSettings.UpdateSetting(previousRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Sell), sell.ToString());
     _localSettings.UpdateSetting(previousRate.Name, "date", DateTime.Now.ToString());
 }
Ejemplo n.º 20
0
 private void CreatePreviosRate(Rate currentRate, double buy, double sell)
 {
     _localSettings.CreateSetting(currentRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Buy), buy.ToString());
     _localSettings.CreateSetting(currentRate.Name, EnumHandler.GetDescriptionFromEnumValue(RateOptions.Sell), sell.ToString());
     _localSettings.CreateSetting(currentRate.Name, "date", LastUpdate.ToString());//.ToString("dd MM yyyy")
 }
Ejemplo n.º 21
0
 private void Dead()
 {
     SceneManager.LoadScene(EnumHandler.ConvertToString(Scenes.Scene1));
 }
Ejemplo n.º 22
0
        void Start()
        {
            ModelHandler._instance = this;
            JSONNode jsonInformation = AustauschAbrufer.Instance.Information;

            this.institute = new DatenbankEintragParser <Institut>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.INSTITUT)], InstitutFabrik.Instance);
            this.alleItems = new DatenbankEintragParser <Item>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.ITEM)], ItemFabrik.Instance);
            this.aufgaben  = new DatenbankEintragParser <Aufgabe>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.AUFGABE)], AufgabeFabrik.Instance);

            var elemente = new List <IKartenelement>();

            elemente.AddRange(new DatenbankEintragParser <Umwelt>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.KARTENELEMENT)], UmweltFabrik.Instance));
            elemente.AddRange(new DatenbankEintragParser <Gebaeude>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.KARTENELEMENT)], GebaeudeFabrik <Gebaeude> .Instance));
            elemente.AddRange(new DatenbankEintragParser <Wohnhaus>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.KARTENELEMENT)], WohnhausFabrik.Instance));
            elemente.AddRange(new DatenbankEintragParser <Niederlassung>().ArrayZuObjekten(jsonInformation[EnumHandler.AlsString(TabellenName.KARTENELEMENT)], NiederlassungFabrik.Instance));
            this.kartenelemente = elemente;

            this.InitItemsInBesitz(this.alleItems);

            spielContainer.SetActive(true);
        }
Ejemplo n.º 23
0
 internal byte GetEnumValId(Type type, object val)
 {
     if (!EnumType2EnumHandler.ContainsKey(type))
         EnumType2EnumHandler[type] = new EnumHandler(type);
     return EnumType2EnumHandler[type].GetEnumValId(val);
 }
Ejemplo n.º 24
0
    private void LoadNextScene()
    {
        var newScene = (EnumHandler.ConverToEnum <Scenes>(SceneManager.GetActiveScene().name) + 1);

        SceneManager.LoadScene(EnumHandler.ConvertToString(newScene));
    }
Ejemplo n.º 25
0
 public override IDatenbankEintrag ErzeugeDantebankEintrag(JSONObject jsonObjekt)
 {
     if (!jsonObjekt["kartenelement_art_name"].IsNull && jsonObjekt["kartenelement_art_name"].Value.Equals(EnumHandler.AlsString(this.GetKartenelementArt)))
     {
         return(base.ErzeugeDantebankEintrag(jsonObjekt));
     }
     return(null);
 }
Ejemplo n.º 26
0
 public virtual string GetPopupTitel()
 {
     return(StringHelfer.Ucfirst(EnumHandler.AlsString(this.eintrag.Tabelle())));
 }
Ejemplo n.º 27
0
 protected override void InitForm()
 {
     itemArtText.GetComponent <Text>().text       = StringHelfer.Ucfirst(EnumHandler.AlsString(this.Eintrag.ItemArt));
     gewichtText.GetComponent <Text>().text       = this.Eintrag.Gewicht.ToString();
     konfigurationText.GetComponent <Text>().text = this.Eintrag.Konfiguration;
 }
Ejemplo n.º 28
0
 protected override void InitForm()
 {
     statusText.GetComponent <Text>().text            = StringHelfer.Ucfirst(EnumHandler.AlsString(this.Eintrag.Status));
     gesetzesgrundlageText.GetComponent <Text>().text = this.Eintrag.Gesetzesgrundlage;
     teilaufgabe_info.GetComponent <Text>().text      = ModelHandler.Instance.NaechsteTeilaugabeInAufgabe(this.Eintrag).Dialog.MenueText;
 }
 public override string GetPopupTitel()
 {
     return(EnumHandler.AlsString(this.eintrag.KartenelementArt));
 }
Ejemplo n.º 30
0
        private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var messageDialog = _container.GetInstance <IMessageDialog>();

            messageDialog.SimpleMessageDialogAsync("Error no esperado. Por favor cierre la aplicación", EnumHandler.GetDescriptionFromEnumValue(ErrorStatus.Critical));
            _log.Warn(e.Message);
        }
 protected override string GetKurzInfo()
 {
     return(EnumHandler.AlsString(this.eintrag.Tabelle()) + KartenelementPopupEintragAdapter.betreten);
 }