コード例 #1
0
ファイル: PickerItem.cs プロジェクト: bmacombe/soltechxf
        public static PickerItem <T> GetPickerItemFromEnum(T item, ILocalizer localizer, String resourceNamespace)
        {
            if (localizer == null)
            {
                throw new ArgumentNullException("localizer");
            }
            if (String.IsNullOrEmpty(resourceNamespace))
            {
                throw new ArgumentNullException("resourceNamespace");
            }

            Type enumType = typeof(T);

            if (!enumType.GetTypeInfo().IsEnum)
            {
                throw new ArgumentException("You must provide an enumeration.", "enumeration");
            }

            if (!Enum.IsDefined(enumType, item))
            {
                throw new ArgumentOutOfRangeException("item");
            }

            var entry       = enumType.GetRuntimeField(Enum.GetName(enumType, item));
            var description = entry.GetCustomAttribute <DescriptionAttribute>();
            var pickerEntry = new PickerItem <T>(localizer.GetText(resourceNamespace, enumType.Name, description.ResourceId), (T)entry.GetValue(null));

            return(pickerEntry);
        }
コード例 #2
0
ファイル: PickerItem.cs プロジェクト: bmacombe/soltechxf
        public static IList <PickerItem <T> > GetPickerItemListFromEnum(ILocalizer localizer, String resourceNamespace)
        {
            if (localizer == null)
            {
                throw new ArgumentNullException("localizer");
            }
            if (String.IsNullOrEmpty(resourceNamespace))
            {
                throw new ArgumentNullException("resourceNamespace");
            }

            Type enumType = typeof(T);

            if (!enumType.GetTypeInfo().IsEnum)
            {
                throw new ArgumentException("You must provide an enumeration.", "enumeration");
            }

            var list = new List <PickerItem <T> >();

            foreach (var entryName in Enum.GetNames(enumType))
            {
                var entry       = enumType.GetRuntimeField(entryName);
                var description = entry.GetCustomAttribute <DescriptionAttribute>();
                var pickerEntry = new PickerItem <T>(localizer.GetText(resourceNamespace, enumType.Name, description.ResourceId), (T)entry.GetValue(null));
                list.Add(pickerEntry);
            }

            return(list);
        }
コード例 #3
0
ファイル: PickerItem.cs プロジェクト: bmacombe/soltechxf
        public PickerItem(T item, ILocalizer localizer, String resourceNamespace)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (localizer == null)
            {
                throw new ArgumentNullException("localizer");
            }
            if (String.IsNullOrEmpty(resourceNamespace))
            {
                throw new ArgumentNullException("resourceNamespace");
            }

            Type enumType = typeof(T);

            if (!enumType.GetTypeInfo().IsEnum)
            {
                throw new ArgumentException("You must provide an enumeration.", "enumeration");
            }

            var entry       = enumType.GetRuntimeField(Enum.GetName(enumType, item));
            var description = entry.GetCustomAttribute <DescriptionAttribute>();

            Name = localizer.GetText(resourceNamespace, enumType.Name, description.ResourceId);
            Item = item;
        }
コード例 #4
0
        public static ControllerModel CreateLocalizedControllerModel(this ControllerModel originalControllerModel,
                                                                     ILocalizer localizer, string culture)
        {
            ControllerModel localizedControllerModel = new ControllerModel(originalControllerModel);

            localizer.MarkModelLocalizedFor(localizedControllerModel, culture);

            // Fix for https://github.com/aspnet/Mvc/issues/6159
            localizedControllerModel.Actions.ToList().ForEach(action => action.Controller = localizedControllerModel);

            // Clear existing attribute routed controller routes
            localizedControllerModel.Selectors.Clear();

            foreach (ActionModel action in localizedControllerModel.Actions.ToList())
            {
                // Check for attribute routed action routes
                if (action.Selectors.All(x => x.AttributeRouteModel != null))
                {
                    localizer.MarkModelLocalizedFor(action, culture);
                }

                action.Selectors.Clear();
            }

            return(localizedControllerModel);
        }
コード例 #5
0
 public static void ThrowIfNotLocalizedModel(this ActionModel actionModel, ILocalizer localizer)
 {
     if (!actionModel.IsLocalizedModel(localizer))
     {
         throw new ArgumentException("Localized ActionModel was expected.");
     }
 }
コード例 #6
0
 public static void ThrowIfNotOriginalModel(this ActionModel actionModel, ILocalizer localizer)
 {
     if (!actionModel.IsOriginalModel(localizer))
     {
         throw new ArgumentException("Original ControllerModel was expected.");
     }
 }
コード例 #7
0
 public void AddAdditionalLocalizer(ILocalizer localizer)
 {
     if (_additionalLocalizers.ContainsKey(localizer.GetType()) == false)
     {
         _additionalLocalizers.TryAdd(localizer.GetType(), localizer);
     }
 }
コード例 #8
0
        public LanguageController(IControllersProvider <T> controllersProvider, ILocalizer localizer)
            : base(controllersProvider, localizer)
        {
            var handlers = new List <IMessageHandler <T> >();

            foreach (MethodInfo methodInfo in GetType().GetMethods())
            {
                var attribute = Attribute.GetCustomAttribute(
                    methodInfo,
                    typeof(LanguageActionAttribute)
                    ) as LanguageActionAttribute;

                if (attribute is null)
                {
                    continue;
                }

                // ReSharper disable once UseNegatedPatternMatching
                var expression = GetType().GetProperty(attribute.ExpressionPropertyName)?.GetValue(this) as Expression;

                if (expression is null)
                {
                    throw new InvalidOperationException(
                              "Couldn't find expression property with name " + attribute.ExpressionPropertyName
                              );
                }

                handlers.Add(new LanguageActionHandler <T>(
                                 expression, localizer, methodInfo)
                             );
            }

            LanguageHandlers = handlers.ToArray();
        }
コード例 #9
0
 public void Setup(IServices services, IMetaModel metaModel, ILocalizer localizer) {
     this.services = services;
     this.metaModel = metaModel;
     this.localizer = localizer;
     TypeResolver.Reset();
     ListPropertyValues = GetListPropertyValues();
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalizerViewModel"/> class.
 /// </summary>
 /// <param name="navigationService"></param>
 /// <param name="systemSettingsStore"></param>
 /// <param name="localizer"></param>
 public LocalizerViewModel(
     INavigationService navigationService,
     ISystemSettingsStore systemSettingsStore,
     ILocalizer localizer)
     : base(navigationService, systemSettingsStore, localizer)
 {
 }
コード例 #11
0
 public CompoLoginUsernamePasswordModelModel(IUserApplication userApplication, IMsgBox msgBox, IJwtBuilder jwtBuilder, ILocalizer localizer)
 {
     _userApplication = userApplication;
     _msgBox          = msgBox;
     _jwtBuilder      = jwtBuilder;
     _localizer       = localizer;
 }
コード例 #12
0
        public ReportHelper()
        {
            // DI ready
            IServiceLocator locator = ServiceLocator.Current;

            _host                 = locator.GetService <IApplicationHost>();
            _dbContext            = locator.GetService <IDbContext>();
            _localizer            = locator.GetService <ILocalizer>();
            _stimulsoftReportShim = locator.GetService <IStimulsoftReportShim>(sloc =>
            {
                var inst       = System.Activator.CreateInstance("A2v10.Stimulsoft", "A2v10.Stimulsoft.StimulsoftReportShim");
                var instUnwrap = inst.Unwrap();
                var ass        = Assembly.GetAssembly(instUnwrap.GetType());

                var actualBuild = ass.GetName().Version.Build;

                if (actualBuild < StimulsoftVersion.ExpectedVersion)
                {
                    throw new InvalidProgramException($"Invalid A2v10.Stimulsoft build. Expected: {StimulsoftVersion.ExpectedVersion}, Actual: {actualBuild}");
                }
                var shim = instUnwrap as IStimulsoftReportShim;
                shim.Inject(sloc);
                return(shim);
            });
        }
コード例 #13
0
 public Compo_ChanageAccessLevelModel(IUserApplication userApplication, IMsgBox msgBox, ILocalizer localizer, IAccesslevelApplication accesslevelApplication)
 {
     _UserApplication        = userApplication;
     _MsgBox                 = msgBox;
     _Localizer              = localizer;
     _AccesslevelApplication = accesslevelApplication;
 }
コード例 #14
0
ファイル: FrameworkException.cs プロジェクト: oklancir/Rhetos
 public static string GetInternalServerErrorMessage(ILocalizer localizer, Exception exception)
 {
     return(localizer[
                "Internal server error occurred. See RhetosServer.log for more information. ({0}, {1})",
                exception.GetType().Name,
                DateTime.Now.ToString("s")]);
 }
コード例 #15
0
 public CompoPhoneNumberModel(IMsgBox msgBox, ILocalizer localizer, IUserApplication userApplication, ISmsSender smsSender)
 {
     _msgBox          = msgBox;
     _localizer       = localizer;
     _userApplication = userApplication;
     _smsSender       = smsSender;
 }
コード例 #16
0
 public EditModel(IAccesslevelApplication accesslevelApplication, IMsgBox msgBox, ILocalizer localizer, IUserApplication userApplication)
 {
     _AccesslevelApplication = accesslevelApplication;
     _MsgBox          = msgBox;
     _Localizer       = localizer;
     _UserApplication = userApplication;
 }
コード例 #17
0
 protected Entity(TId id, ILocalizer localizer, ILogger logger, ISystemClock clock)
 {
     Id        = id;
     Localizer = localizer;
     Logger    = logger;
     Clock     = clock;
 }
コード例 #18
0
 public Compo_Login_PhoneNumberModel(IUserApplication userApplication, IMsgBox msgBox, ILocalizer localizer, ISmsSender smsSender)
 {
     _UserApplication = userApplication;
     _MsgBox          = msgBox;
     _Localizer       = localizer;
     _SmsSender       = smsSender;
 }
コード例 #19
0
        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            this.localizer = this.Kernel.Get<ILocalizer>();
            this.localizer.Initialize();

            this.DisplayRootViewFor(typeof(IStockTickerViewModel));
        }
コード例 #20
0
ファイル: DiProxy.cs プロジェクト: Andrey-Anatolyevich/Dating
 public DiProxy(
     IPlacesService placesService
     , SessionOperator sessionOperator
     , IObjectTypesService objectTypesService
     , IObjectsService objectsService
     , ILocalizationService localeService
     , IMapper mapper
     , ILocalizer localizer
     , IAdsService adsService
     , IFilesService filesService
     , ConfigValuesCollection configValues
     , IUserInfoService userInfoService)
 {
     _elements.Add(typeof(IPlacesService), placesService);
     _elements.Add(typeof(SessionOperator), sessionOperator);
     _elements.Add(typeof(IObjectTypesService), objectTypesService);
     _elements.Add(typeof(IObjectsService), objectsService);
     _elements.Add(typeof(ILocalizationService), localeService);
     _elements.Add(typeof(IMapper), mapper);
     _elements.Add(typeof(ILocalizer), localizer);
     _elements.Add(typeof(IAdsService), adsService);
     _elements.Add(typeof(IFilesService), filesService);
     _elements.Add(typeof(ConfigValuesCollection), configValues);
     _elements.Add(typeof(IUserInfoService), userInfoService);
 }
コード例 #21
0
ファイル: ProcessingEngine.cs プロジェクト: davorpr1/Rhetos
 public ProcessingEngine(
     IPluginsContainer<ICommandImplementation> commandRepository,
     IPluginsContainer<ICommandObserver> commandObservers,
     ILogProvider logProvider,
     IPersistenceTransaction persistenceTransaction,
     IAuthorizationManager authorizationManager,
     XmlUtility xmlUtility,
     IUserInfo userInfo,
     ISqlUtility sqlUtility,
     ILocalizer localizer)
 {
     _commandRepository = commandRepository;
     _commandObservers = commandObservers;
     _logger = logProvider.GetLogger("ProcessingEngine");
     _performanceLogger = logProvider.GetLogger("Performance");
     _requestLogger = logProvider.GetLogger("ProcessingEngine Request");
     _commandsLogger = logProvider.GetLogger("ProcessingEngine Commands");
     _commandsResultLogger = logProvider.GetLogger("ProcessingEngine CommandsResult");
     _persistenceTransaction = persistenceTransaction;
     _authorizationManager = authorizationManager;
     _xmlUtility = xmlUtility;
     _userInfo = userInfo;
     _sqlUtility = sqlUtility;
     _localizer = localizer;
 }
コード例 #22
0
        public AuthenticationService(
            ILogProvider logProvider,
            Lazy <IAuthorizationManager> authorizationManager,
            GenericRepositories repositories,
            Lazy <ISqlExecuter> sqlExecuter,
            Lazy <IEnumerable <ISendPasswordResetToken> > sendPasswordResetTokenPlugins,
            ILocalizer localizer)
        {
            _logger = logProvider.GetLogger("AspNetFormsAuth.AuthenticationService");
            _authorizationManager         = authorizationManager;
            _sqlExecuter                  = sqlExecuter;
            _sendPasswordResetTokenPlugin = new Lazy <ISendPasswordResetToken>(() => SinglePlugin(sendPasswordResetTokenPlugins));

            _passwordStrengthRules  = new Lazy <IEnumerable <IPasswordStrength> >(() => repositories.Load <IPasswordStrength>());
            _passwordAttemptsLimits = new Lazy <IEnumerable <IPasswordAttemptsLimit> >(() =>
            {
                var limits = repositories.Load <IPasswordAttemptsLimit>();
                foreach (var limit in limits)
                {
                    if (limit.TimeoutInSeconds == null || limit.TimeoutInSeconds <= 0)
                    {
                        limit.TimeoutInSeconds = int.MaxValue;
                    }
                }
                return(limits);
            });
            _localizer = localizer;
        }
コード例 #23
0
 public Compo_Login_UsernamePasswordModel(IUserApplication userApplication, IMsgBox msgBox, IJWTBuilder jWTBuilder, ILocalizer localizer)
 {
     _UserApplication = userApplication;
     _MsgBox          = msgBox;
     _JWTBuilder      = jWTBuilder;
     _Localizer       = localizer;
 }
コード例 #24
0
        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            this.localizer = this.Kernel.Get <ILocalizer>();
            this.localizer.Initialize();

            this.DisplayRootViewFor(typeof(IStockTickerViewModel));
        }
コード例 #25
0
        public PluginOptionViewModelFactory(ILocalizer localizer)
        {
            _constructListOptionMethodInfo = GetType().GetMethod(nameof(ConstructListOption), BindingFlags.NonPublic | BindingFlags.Instance)
                                             ?? throw new Exception("ConstructListOption not found!");

            _localizationProvider = new LocalizationProvider(localizer);
        }
コード例 #26
0
 public PriceSettingRepository(ILocalizer localizer, IHttpContextAccessor httpContextAccessor,
                               CommonRepository commRepos)
 {
     _localizer           = localizer;
     _httpContextAccessor = httpContextAccessor;
     _commRepos           = commRepos;
 }
コード例 #27
0
 /// <inheritdoc cref="ILocalizer.Localize{TComponent}"/>
 public static string Localize <TComponent>(
     this ILocalizer localizer,
     Func <TComponent, LocalizationTemplate> selector)
     where TComponent : ILocalizationComponent
 {
     return(localizer.Localize(selector, Array.Empty <object>()));
 }
コード例 #28
0
ファイル: HostHelpers.cs プロジェクト: alex-kukhtin/A2v10
        public static String GetAppData(this IApplicationHost host, ILocalizer localizer, IUserLocale userLocale)
        {
            var appJson = host.ApplicationReader.ReadTextFile(String.Empty, "app.json");

            if (appJson != null)
            {
                if (appJson.Contains("$("))
                {
                    var sb = new StringBuilder(appJson);
                    sb.Replace("$(lang)", userLocale.Language)
                    .Replace("$(lang2)", userLocale.Language2);
                    appJson = sb.ToString();
                }
                // with validation
                ExpandoObject app = JsonConvert.DeserializeObject <ExpandoObject>(appJson);
                app.Set("embedded", host.Embedded);
                return(localizer.Localize(null, JsonConvert.SerializeObject(app)));
            }

            ExpandoObject defAppData = new ExpandoObject();

            defAppData.Set("version", host.AppVersion);
            defAppData.Set("title", "A2v10 Web Application");
            defAppData.Set("copyright", host.Copyright);
            defAppData.Set("embedded", host.Embedded);
            return(JsonConvert.SerializeObject(defAppData));
        }
コード例 #29
0
        public static IEnumerable <SelectorModel> GetUntranslatedSelectorsFor(this ActionModel originalActionModel,
                                                                              ILocalizer localizer, string culture)
        {
            ActionModel localizedActionModel = originalActionModel.GetLocalizedModelFor(localizer, culture);

            return(originalActionModel.Selectors.Skip(localizedActionModel.Selectors.Count));
        }
コード例 #30
0
ファイル: ProcessingEngine.cs プロジェクト: oklancir/Rhetos
 public ProcessingEngine(
     IPluginsContainer <ICommandImplementation> commandRepository,
     IPluginsContainer <ICommandObserver> commandObservers,
     ILogProvider logProvider,
     IPersistenceTransaction persistenceTransaction,
     IAuthorizationManager authorizationManager,
     XmlUtility xmlUtility,
     IUserInfo userInfo,
     ISqlUtility sqlUtility,
     ILocalizer localizer)
 {
     _commandRepository         = commandRepository;
     _commandObservers          = commandObservers;
     _logger                    = logProvider.GetLogger("ProcessingEngine");
     _performanceLogger         = logProvider.GetLogger("Performance");
     _requestLogger             = logProvider.GetLogger("ProcessingEngine Request");
     _commandsLogger            = logProvider.GetLogger("ProcessingEngine Commands");
     _commandsResultLogger      = logProvider.GetLogger("ProcessingEngine CommandsResult");
     _commandsClientErrorLogger = logProvider.GetLogger("ProcessingEngine CommandsWithClientError");
     _commandsServerErrorLogger = logProvider.GetLogger("ProcessingEngine CommandsWithServerError");
     _persistenceTransaction    = persistenceTransaction;
     _authorizationManager      = authorizationManager;
     _xmlUtility                = xmlUtility;
     _userInfo                  = userInfo;
     _sqlUtility                = sqlUtility;
     _localizer                 = localizer;
 }
コード例 #31
0
 public static void Set(ILocalizer localizer)
 {
     lock (_lock)
     {
         Current = localizer;
     }
 }
コード例 #32
0
 /// <summary>
 /// Subscribes an ILocalizer if it isn't already subscribed.
 /// All subscribers will be automatically localized if the Language is changed.
 /// </summary>
 /// <param name="subscriber"></param>
 public void Subscribe(ILocalizer subscriber)
 {
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #33
0
        /// <summary>
        /// 获取枚举类型值对应的描述名称
        /// </summary>
        /// <param name="enumType">枚举类型</param>
        /// <param name="value">枚举类型值</param>
        /// <returns>描述名称</returns>
        public static string GetNameFromEnum(Type enumType, object value, ILocalizer localizer = null)
        {
            if (value == null || value == DBNull.Value)
            {
                return(string.Empty);
            }
            if (enumType.IsEnum)
            {
                List <Tuple <string, object> > enumList = null;
                if (enumDic.ContainsKey(enumType))
                {
                    enumList = GetObjectsFromEnum(enumType, localizer);
                }
                else
                {
                    enumList = enumDic.GetOrAdd(enumType, new List <Tuple <string, object> >());
                }

                if (enumList != null)
                {
                    foreach (var el in enumList)
                    {
                        if (el.Item2 == value)
                        {
                            return(el.Item1);
                        }
                    }
                }
            }
            return(value.ToString());
        }
コード例 #34
0
ファイル: EnumHelper.cs プロジェクト: cairabbit/daf
        /// <summary>
        /// 获取枚举类型值对应的描述名称
        /// </summary>
        /// <param name="enumType">枚举类型</param>
        /// <param name="value">枚举类型值</param>
        /// <returns>描述名称</returns>
        public static string GetNameFromEnum(Type enumType, object value, ILocalizer localizer = null)
        {
            if (value == null || value == DBNull.Value)
                return string.Empty;
            if (enumType.IsEnum)
            {
                List<Tuple<string, object>> enumList = null;
                if (enumDic.ContainsKey(enumType))
                {
                    enumList = GetObjectsFromEnum(enumType, localizer);
                }
                else
                {
                    enumList = enumDic.GetOrAdd(enumType, new List<Tuple<string, object>>());
                }

                if (enumList != null)
                {
                    foreach (var el in enumList)
                    {
                        if (el.Item2 == value)
                            return el.Item1;
                    }
                }
            }
            return value.ToString();
        }
コード例 #35
0
ファイル: VTSViewModel.cs プロジェクト: dtimyr/xamarin
		public VTSViewModel (IFileSystemService fileSystem, ILocalizer localazer, ISQLitePlatform sqlitePlatform)
		{	
			_vacationList = new VacationInfoMockModel ().Vacations;

			_fileSystem = fileSystem;
			this.Localaizer = localazer;
			_sqlitePlatform = sqlitePlatform;
		}
コード例 #36
0
 public BrigitaProducts(
             IRepo<Product> repo, 
             ICategories cats, 
             ILocalizer<Product> localizer) 
 {
     _repo = repo;
     _cats = cats;
     _localizer = localizer;
 }
コード例 #37
0
ファイル: EnumHelper.cs プロジェクト: cairabbit/daf
        /// <summary>
        /// 获取枚举类型对象集合
        /// </summary>
        /// <param name="enumType">枚举类型</param>
        /// <returns>对象集合</returns>
        public static List<Tuple<string, object>> GetObjectsFromEnum(Type enumType, ILocalizer localizer = null)
        {
            if (enumType == null || !enumType.IsEnum)
                return null;
            if (enumDic.ContainsKey(enumType))
                return enumDic[enumType];

            List<Tuple<string, object>> objs = new List<Tuple<string, object>>();
            Type typeDescription = typeof(DescriptionAttribute);
            Type typeBrowsable = typeof(BrowsableAttribute);
            FieldInfo[] fields = enumType.GetFields();
            foreach (FieldInfo field in fields)
            {
                if (field.FieldType.IsEnum == true)
                {
                    string name;
                    object value;
                    object[] arr = field.GetCustomAttributes(typeBrowsable, true);
                    if (arr.Length > 0)
                    {
                        BrowsableAttribute bb = (BrowsableAttribute)arr[0];
                        if (bb.Browsable == false)
                            continue;
                    }
                    if (localizer == null)
                    {
                        arr = field.GetCustomAttributes(typeDescription, true);
                        if (arr.Length > 0)
                        {
                            DescriptionAttribute aa = (DescriptionAttribute)arr[0];
                            name = aa.Description;
                        }
                        else
                        {
                            name = field.Name;
                        }
                    }
                    else
                    {
                        name = localizer.Get(string.Format("{0}_{1}", enumType.Name, field.Name), enumType.AssemblyName());
                    }
                    //string enumName = enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null).ToString();
                    value = Enum.Parse(enumType, field.Name);

                    objs.Add(new Tuple<string, object>(name, value));
                }
            }

            if (objs.Count > 0)
            {
                enumDic.AddOrUpdate(enumType, objs, (o, n) => n);
            }

            return objs;
        }
コード例 #38
0
ファイル: EventStore.cs プロジェクト: TormodHystad/Bifrost
	    /// <summary>
	    /// Initializes a new instance of <see cref="EventStore"/>
	    /// </summary>
	    /// <param name="repository"><see cref="IEventRepository"/> that persists events</param>
        /// <param name="eventStoreChangeManager">A <see cref="IEventStoreChangeManager"/> for managing changes to the event store</param>
        /// <param name="eventSubscriptionManager">A <see cref="IEventSubscriptionManager"/> for managing event subscriptions</param>
	    /// <param name="localizer"><see cref="ILocalizer" /> that ensures thread has the correct culture.</param>
	    public EventStore(
            IEventRepository repository, 
            IEventStoreChangeManager eventStoreChangeManager, 
            IEventSubscriptionManager eventSubscriptionManager,
            ILocalizer localizer)
        {
            _repository = repository;
            _eventStoreChangeManager = eventStoreChangeManager;
            _eventSubscriptionManager = eventSubscriptionManager;
		    _localizer = localizer;
        }
コード例 #39
0
        /// <summary>
        /// Initializes an instance of <see cref="EventSubscriptionManager"/>
        /// </summary>
        /// <param name="subscriptions">A <see cref="IEventSubscriptions"/> that will be used to maintain subscriptions from a datasource</param>
        /// <param name="typeDiscoverer">A <see cref="ITypeDiscoverer"/> for discovering <see cref="IProcessEvents"/>s in current process</param>
        /// <param name="container">A <see cref="IContainer"/> for creating instances of objects/services</param>
        /// <param name="localizer">A <see cref="ILocalizer"/> for controlling localization while executing subscriptions</param>
        public EventSubscriptionManager(
            IEventSubscriptions subscriptions,
            ITypeDiscoverer typeDiscoverer, 
            IContainer container,
            ILocalizer localizer)
        {
            _subscriptions = subscriptions;
            _typeDiscoverer = typeDiscoverer;
            _container = container;
            _localizer = localizer;

            RefreshAndMergeSubscriptionsFromRepository();
        }
コード例 #40
0
ファイル: CommandCoordinator.cs プロジェクト: JoB70/Bifrost
		/// <summary>
		/// Initializes a new instance of the <see cref="CommandCoordinator">CommandCoordinator</see>
		/// </summary>
		/// <param name="commandHandlerManager">A <see cref="ICommandHandlerManager"/> for handling commands</param>
		/// <param name="commandContextManager">A <see cref="ICommandContextManager"/> for establishing a <see cref="CommandContext"/></param>
        /// <param name="commandSecurityManager">A <see cref="ICommandSecurityManager"/> for dealing with security and commands</param>
		/// <param name="commandValidationService">A <see cref="ICommandValidationService"/> for validating a <see cref="ICommand"/> before handling</param>
		/// <param name="localizer">A <see cref="ILocalizer"/> to use for controlling localization of current thread when handling commands</param>
		public CommandCoordinator(
			ICommandHandlerManager commandHandlerManager,
			ICommandContextManager commandContextManager,
            ICommandSecurityManager commandSecurityManager,
            ICommandValidationService commandValidationService,
			ILocalizer localizer)
		{
			_commandHandlerManager = commandHandlerManager;
			_commandContextManager = commandContextManager;
            _commandSecurityManager = commandSecurityManager;
		    _commandValidationService = commandValidationService;
	    	_localizer = localizer;
		}
コード例 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandCoordinator">CommandCoordinator</see>
 /// </summary>
 /// <param name="commandHandlerManager">A <see cref="ICommandHandlerManager"/> for handling commands</param>
 /// <param name="commandContextManager">A <see cref="ICommandContextManager"/> for establishing a <see cref="CommandContext"/></param>
 /// <param name="commandSecurityManager">A <see cref="ICommandSecurityManager"/> for dealing with security and commands</param>
 /// <param name="commandValidators">A <see cref="ICommandValidators"/> for validating a <see cref="ICommand"/> before handling</param>
 /// <param name="localizer">A <see cref="ILocalizer"/> to use for controlling localization of current thread when handling commands</param>
 /// <param name="exceptionPublisher">An <see cref="IExceptionPublisher"/> to send exceptions to</param>
 public CommandCoordinator(
     ICommandHandlerManager commandHandlerManager,
     ICommandContextManager commandContextManager,
     ICommandSecurityManager commandSecurityManager,
     ICommandValidators commandValidators,
     ILocalizer localizer,
     IExceptionPublisher exceptionPublisher)
 {
     _commandHandlerManager = commandHandlerManager;
     _commandContextManager = commandContextManager;
     _commandSecurityManager = commandSecurityManager;
     _commandValidationService = commandValidators;
     _localizer = localizer;
     _exceptionPublisher = exceptionPublisher;
 }
コード例 #42
0
 public AuthorizationManager(
     IPluginsContainer<IClaimProvider> claimProviders,
     IUserInfo userInfo,
     ILogProvider logProvider,
     IAuthorizationProvider authorizationProvider,
     IWindowsSecurity windowsSecurity,
     ILocalizer localizer)
 {
     _userInfo = userInfo;
     _claimProviders = claimProviders;
     _authorizationProvider = authorizationProvider;
     _windowsSecurity = windowsSecurity;
     _logger = logProvider.GetLogger(GetType().Name);
     _performanceLogger = logProvider.GetLogger("Performance");
     _allowBuiltinAdminOverride = FromConfigAllowBuiltinAdminOverride();
     _localizer = localizer;
 }
コード例 #43
0
 public BrigitaCategories(IRepo<Category> repo, ILocalizer<Category> localizer) {
     _repo = repo;
     _localizer = localizer;
 }
コード例 #44
0
 public LocalizeExtension(ILocalizer localizer)
 {
     if (localizer == null) throw new ArgumentNullException("localizer");
     _localizer = localizer;
 }
コード例 #45
0
 /// <summary>
 /// A class factory for localizers.
 /// </summary>
 /// <param name="assembly">
 /// The <see cref="Assembly"/> to use for resource resolution.
 /// </param>
 /// <returns>An instance of <see cref="ILocalizer"/></returns>
 /// <remarks>
 /// If an <see cref="ILocalizer"/> was provided through the constructor,
 /// that instance will be used.
 /// </remarks>
 private ILocalizer GetLocalizer(Assembly assembly)
 {
     if (_localizer == null)
         _localizer = new EmbeddedResourceLocalizer(assembly);
     return _localizer;
 }
コード例 #46
0
		public virtual void  addLocalizer(ILocalizer localizer)
		{
			localizers.Add(localizer);
		}
コード例 #47
0
ファイル: MessagesFilter.cs プロジェクト: xwyangjshb/cuyahoga
 public MessagesFilter(ILocalizer localizer)
 {
     this._localizer = localizer;
 }
コード例 #48
0
ファイル: LoginController.cs プロジェクト: ThinksoftRu/Sototi
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="LoginController"/>.
 /// </summary>
 /// <param name="log">
 /// The log.
 /// </param>
 /// <param name="dataContext">
 /// The data context.
 /// </param>
 public LoginController(ILogger log, IDataContext dataContext, ILocalizer localizer)
     : base(log, dataContext, localizer)
 {
 }
コード例 #49
0
 /// <summary>
 /// Renders this survey section instance.
 /// </summary>
 /// <param name="placeHolder">The place holder.</param>
 /// <param name="readOnly">if set to <c>true</c> [read only].</param>
 /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param>
 /// <param name="validationProvider">The validation provider.</param>
 /// <param name="localizer">Localizes text.</param>
 public void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer)
 {
     Section.RenderSection(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer);
 }
コード例 #50
0
ファイル: EnumHelper.cs プロジェクト: cairabbit/daf
 /// <summary>
 /// 获取枚举类型对象集合
 /// </summary>
 /// <param name="typeName">枚举类型名称</param>
 /// <returns>对象集合</returns>
 public static List<Tuple<string, object>> GetObjectsFromEnum(string typeName, ILocalizer localizer = null)
 {
     Type enumType = Type.GetType(typeName);
     return GetObjectsFromEnum(enumType, localizer);
 }
コード例 #51
0
        /// <summary>
        /// Renders the read-only section in a table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="localizer">Localizes text.</param>
        public void Render(Table table, ILocalizer localizer)
        {
            var row = new TableRow();
            table.Rows.Add(row);

            // cell for the section table
            var cell = new TableCell();
            row.Cells.Add(cell);

            // let's create a new table for this section
            string sectionWrapStyle = localizer.Localize("SectionWrapInlineStyle.Text");
            var sectionTable = new Table();
            sectionTable.Attributes.Add("style", sectionWrapStyle);
            cell.Controls.Add(sectionTable);

            row = new TableRow();
            sectionTable.Rows.Add(row);

            // row for the section title
            string sectionTitleStyle = localizer.Localize("SectionTitleInlineStyle.Text");
            cell = new TableCell { ColumnSpan = 3, Text = this.FormattedText };
            cell.Attributes.Add("style", sectionTitleStyle);
            row.Cells.Add(cell);

            string answerInlineStyle = localizer.Localize("AnswerInlineStyle.Text");
            foreach (IQuestion question in this.GetQuestions())
            {
                Control formControl = Utility.CreateWebControl(question, true, answerInlineStyle, localizer);

                row = new TableRow();
                sectionTable.Rows.Add(row);

                // question
                string questionTitleStyle = localizer.Localize("QuestionTitleInlineStyle.Text");
                cell = new TableCell
                           {
                                   ColumnSpan = 2,
                                   Text = question.FormattedText
                           };
                cell.Attributes.Add("style", questionTitleStyle);
                row.Cells.Add(cell);

                row = new TableRow();
                sectionTable.Rows.Add(row);

                // spacer
                cell = new TableCell { Text = Utility.EntityNbsp, Width = 10 };
                row.Cells.Add(cell);

                // answer
                cell = new TableCell();
                row.Cells.Add(cell);

                cell.Controls.Add(formControl);
            }
        }
コード例 #52
0
ファイル: MainViewModel.cs プロジェクト: dtimyr/xamarin
		public MainViewModel (ILocalizer localaizer)
		{
			this.Localaizer = localaizer;
		}
コード例 #53
0
ファイル: BaseController.cs プロジェクト: ThinksoftRu/Sototi
 /// <summary>
 /// Создает новый экземпляр класса.
 /// </summary>
 /// <param name="log">Протоколирование событий.</param>
 /// <param name="dataContext">Контекст данных.</param>
 protected BaseController(ILogger log, IDataContext dataContext, ILocalizer localizer)
 {
     this.Log = log;
     this.DataContext = dataContext;
     this.Localizer = localizer;
 }
コード例 #54
0
 public void Init()
 {
     localizer = CreateLocalizer();
 }
コード例 #55
0
 public LocalizationFilter(ILocalizer localizer)
 {
     this._localizer = localizer;
 }
コード例 #56
0
        /// <summary>
        /// Renders the survey from this survey.
        /// </summary>
        /// <param name="table">The HTML table to put the survey into.</param>
        /// <param name="localizer">Localizes text.</param>
        public void Render(Table table, ILocalizer localizer)
        {
            Debug.Assert(table != null, "table cannot be null");

            // add the survey title
            if (this.ShowText)
            {
                string titleStyle = localizer.Localize("TitleInlineStyle");
                var row = new TableRow();
                table.Rows.Add(row);
                var cell = new TableCell();
                row.Cells.Add(cell);
                cell.Text = this.Text;
                cell.Attributes.Add("style", titleStyle);
            }

            foreach (ReadonlySection s in this.GetSections())
            {
                s.Render(table, localizer);
            }
        }
コード例 #57
0
ファイル: Utility.cs プロジェクト: krishna23456/Engage-Survey
        /// <summary>
        /// Create a web control for the survey renderer.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <param name="readOnly">if set to <c>true</c> [read only].</param>
        /// <param name="style">The style.</param>
        /// <param name="localizer">Localizes text.</param>
        /// <returns>
        /// A Div with controls in it.
        /// </returns>
        public static Control CreateWebControl(IQuestion question, bool readOnly, string style, ILocalizer localizer)
        {
            WebControl control;
            switch (question.ControlType)
            {
                case ControlType.DropDownChoices:
                    control = (WebControl)RenderDropDownList(question, style, localizer.Localize("DefaultDropDownOption.Text"));
                    break;
                case ControlType.HorizontalOptionButtons:
                    control = (WebControl)RenderHorizontalOptionButtons(question, style);
                    break;
                case ControlType.VerticalOptionButtons:
                    control = (WebControl)RenderVerticalOptionButtons(question, style);
                    break;
                case ControlType.LargeTextInputField:
                    control = (WebControl)RenderLargeTextInputField(question, style);
                    break;
                case ControlType.SmallTextInputField:
                    control = (WebControl)RenderSmallInputField(question, style);
                    break;
                case ControlType.Checkbox:
                    return RenderCheckBoxList(question, readOnly, style, localizer.Localize("CheckBoxLimitExceeded.Format"));
                default:
                    control = new Label { Text = "No control info found for ControlType: " + question.ControlType };
                    break;
            }

            control.Enabled = !readOnly;
            return control;
        }
コード例 #58
0
 public ExceptionFilter(ILocalizer localizer, ILogger logger)
 {
     this._localizer = localizer;
     this._logger = logger;
 }
コード例 #59
0
ファイル: LoginViewModel.cs プロジェクト: dtimyr/xamarin
		public LoginViewModel (ILocalizer localaizer, IPlatformException platformException)
		{
			this.Localaizer = localaizer;
			_platformException = platformException;
		}
コード例 #60
0
 public LocalizationConverter(string context, ILocalizer localizer)
 {
     this.Context = context;
     this.Localizer = localizer;
 }