Exemplo n.º 1
0
        public string CaseTranslate(
            string word_in,
            string schemaName_in
            )
        {
            string _output;
            string _key = word_in + "|" + schemaName_in;

            lock (this.casetranslate_cache_) {
                if (this.casetranslate_cache_.Contains(_key))
                {
                    _output = (string)this.casetranslate_cache_[_key];
                    return(_output);
                }
                else
                {
                    #region XS_specificCaseType _case = ...;
                    int _index = -1;
                    XS_specificCaseType _case;
                    if (
                        // (no schema provided)
                        (string.IsNullOrEmpty(schemaName_in))
                        ||
                        (
                            // (can't find specific schema)
                            (_index = MetadataIndexCollection.Search(schemaName_in))
                            ==
                            -1
                        )
                        ||
                        (
                            // (not found at specific schema)
                            (_case = MetadataIndexCollection[_index].SpecificCaseCollection[word_in])
                            ==
                            null
                        )
                        )
                    {
                        // look in generic
                        _case = SpecificCaseCollection[word_in];
                    }
                    #endregion

                    _output = (_case == null)
                                                ? string.Empty
                                                : _case.Translation;
                    if (!string.IsNullOrEmpty(_output))
                    {
                        this.casetranslate_cache_.Add(_key, _output);
                        return(_output);
                    }
                    else
                    {
                        switch (CaseType)
                        {
                        case XS_CaseTypeEnumeration.PascalCase:
                            if (word_in.Length > 0)
                            {
                                _output = string.Concat(
                                    word_in[0].ToString(
                                        System.Globalization.CultureInfo.CurrentCulture
                                        ).ToUpper(
                                        System.Globalization.CultureInfo.CurrentCulture
                                        ),
                                    word_in.Substring(1)
                                    );
                            }
                            else
                            {
                                _output = word_in;
                            }
                            this.casetranslate_cache_.Add(_key, _output);
                            return(_output);

                        case XS_CaseTypeEnumeration.camelCase:
                        case XS_CaseTypeEnumeration.lowercase:
                        case XS_CaseTypeEnumeration.UPPERCASE:
                        case XS_CaseTypeEnumeration._invalid_:
                            // ToDos: later!
                            throw new Exception("not implemented!");

                        case XS_CaseTypeEnumeration.none:
                        default:
                            this.casetranslate_cache_.Add(_key, word_in);
                            return(word_in);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public string CaseTranslate(
            string word_in,
            string schemaName_in
            )
        {
            string _key = word_in + "|" + schemaName_in;

            if (casetranslate_cache_ == null)
            {
                casetranslate_cache_ = new Hashtable();
            }
            if (casetranslate_cache_.Contains(_key))
            {
                return((string)casetranslate_cache_[_key]);
            }
            else
            {
                #region XS_specificCaseType _case = ...;
                int _index = -1;
                XS_specificCaseType _case;
                if (
                    // (no schema provided)
                    (schemaName_in == string.Empty)
                    ||
                    (
                        // (can't find specific schema)
                        (_index = MetadataIndexCollection.Search(schemaName_in))
                        ==
                        -1
                    )
                    ||
                    (
                        // (not found at specific schema)
                        (_case = MetadataIndexCollection[_index].SpecificCaseCollection[word_in])
                        ==
                        null
                    )
                    )
                {
                    // look in generic
                    _case = SpecificCaseCollection[word_in];
                }
                #endregion

                string _output = (_case == null)
                                        ? string.Empty
                                        : _case.Translation;
                if (_output != string.Empty)
                {
                    casetranslate_cache_.Add(_key, _output);
                    return(_output);
                }
                else
                {
                    switch (CaseType)
                    {
                    case XS_CaseTypeEnumeration.PascalCase:
                        if (word_in.Length > 0)
                        {
                            _output
                                = word_in[0].ToString().ToUpper()
                                  + word_in.Substring(1);
                        }
                        else
                        {
                            _output = word_in;
                        }
                        casetranslate_cache_.Add(_key, _output);
                        return(_output);

                    case XS_CaseTypeEnumeration.camelCase:
                    case XS_CaseTypeEnumeration.lowercase:
                    case XS_CaseTypeEnumeration.UPPERCASE:
                    case XS_CaseTypeEnumeration._invalid_:
                        // ToDos: later!
                        throw new Exception("not implemented!");

                    case XS_CaseTypeEnumeration.none:
                    default:
                        casetranslate_cache_.Add(_key, word_in);
                        return(word_in);
                    }
                }
            }
        }