예제 #1
0
        private bool IsEnabled()
        {
            if (localAttr == null)
            {
                return(false);
            }

            if (localRowInstance != null)
            {
                return(true);
            }

            localRowInstance = (ILocalizationRow)Activator.CreateInstance(localAttr.LocalizationRow);
            rowPrefixLength  = PrefixHelper.DeterminePrefixLength(BasedOnRow.EnumerateTableFields(),
                                                                  x => x.Name);
            localRowPrefixLength = PrefixHelper.DeterminePrefixLength(localRowInstance.EnumerateTableFields(),
                                                                      x => x.Name);
            mappedIdField = localRowInstance.FindField(localAttr.MappedIdField ?? BasedOnRow.IdField.Name);
            if (mappedIdField is null)
            {
                throw new InvalidOperationException(string.Format("Can't locate localization table mapped ID field for {0}!",
                                                                  localRowInstance.Table));
            }

            return(true);
        }
        public override void Initialize()
        {
            if (BasedOnRow == null)
            {
                return;
            }

            var attr = BasedOnRow.GetType().GetCustomAttribute <LocalizationRowAttribute>(false);

            if (attr != null)
            {
                localizationRowHandler = Activator.CreateInstance(typeof(LocalizationRowHandler <>)
                                                                  .MakeGenericType(BasedOnRow.GetType())) as ILocalizationRowHandler;
            }
        }
예제 #3
0
        public override void Initialize()
        {
            localAttr = null;

            if (BasedOnRow == null)
            {
                return;
            }

            localAttr = BasedOnRow.GetType().GetCustomAttribute <LocalizationRowAttribute>(false);
            if (localAttr == null)
            {
                return;
            }

            if (!typeof(ILocalizationRow).IsAssignableFrom(localAttr.LocalizationRow))
            {
                throw new InvalidOperationException(string.Format("Localization table {0} doesn't implement ILocalizationRow interface!",
                                                                  localAttr.LocalizationRow.FullName));
            }
        }