/// <summary> /// Initializes a new instance of the <see cref="BoxInfo"/> class. /// </summary> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="defaultLocalization">The default localization.</param> /// <param name="localizations">The localizations.</param> /// <remarks> /// If this constructor is used no configuration file is loaded /// and localization config files are loaded (deserealized and stored in /// cache) as needed (lazy loading) but only if specified /// <c>localizations</c> does not satisfy some localePrefs. /// </remarks> public BoxInfo( Boxes.Serializer.Configuration.IHelper configurationHelper, Boxes.Serializer.Localization.IHelper defaultLocalization, Boxes.Serializer.Localization.IHelper[] localizations ) { if (configurationHelper == null) { string message = "BoxInf18: Unable to get config for " + this.identifier; Debug.WriteLine(message); throw new ArgumentNullException(message); } this.box = configurationHelper; if (defaultLocalization == null) { string message = "BoxInf19: Unable to get default localization for " + this.identifier; Debug.WriteLine(message); throw new ArgumentNullException(message); } this.boxLocalizations.Add(defaultLanguageId, defaultLocalization); if (localizations.Length > 0) { foreach (Boxes.Serializer.Localization.IHelper localization in localizations) { this.boxLocalizations.Add(localization.LocaleId, localization); } } }
/// <summary> /// <para>Default constructor.</para> /// <para>Loads box config file (independent on localization) /// i.e. stores box config file deserealization to /// <see cref="F:Ferda.Modules.Boxes.BoxInfo.box">cache</see>. /// </para> /// <para>Config files are loaded from <see cref="F:Ferda.Modules.Boxes.BoxInfo.ConfigFilesDirectoryPath"/>.</para> /// </summary> /// <remarks> /// Localization config files are loaded (deserealized and stored in /// cache) as needed (lazy loading). /// </remarks> /// <seealso cref="T:Ferda.Modules.Boxes.Serializer.Configuration.Helper"/> /// <exception cref="T:System.Exception">Thrown iff getting box config faild.</exception> protected BoxInfo() { //Deserealize and store box config file this.box = new Boxes.Serializer.Configuration.Helper( Boxes.Serializer.Reader.ReadBox( Path.Combine(this.ConfigFilesDirectoryPath, boxCofigFileName) ) ); //Deserealization has to be sucessful if (this.box == null) { string message = "BoxInf01: Unable to get config for " + this.identifier; Debug.WriteLine(message); throw new Exception(message); } }
/// <summary> /// Initializes a new instance of the <see cref="BoxInfo"/> class. /// </summary> /// <param name="configurationHelper">The configuration helper.</param> /// <remarks> /// If this constructor is used no configuration file is loaded /// and localization config files are loaded (deserealized and stored in /// cache) as needed (lazy loading). /// </remarks> public BoxInfo(Boxes.Serializer.Configuration.IHelper configurationHelper) { if (configurationHelper == null) { string message = "BoxInf17: Unable to get config for " + this.identifier; Debug.WriteLine(message); throw new ArgumentNullException(message); } this.box = configurationHelper; }