示例#1
0
        //#common
        //##get
        //##Get by masterId
        private static Annex Get(string className, long masterId, List <Annex> annexes, string langCode, GetAnnexMode getAnnexMode)
        {
            if (annexes == null)
            {
                return(null);
            }

            var annex = new Annex();

            if (getAnnexMode == GetAnnexMode.OnlyByCurLang)
            {
                annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId && x.LanguageCode == langCode)
                    : annexes.Find(x => x.ClassName == className && x.MasterId == masterId && x.LanguageCode == langCode);
            }

            else if (getAnnexMode == GetAnnexMode.FirstAnnex)
            {
                annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId && x.LanguageCode == langCode)
                    : annexes.Find(x => x.ClassName == className && x.MasterId == masterId && x.LanguageCode == langCode);

                if (annex == null)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId)
                        : annexes.Find(x => x.ClassName == className && x.MasterId == masterId);
                }
            }

            else if (getAnnexMode == GetAnnexMode.StepByStep)
            {
                annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId && x.LanguageCode == langCode)
                    : annexes.Find(x => x.ClassName == className && x.MasterId == masterId && x.LanguageCode == langCode);

                //if (annex == null)
                //{
                //    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId && x.LanguageCode == CultureHelper.CurrentLanguageCode)
                //        : annexes.Find(x => x.ClassName == className && x.MasterId == masterId && x.LanguageCode == CultureHelper.CurrentLanguageCode);
                //}

                if (annex == null)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId && x.LanguageCode == DefaultLanguageCode)
                        : annexes.Find(x => x.ClassName == className && x.MasterId == masterId && x.LanguageCode == DefaultLanguageCode);
                }

                if (annex == null)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterId == masterId)
                        : annexes.Find(x => x.ClassName == className && x.MasterId == masterId);
                }
            }
            return(annex ?? null);
        }
示例#2
0
 //#GetText by masterName
 public static string GetText(string className, string masterName, List <Annex> annexes, AnnexTextType textType, string curLangCode, GetAnnexMode getAnnexMode)
 {
     try
     {
         var annex = Get(className, masterName, annexes, curLangCode, getAnnexMode);
         if (annex == null)
         {
             return(string.Empty);
         }
         else
         {
             return(GetTextByAnnex(annex, textType));
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException("\n>> " + TypeName + ".GetText Error: " + ex.Message);
     }
 }
示例#3
0
        //#GetText by masterName, className can be empty
        public static string GetText(string className, string masterName, List <Annex> annexes, AnnexTextType textType, string curLangCode, GetAnnexMode getAnnexMode)
        {
            var annex = Get(className, masterName, annexes, curLangCode, getAnnexMode);

            if (annex == null)
            {
                return(string.Empty);
            }
            else
            {
                return(GetTextByAnnex(annex, textType));
            }
        }
示例#4
0
        //#Get by masterName
        private static Annex Get(string className, string masterName, List <Annex> annexes, string langCode, GetAnnexMode getAnnexMode)
        {
            if (annexes == null)
            {
                return(null);
            }
            try
            {
                var annex = new Annex();
                if (getAnnexMode == GetAnnexMode.FirstAnnex)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterName == masterName)
                        : annexes.Find(x => x.ClassName == className && x.MasterName == masterName);
                }
                else if (getAnnexMode == GetAnnexMode.OnlyByCurLang)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterName == masterName && x.LanguageCode == langCode)
                        : annexes.Find(x => x.ClassName == className && x.MasterName == masterName && x.LanguageCode == langCode);
                }
                else if (getAnnexMode == GetAnnexMode.StepByStep)
                {
                    annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterName == masterName && x.LanguageCode == langCode)
                        : annexes.Find(x => x.ClassName == className && x.MasterName == masterName && x.LanguageCode == langCode);

                    if (annex == null)
                    {
                        annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterName == masterName && x.LanguageCode == DefaultLanguageCode)
                            : annexes.Find(x => x.ClassName == className && x.MasterName == masterName && x.LanguageCode == DefaultLanguageCode);
                    }

                    if (annex == null)
                    {
                        annex = className.IsNullOrEmpty() ? annexes.Find(x => x.MasterName == masterName)
                            : annexes.Find(x => x.ClassName == className && x.MasterName == masterName);
                    }
                }
                return(annex ?? null);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("\n>> " + TypeName + ".Get Error: " + ex.Message);
            }
        }