public void resolve_returns_exception()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = exceptionHelper.Resolve("valid");
     Assert.True(ex is InvalidOperationException);
     Assert.Equal("Here is the message.", ex.Message);
 }
 public void resolve_allows_inner_exception_to_be_provided()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var inner = new ArgumentException();
     var ex = exceptionHelper.Resolve("valid", inner);
     Assert.NotNull(ex.InnerException);
     Assert.Same(inner, ex.InnerException);
 }
 public void resolve_allows_custom_constructor_and_message_formatting_in_tandem()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = exceptionHelper.Resolve("withConstructorAndMessageArgs", new object[] { 1, 2, "more info" }, "param1") as TestException;
     Assert.NotNull(ex);
     Assert.Equal("My message with a parameter: 'param1'", ex.Message);
     Assert.Equal(1, ex.Num1);
     Assert.Equal(2, ex.Num2);
     Assert.Equal("more info", ex.Info);
 }
 public LocalizedArgumentOutOfRangeException(string argument, object min, object max, string key = "Exceptions.ArgumentOutOfRangeException", string defaultMessage = null, object parameters = null, Exception innerException = null)
     : base(defaultMessage, innerException)
 {
     if (defaultMessage == null)
     {
         defaultMessage = "Value must be in the range {0} to {1}";
     }
     Localization = new ExceptionHelper(this, key, defaultMessage, parameters);
     Localization.AddParameter("Minimum", min).AddParameter("Maximum", max);
 }
 public void resolve_allows_custom_constructor_to_be_called()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = exceptionHelper.Resolve("withConstructorArgs", new object[] { 1, 2, "more info" }, (Exception)null) as TestException;
     Assert.NotNull(ex);
     Assert.Equal("A message.", ex.Message);
     Assert.Equal(1, ex.Num1);
     Assert.Equal(2, ex.Num2);
     Assert.Equal("more info", ex.Info);
 }
 public void exception_helper_resource_can_be_in_custom_location()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture), "Kent.Boogaart.HelperTrinity.UnitTests.ExceptionHelper.Subfolder.CustomExceptionHelperResource.xml");
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.ResolveAndThrowIf(true, "anException"));
     Assert.Equal("Here is the message.", ex.Message);
 }
 public void resolve_throws_if_type_is_not_an_exception()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.Resolve("typeNotException"));
     Assert.Equal("Type 'System.DateTime' for exception with key 'typeNotException' does not inherit from 'System.Exception'", ex.Message);
 }
Exemple #8
0
 /// <summary>
 /// Gets an object that can iterate through information of substrings in this string (or a part of this string)
 /// that are delimited by the specified separator.
 /// </summary>
 /// <param name="str">This string instance.</param>
 /// <param name="separator">A string instance that delimits the substrings in the current string instance.</param>
 /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
 /// <param name="removeEmptyEntries"><c>true</c> if the returned enumerator should ignore empty substrings; otherwise <c>false</c>.</param>
 /// <param name="trim">Indicates whether the returned substrings are trimmed.
 /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will not be returned;
 /// for example, in this case "ab,,   ,,cd" split by dual-comma ",," is "ab" and "cd".</para></param>
 /// <returns>
 /// An object that can iterate through information of substrings in the current string instance (or a part of the current string instance)
 /// that are delimited by the specified separator.
 /// </returns>
 public static IEnumerator <StringSplitResult> GetSplitEnumeratorEx(this string str, string separator, int startIndex = 0, bool removeEmptyEntries = false, bool trim = false)
 {
     ExceptionHelper.NonNegativeArgumentRequired("startIndex", startIndex);
     return(_innerGetSplitEnumeratorEx(str, separator, startIndex, str.Length, removeEmptyEntries, trim));
 }
 public LocalizedFileNotFoundException(string filename, string key = "Exceptions.FileNotFoundException", string defaultMessage = null, object parameters = null, Exception innerException = null)
     : base(defaultMessage, innerException)
 {
     Localization = new ExceptionHelper(this, key, defaultMessage, parameters);
     Localization.AddParameter("FileName", filename);
 }
 public void resolve_throws_if_key_is_not_found()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.Resolve("invalidKey"));
     Assert.Equal("The exception details for key 'invalidKey' could not be found at /exceptionHelper/exceptionGroup[@type'Kent.Boogaart.HelperTrinity.UnitTests.ExceptionHelperFixture']/exception[@key='invalidKey'].", ex.Message);
 }
Exemple #11
0
 /// <summary>
 /// Gets an object that can iterate through groups of substrings in this string instance (or a part of the current string instance according to <paramref name="startIndex"/> and <paramref name="length"/>) that are delimited by the primary and secondary Unicode separators outside quotes.
 /// </summary>
 /// <param name="str">This string instance.</param>
 /// <param name="primarySeparator">A primary spearator delimits substring groups, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the semi-comma ';' is the primary separator.</param>
 /// <param name="secondarySeparator">A secondary separator delimits substrings in a group, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the comma ',' is the secondary separator.</param>
 /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
 /// <param name="length">A positive value indicating the number of characters to search starting from the position specified by <paramref name="startIndex" />.</param>
 /// <param name="leftQuotes">Specifies an array of Unicode characters as the left quotes.
 /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />.</param>
 /// <param name="rightQuotes">Specifies an array of Unicode characters as the right quotes.
 /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />.</param>
 /// <param name="removeEmptyEntries"><c>true</c> if empty strings should be ignored; otherwise <c>false</c>.</param>
 /// <param name="removeEmptyGroups"><c>true</c> if empty substring groups should be ignored by the returned enumerator; otherwise, <c>false</c>.</param>
 /// <param name="trim">Indicates whether the returned substrings are trimmed.
 /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will be ignored by the returned enumerator;
 /// for example, in this case "ab,   ,cd" split by comma ',' is "ab" and "cd".</para></param>
 /// <param name="keepQuotes"><c>true</c> if the quotes should be included in each returned substring; otherwise, <c>false</c>.</param>
 /// <returns>An object that can iterate through groups of substrings in this string instance (or a part of the current string instance) that are delimited by the primary and secondary separators.</returns>
 public static IEnumerator <string[]> GetDoubleSplitEnumeratorWithQuotes(this string str, char primarySeparator, char secondarySeparator, int startIndex, int length, char[] leftQuotes, char[] rightQuotes, bool removeEmptyEntries = false, bool removeEmptyGroups = false, bool trim = false, bool keepQuotes = true)
 {
     ExceptionHelper.ForwardCheckStartIndexAndLength(startIndex, length, str.Length);
     return(new _innerDoubleSplitEnumerator02(str, startIndex, str.Length, c1 => c1 == primarySeparator, c2 => c2 == secondarySeparator, leftQuotes, rightQuotes, removeEmptyEntries, removeEmptyGroups, trim, keepQuotes));
 }
Exemple #12
0
        /// <summary>
        /// Gets an object that can iterate through groups of substrings in this string instance (or a part of the current string instance according to <paramref name="startIndex"/> and <paramref name="length"/>) that are delimited by Unicode characters outside quotes and satisfying the specified primary predicate and secondary predicate.
        /// </summary>
        /// <param name="str">This string instance.</param>
        /// <param name="primaryPredicate">A function used to test each Unicode character of the current string. If a character passes this predicate, it returns a non-negative integer as the separator's index; otherwise, this function must return -1. Any character satisfying this predicate will be used as the primary separator. A primary spearator delimits substring arrays, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the semi-comma ';' is the primary separator.</param>
        /// <param name="secondaryPredicate">A function used to test each Unicode character of the current string. If a character passes this predicate, it returns a non-negative integer as the separator's index; otherwise, this function must return -1. Any character satisfying this predicate will be used as the secondary separator. A secondary separator delimits substrings in an array, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the comma ',' is the secondary separator.</param>
        /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
        /// <param name="length">A positive value indicating the number of characters to search starting from the position specified by <paramref name="startIndex" />.</param>
        /// <param name="leftQuotes">Specifies an array of Unicode characters as the left quotes.
        /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />.</param>
        /// <param name="rightQuotes">Specifies an array of Unicode characters as the right quotes.
        /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />.</param>
        /// <param name="removeEmptyEntries"><c>true</c> if empty strings should be ignored; otherwise <c>false</c>.</param>
        /// <param name="removeEmptyGroups"><c>true</c> if empty substring groups should be ignored by the returned enumerator; otherwise, <c>false</c>.</param>
        /// <param name="trim">Indicates whether the returned substrings are trimmed.
        /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will be ignored by the returned enumerator;
        /// for example, in this case "ab,   ,cd" split by comma ',' is "ab" and "cd".</para></param>
        /// <param name="keepQuotes"><c>true</c> if the quotes should be included in each returned substring; otherwise, <c>false</c>.</param>
        /// <returns>An object that can iterate through groups of substrings in this string instance (or a part of the current string instance) that are delimited by Unicode characters satisfying the specified two predicates.</returns>
        public static IEnumerator <string[]> GetDoubleSplitEnumeratorWithQuotes(this string str, Func <char, bool> primaryPredicate, Func <char, bool> secondaryPredicate, int startIndex, int length, char[] leftQuotes, char[] rightQuotes, bool removeEmptyEntries = false, bool removeEmptyGroups = false, bool trim = false, bool keepQuotes = true)
        {
            var endIndex = ExceptionHelper.ForwardCheckStartIndexAndLength(startIndex, length, str.Length);

            return(new _innerDoubleSplitEnumerator02(str, startIndex, endIndex, primaryPredicate, secondaryPredicate, leftQuotes, rightQuotes, removeEmptyEntries, removeEmptyGroups, trim, keepQuotes));
        }
Exemple #13
0
 /// <summary>
 /// Gets an object that can iterate through groups of substrings in this string instance (or a part of the current string instance according to <paramref name="startIndex"/>) that are delimited by Unicode characters outside quotes and satisfying the specified primary predicate and secondary predicate.
 /// </summary>
 /// <param name="str">This string instance.</param>
 /// <param name="primaryPredicate">A function used to test each Unicode character of the current string. If a character passes this predicate, it returns a non-negative integer as the separator's index; otherwise, this function must return -1. Any character satisfying this predicate will be used as the primary separator. A primary spearator delimits substring arrays, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the semi-comma ';' is the primary separator.</param>
 /// <param name="secondaryPredicate">A function used to test each Unicode character of the current string. If a character passes this predicate, it returns a non-negative integer as the separator's index; otherwise, this function must return -1. Any character satisfying this predicate will be used as the secondary separator. A secondary separator delimits substrings in an array, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the comma ',' is the secondary separator.</param>
 /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
 /// <param name="leftQuote">The left quote paired by <paramref name="rightQuote"/> to escape separators.</param>
 /// <param name="rightQuote">The right quote paired by <paramref name="leftQuote"/> to escape separators.</param>
 /// <param name="removeEmptyEntries"><c>true</c> if empty strings should be ignored; otherwise <c>false</c>.</param>
 /// <param name="removeEmptyGroups"><c>true</c> if empty substring groups should be ignored by the returned enumerator; otherwise, <c>false</c>.</param>
 /// <param name="trim">Indicates whether the returned substrings are trimmed.
 /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will be ignored by the returned enumerator;
 /// for example, in this case "ab,   ,cd" split by comma ',' is "ab" and "cd".</para></param>
 /// <param name="keepQuotes"><c>true</c> if the quotes should be included in each returned substring; otherwise, <c>false</c>.</param>
 /// <returns>An object that can iterate through groups of substrings in this string instance (or a part of the current string instance) that are delimited by Unicode characters satisfying the specified two predicates.</returns>
 public static IEnumerator <string[]> GetDoubleSplitEnumeratorWithQuotes(this string str, Func <char, bool> primaryPredicate, Func <char, bool> secondaryPredicate, int startIndex, char leftQuote = '{', char rightQuote = '}', bool removeEmptyEntries = false, bool removeEmptyGroups = false, bool trim = false, bool keepQuotes = true)
 {
     ExceptionHelper.NonNegativeArgumentRequired("startIndex", startIndex);
     return(new _innerDoubleSplitEnumerator01(str, startIndex, str.Length, primaryPredicate, secondaryPredicate, leftQuote, rightQuote, removeEmptyEntries, removeEmptyGroups, trim, keepQuotes));
 }
        static void Main(string[] args)
        {
            #region Using static - ex1
            EncryptUtil.EncryptFiles();
            #endregion

            #region nameOf - ex1
            //var customer = new Customer("John D.");
            //customer.FullName = "John Denver";
            //customer.FullName = "Bob C.";
            #endregion

            #region nameOf - ex2
            // WpfApp1
            #endregion

            #region String Interpolation - ex1
            // 1. -> PersonUnitTests.cs
            #endregion

            #region String Interpolation - ex2
            var p = new Person("", "John");
            Console.WriteLine($"p.FullName: {p.FullName}");
            #endregion

            #region Null Conditional Operator - ex1 FooBar

            FooBar nullSample = null;

            #region 1
            if (nullSample != null && nullSample.Foo != null && nullSample.Foo.Bar != null)
            {
                nullSample.Foo.Bar.SayBar();
            }
            #endregion

            #region 2
            nullSample?.Foo?.Bar?.SayBar();
            #endregion

            #endregion

            #region Null Conditional Operator - ex2
            // Customer.cs - Null-Cond Operator - ex2
            #endregion

            #region Null Conditional Operator - ex3
            var points = new[]
            {
                new Point() {X = 3100, Y = 3200 },
                null
            };

            //Console.WriteLine(points[0]?.ToString());
            //Console.WriteLine(points[1]?.ToString());
            #endregion

            #region Null Conditional Operator - ex 4
            //Point[] points2 = null;
            //Point[] points3 = new Point[] { }; // !
            //Console.WriteLine(points2[0]?.ToString());
            #endregion

            #region AutoProperty - ex1

            //var company1 = Company.NewCompany1;

            #endregion

            #region Expression Bodied Methods - ex1
            //var company2 = Company.NewCompany2();
            #endregion

            #region Expression Bodied Methods - ex2
            //var company3 = new Company("Coca-Cola", "Iasi");
            //Console.WriteLine(company3.ToString());
            #endregion

            #region Expression Bodied Methods - ex3 companes
            var companies = new Companies();
            companies.Add(new Company("c1", "Iasi"));
            companies.Add(new Company("c2", "Cluj"));
            companies.Add(new Company("c3", "Bucuresti"));

            //Console.WriteLine($"expression bodied methods - ex3, company: {companies["c3"]}");

            #endregion

            #region DictionaryInitializer - ex1
            var dicHelper = new DictionaryHelper();
            #endregion

            #region DictionaryInitializer - ex3
            var dic = dicHelper.Ex3();
            //Console.WriteLine("ex3 - dictionary initializer");
            //Console.WriteLine(dic[10]);

            // ! Console.WriteLine(dic[2]);

            #endregion

            #region DictionaryInitializer - ex4
            var list = dicHelper.Ex4();

            Console.WriteLine(list[4]);
            #endregion

            #region ExceptionImprov - ex1
            var wHandler = new ExceptionHelper();
            wHandler.ReadDataFromGoogle();
            #endregion

            #region ExceptionImprov - ex2 await
            var wHandler2 = new ExceptionHelper();
            //wHandler2.ReadDataFromGoogle2();
            #endregion

            #region ExceptionImprov - ex3
            //wHandler.ShowCompanyDetails();
            #endregion

            Console.WriteLine("");
        }
 public LocalizedArgumentNullException(string paramName, string key = "Exceptions.ArgumentNullException", string defaultMessage = null, object parameters = null, Exception innerException = null)
     : base(paramName, defaultMessage)
 {
     Localization = new ExceptionHelper(this, key, defaultMessage, parameters);
     Localization.AddParameter("ParamName", paramName);
 }
 /// <summary>
 /// Reports the zero-based index of the last occurrence of the specified <paramref name="value" /> outside quotes in this string. The search starts from <pararef name="startIndex" /> and advances towards the beginning of the current string.
 /// </summary>
 /// <param name="str">This string instance.</param>
 /// <param name="value">The substring to seek.</param>
 /// <param name="startIndex">The search starting position.</param>
 /// <param name="primaryLeftQuotes">Specifies an array of Unicode characters as the primary left quotes. A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="primaryRightQuote" />.</param>
 /// <param name="primaryRightQuotes">Specifies an array of Unicode characters as the primary right quotes. A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="primaryLeftQuote" />.</param>
 /// <param name="secondaryLeftQuotes">Specifies an array of Unicode characters as the secondary left quotes. A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="secondaryRightQuotes" />. Secondary quotes are escaped when they are inside a pair of primary quotes.</param>
 /// <param name="secondaryRightQuotes">Specifies an array of Unicode characters as the secondary right quotes. A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="secondaryLeftQuotes" />. Secondary quotes are escaped when they are inside a pair of primary quotes.</param>
 /// <param name="comparisonType">One of the enumeration values that specifies the rules for the search of <paramref name="value" />.</param>
 /// <returns>
 /// The zero-based index position of the last occurrence of <paramref name="value" /> if it is found outside quotes, or -1 if it is not.
 /// </returns>
 /// <exception cref="System.FormatException">Occurs when there is quote mismatch in the string instance.</exception>
 public static int LastIndexOfWithQuotes(this string str, string value, int startIndex, char[] primaryLeftQuotes, char[] primaryRightQuotes, char[] secondaryLeftQuotes, char[] secondaryRightQuotes,
                                         StringComparison comparisonType = StringComparison.Ordinal)
 {
     ExceptionHelper.ArgumentRangeRequired("startIndex", startIndex, 0, true, str.Length - 1, true);
     return(_innerLastIndexOfWithQuotes(str, value, startIndex, -1, primaryLeftQuotes, primaryRightQuotes, secondaryLeftQuotes, secondaryRightQuotes, comparisonType));
 }
 public void resolve_allows_formatting_of_exception_message()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = exceptionHelper.Resolve("withMessageArgs", "hello", 12);
     Assert.Equal("Here is the message with argument (hello) or two (12).", ex.Message);
 }
Exemple #18
0
 /// <summary>
 /// Gets an object that can iterate through groups of substrings in this string instance (or a part of the current string instance according to <paramref name="startIndex"/>) that are delimited by the primary and secondary Unicode separators outside quotes.
 /// </summary>
 /// <param name="str">This string instance.</param>
 /// <param name="primarySeparator">A primary spearator delimits substring groups, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the semi-comma ';' is the primary separator.</param>
 /// <param name="secondarySeparator">A secondary separator delimits substrings in a group, for example, in "123,456;abc,def" which represent substring arrays { {"123", "456"}, {"abc", "def"} }, the comma ',' is the secondary separator.</param>
 /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
 /// <param name="leftQuotes">Specifies an array of Unicode characters as the left quotes.
 /// A left quote of an index of this array corresponds to the right quote of that index of the array specified by <paramref name="rightQuotes" />.</param>
 /// <param name="rightQuotes">Specifies an array of Unicode characters as the right quotes.
 /// A right quote of an index of this array corresponds to the left quote of that index of the array specified by <paramref name="leftQuotes" />.</param>
 /// <param name="removeEmptyEntries"><c>true</c> if empty strings should be ignored; otherwise <c>false</c>.</param>
 /// <param name="removeEmptyGroups"><c>true</c> if empty substring groups should be ignored by the returned enumerator; otherwise, <c>false</c>.</param>
 /// <param name="trim">Indicates whether the returned substrings are trimmed.
 /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will be ignored by the returned enumerator;
 /// for example, in this case "ab,   ,cd" split by comma ',' is "ab" and "cd".</para></param>
 /// <param name="keepQuotes"><c>true</c> if the quotes should be included in each returned substring; otherwise, <c>false</c>.</param>
 /// <returns>An object that can iterate through groups of substrings in this string instance (or a part of the current string instance) that are delimited by the primary and secondary separators.</returns>
 public static IEnumerator <string[]> GetDoubleSplitEnumeratorWithQuotes(this string str, char primarySeparator, char secondarySeparator, int startIndex, char[] leftQuotes, char[] rightQuotes, bool removeEmptyEntries = false, bool removeEmptyGroups = false, bool trim = false, bool keepQuotes = true)
 {
     ExceptionHelper.NonNegativeArgumentRequired("startIndex", startIndex);
     return(new _innerDoubleSplitEnumerator02(str, startIndex, str.Length, c1 => c1 == primarySeparator, c2 => c2 == secondarySeparator, leftQuotes, rightQuotes, removeEmptyEntries, removeEmptyGroups, trim, keepQuotes));
 }
 public InnerParserException(string construct, int pos, string key, string defaultMessage, object parameters)
 {
     Localization = new ExceptionHelper(this, key, defaultMessage, parameters);
     Pos = pos;
     Construct = construct;
 }
 public void resolve_throws_if_type_attribute_is_not_found()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.Resolve("noTypeAttribute"));
     Assert.Equal("The 'type' attribute could not be found for exception with key 'noTypeAttribute'", ex.Message);
 }
 public void resolve_throws_if_no_constructor_could_be_found()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.Resolve("noConstructorFound"));
     Assert.Equal("An appropriate constructor could not be found for exception type 'Kent.Boogaart.HelperTrinity.UnitTests.ExceptionHelperFixture+TestException, for exception with key 'noConstructorFound'", ex.Message);
 }
 public void resolve_throws_if_type_could_not_be_loaded()
 {
     var exceptionHelper = new ExceptionHelper(typeof(ExceptionHelperFixture));
     var ex = Assert.Throws<InvalidOperationException>(() => exceptionHelper.Resolve("typeCouldNotBeLoaded"));
     Assert.Equal("Type 'Foo.Bar.Wont.Load, Anywhere' could not be loaded for exception with key 'typeCouldNotBeLoaded'", ex.Message);
 }
 public LocalizedKeyNotFoundException(string key = "Exceptions.KeyNotFoundException", string defaultMessage = null, object parameters = null, Exception innerException = null)
     : base(defaultMessage, innerException)
 {
     Localization = new ExceptionHelper(this, key, defaultMessage, parameters);
 }
Exemple #24
0
        /// <summary>
        /// Gets an object that can iterate through information of substrings in this string (or a part of this string)
        /// that are delimited by the specified separator.
        /// </summary>
        /// <param name="str">This string instance.</param>
        /// <param name="separator">A string instance that delimits the substrings in the current string instance.</param>
        /// <param name="startIndex">The zero-based position indicating where the search for separators starts.</param>
        /// <param name="length">A positive value indicating the number of characters to search starting from the position specified by <paramref name="startIndex" />.</param>
        /// <param name="removeEmptyEntries"><c>true</c> if the returned enumerator should ignore empty substrings; otherwise <c>false</c>.</param>
        /// <param name="trim">Indicates whether the returned substrings are trimmed.
        /// <para>NOTE that if <paramref name="removeEmptyEntries" /> is set <c>true</c>, then a substring containing only white spaces will not be returned;
        /// for example, in this case "ab,,   ,,cd" split by dual-comma ",," is "ab" and "cd".</para></param>
        /// <returns>
        /// An object that can iterate through information of substrings in the current string instance (or a part of the current string instance)
        /// that are delimited by the specified separator.
        /// </returns>
        public static IEnumerator <StringSplitResult> GetSplitEnumeratorEx(this string str, string separator, int startIndex, int length, bool removeEmptyEntries = false, bool trim = false)
        {
            var endIndex = ExceptionHelper.ForwardCheckStartIndexAndLength(startIndex, length, str.Length);

            return(_innerGetSplitEnumeratorEx(str, separator, startIndex, endIndex, removeEmptyEntries, trim));
        }