コード例 #1
1
 internal RemoveStringToFirstOccurrence(RemoveString removeString, string marker)
 {
     _removeString = removeString;
     _marker = marker;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #2
1
 internal RemoveStringStartingOccurrencePosition(RemoveString removeString, The position, int occurrenceCount, string marker)
 {
     _removeString = removeString;
     _position = position;
     _occurrenceCount = occurrenceCount;
     _marker = marker;
 }
コード例 #3
1
 internal InsertStringAfter(InsertString insertString, string marker)
 {
     _insertString = insertString;
     _marker = marker;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #4
1
 internal RemoveValue(string source, string extraction)
 {
     _source = source;
     _extraction = extraction;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #5
1
        private static string RemoveValuesInternal(string source, int? quantity, string extraction, StringComparison comparisonRule, The position = The.Beginning)
        {
            if (quantity < 0)
                throw new ArgumentOutOfRangeException("quantity", "Negative quantity is not supported");

            if (quantity == 0)
                return source;

            return source.Remove(extraction,
                (s, e) =>
                {
                    var indexes = source.IndexesOf(extraction, comparisonRule, position);
                    if (quantity != null)
                        indexes = indexes.Take(quantity.Value);
                    if (position == The.End)
                        indexes = indexes.Reverse();

                    var indexesArray = indexes.ToArray();

                    if (!indexesArray.Any())
                        return source;

                    var start = 0;
                    var resultStringLength = source.Length - indexesArray.Length * extraction.Length;
                    var builder = new StringBuilder(resultStringLength);
                    foreach (var index in indexes)
                    {
                        builder.Append(source.Substring(start, index - start));
                        start = index + extraction.Length;
                    }
                    builder.Append(source.Substring(start));
                    return builder.ToString();
                });
        }
 internal RemoveStringStartingOccurrenceToOccurrencePosition(RemoveStringStartingOccurrence source, The position, int occurrenceCount, string marker)
 {
     _source = source;
     _position = position;
     _occurrenceCount = occurrenceCount;
     _marker = marker;
 }
 internal RemoveStringStartingFirstOccurrencePosition(RemoveString removeString, The position, string marker)
 {
     _removeString = removeString;
     _position = position;
     _marker = marker;
     _ignoreCase = false;
     _from = The.Beginning;
 }
コード例 #8
1
 internal RemoveValues(string source, int quantity, string extraction)
 {
     _source = source;
     _quantity = quantity;
     _extraction = extraction;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #9
1
 internal InsertStringBeforeOccurrence(InsertString insertString, int occurrenceCount, string marker)
 {
     _insertString = insertString;
     _occurrenceCount = occurrenceCount;
     _marker = marker;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #10
1
 internal RemoveStringStartingOccurrence(RemoveString removeString, int occurrenceCount, string marker)
 {
     _removeString = removeString;
     _occurrenceCount = occurrenceCount;
     _marker = marker;
     _ignoreCase = false;
     _position = The.Beginning;
 }
 internal RemoveStringStartingOccurrencePositionToOccurrence(RemoveStringStartingOccurrencePosition removeStringStartingOccurrencePosition, int occurrence, string marker)
 {
     _removeStringStartingOccurrencePosition = removeStringStartingOccurrencePosition;
     _occurrence = occurrence;
     _marker = marker;
     _ignoreCase = false;
     _position = The.Beginning;
 }
コード例 #12
1
 internal RemoveStringToOccurrencePosition(RemoveString removeString, The position, int occurrence, string marker)
 {
     _removeString = removeString;
     _position = position;
     _occurrenceCount = occurrence;
     _marker = marker;
     _ignoreCase = false;
     _from = The.Beginning;
 }
コード例 #13
1
        public static int? IndexOf(this string source, The position, int occurrenceCount, string marker, bool ignoreCase, The from)
        {
            var index = source.IndexOf(occurrenceCount, marker, ignoreCase, from);

            if (index == null)
                return null;

            int shift = position == The.StartOf ? 0 : marker.Length;
            return index.Value + shift;
        }
コード例 #14
1
        public static int? IndexOf(this string source, int occurrenceCount, string marker, bool ignoreCase, The from)
        {
            if (occurrenceCount == 0)
                return null;

            var indexes = source.IndexesOf(marker, ignoreCase, from).Skip(occurrenceCount - 1);

            if (!indexes.Any())
                return null;

            return indexes.First();
        }
コード例 #15
1
 public static string RemoveValues(this string source, int? quantity, string extraction, StringComparison comparisonRule, The position)
 {
     switch (position)
     {
         case The.Beginning:
         case The.End:
             return RemoveValuesInternal(source, quantity, extraction, comparisonRule, position);
         case The.StartOf:
         case The.EndOf:
         default:
             throw new ArgumentOutOfRangeException("position", "Only Beginning and End positions are supported by Remove().From() method");
     }
 }
コード例 #16
1
 public static IEnumerable<int> IndexesOf(this string source, string marker, StringComparison comparisonRule, The position)
 {
     switch (position)
     {
         case The.Beginning:
             return source.IndexesOf(marker, comparisonRule);
         case The.End:
             return source.LastIndexesOf(marker, comparisonRule);
         case The.StartOf:
         case The.EndOf:
         default:
             throw new ArgumentOutOfRangeException("position", "Only Beginning and End positions are supported by IndexesOf().From() method");
     }
 }
コード例 #17
1
 public static IEnumerable<int> IndexesOf(this string source, string marker, bool ignoreCase, The position)
 {
     switch (position)
     {
         case The.Beginning:
             return source.IndexesOf(marker, ignoreCase);
         case The.End:
             return source.IndexesOf(marker, ignoreCase).Reverse();
         case The.StartOf:
         case The.EndOf:
         default:
             throw new ArgumentOutOfRangeException("position", "Only Beginning and End positions are supported by IndexesOf().From() method");
     }
 }
コード例 #18
1
 public static string RemoveStartingOrTo(this string source, string marker, bool ignoreCase, The from, bool isStarting)
 {
     switch (from)
     {
         case The.Beginning:
             return source.RemoveStartingOrTo(marker, ignoreCase, isStarting, fromBeginning: true);
         case The.End:
             return source.RemoveStartingOrTo(marker, ignoreCase, isStarting, fromBeginning: false);
         case The.StartOf:
         case The.EndOf:
         default:
             var methodName = isStarting ? "Starting" : "To";
             throw new ArgumentOutOfRangeException(
                 "position", "Only Beginning and End positions are supported by Remove().{0}().From() method".f(methodName));
     }
 }
コード例 #19
1
        private static string InsertWithChecks(this string source, string insertion, string marker, bool ignoreCase, int occurrenceCount, The position, bool after)
        {
            if (occurrenceCount < 0)
                throw new ArgumentOutOfRangeException("occurrence", "Negative occurrence count is not supported");

            if (occurrenceCount == 0)
                return source;

            return source.Insert(insertion, marker,
                (s, i, m) =>
                {
                    var shift = after ? marker.Length : 0;
                    var indexes = s.IndexesOf(m, ignoreCase, position).Take(occurrenceCount).ToArray();
                    return indexes.Any() ? s.Insert(indexes.Last() + shift, i) : s;
                });
        }
コード例 #20
1
 public static string Insert(
     this string source, string insertion, string marker, bool ignoreCase = false,
     The position = The.Beginning, int? occurrenceCount = null, bool after = false)
 {
     switch (position)
     {
         case The.Beginning:
         case The.End:
             return occurrenceCount != null
                 ? source.InsertWithChecks(insertion, marker, ignoreCase, occurrenceCount.Value, position, after)
                 : source.InsertWithChecks(insertion, marker, ignoreCase, position, after);
         case The.StartOf:
         case The.EndOf:
         default:
             throw new ArgumentOutOfRangeException("position", "Only Beginning and End positions are supported by Insert().From() method");
     }
 }
コード例 #21
1
        public static string RemoveStartingOrTo(this string source, int occurrenceCount, string marker, bool ignoreCase, The from, bool isStarting)
        {
            if (occurrenceCount < 0)
                throw new ArgumentOutOfRangeException("occurrenceCount", "Negative occurrence count is not supported");

            if (occurrenceCount == 0)
                return source;

            return source.Remove(marker,
                (s, m) =>
                {
                    var index = source.IndexOf(occurrenceCount, marker, ignoreCase, from);

                    if (index == null)
                        return source;

                    return isStarting ? source.Substring(0, index.Value) : source.Remove(0, index.Value);
                },
                (s, m) => isStarting ? null : String.Empty);
        }
コード例 #22
1
ファイル: CommonLogic.cs プロジェクト: jorik041/FluentStrings
        public static string RemoveStartingOrToPosition(this string source, The position, int occurrenceCount, string marker, bool ignoreCase, The from, bool isStarting)
        {
            if (occurrenceCount < 0)
                throw new ArgumentOutOfRangeException("occurrenceCount", "Negative occurrence count is not supported");

            if (occurrenceCount == 0)
                return source;

            switch (position)
            {
                case The.StartOf:
                case The.EndOf:
                    break;
                case The.Beginning:
                case The.End:
                default:
                    throw new ArgumentOutOfRangeException("position", "Only StartOf and EndOf positions are supported by Remove().Starting() method");
            }

            return source.Remove(marker,
                (s, m) =>
                {
                    var indexes = source.IndexesOf(marker, ignoreCase, from).Skip(occurrenceCount - 1);

                    if (!indexes.Any())
                        return source;

                    int shift = position == The.StartOf ? 0 : marker.Length;
                    var index = indexes.First() + shift;

                    if (index >= source.Length)
                        return isStarting ? source : String.Empty;

                    return isStarting ? source.Substring(0, index) : source.Remove(0, index);
                },
                (s, m) =>
                {
                    return isStarting || position == The.EndOf ? null : String.Empty;
                });
        }
コード例 #23
1
ファイル: Default.aspx.cs プロジェクト: midi9x/csdlpt
 protected void btnRight2_Click(object sender, EventArgs e)
 {
     try
     {
         The t = new The();
         string SoThe = txtThe.Text;
         t = data.GetAThe(SoThe);
         if (t != null)
         {
             Session["SoThe"] = SoThe.ToString();
             Response.Redirect("NhapMaPin.aspx");
         }
         else
         {
             lblmsg.Text = "Thẻ không tồn tại";
         }
     }
     catch(Exception ex)
     {
         Response.Write("<script>alert('"+ex.Message+"');</script>");
     }
 }
コード例 #24
1
ファイル: CommonLogic.cs プロジェクト: jorik041/FluentStrings
        public static string RemoveStartingOrTo(this string source, int occurrenceCount, string marker, bool ignoreCase, The from, bool isStarting)
        {
            if (occurrenceCount < 0)
                throw new ArgumentOutOfRangeException("occurrenceCount", "Negative occurrence count is not supported");

            if (occurrenceCount == 0)
                return source;

            return source.Remove(marker,
                (s, m) =>
                {
                    var indexes = source.IndexesOf(marker, ignoreCase, from).Skip(occurrenceCount - 1);

                    if (!indexes.Any())
                        return source;

                    return isStarting ? source.Substring(0, indexes.First()) : source.Remove(0, indexes.First());
                },
                (s, m) =>
                {
                    return isStarting ? null : String.Empty;
                });
        }
 internal RemoveStringToOccurrencePositionIgnoringCaseFrom(RemoveStringToOccurrencePositionIgnoringCase removeStringToOccurrencePositionIgnoringCase, The position)
 {
     _removeStringToOccurrencePositionIgnoringCase = removeStringToOccurrencePositionIgnoringCase;
     _position = position;
 }
コード例 #26
1
 /// <summary>
 /// Extends IndexesOf.IgnoringCase action with the ability to change starting point.
 /// </summary>
 /// <param name="position">
 /// Position in source string to start from. Beginning or End value can be used.
 /// </param>
 /// <exception cref="System.ArgumentOutOfRangeException">Thrown when StartOf or EndOf position value is used</exception>
 public static IndexesOfValueIgnoringCaseFrom From(this IndexesOfValueIgnoringCase source, The position)
 {
     return new IndexesOfValueIgnoringCaseFrom(source, position);
 }
コード例 #27
1
 internal RemoveValueFrom(RemoveValue removeValue, The position)
 {
     _removeValue = removeValue;
     _position = position;
 }
コード例 #28
0
 internal RemoveStringToFirstOccurrencePosition(RemoveString removeString, The position, string marker)
 {
     _removeString = removeString;
     _position = position;
     _marker = marker;
 }
コード例 #29
0
 public void should_throw_a_managed_exception()
 {
     The.Action(() => sut.CreateNewTemplateFromChart(new CurveChart(), _existingTemplates)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #30
0
 public void should_throw_an_exception_explaining_that_the_parameter_cannot_be_found()
 {
     The.Action(() => sut.UpdateStartValuesFromSimulation(_identificationParameter)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #31
0
 private static string InsertWithChecks(this string source, string insertion, string marker, bool ignoreCase, The position, bool after)
 {
     return source.Insert(insertion, marker,
         (s, i, m) =>
         {
             var indexShift = 0;
             var afterShift = after ? marker.Length : 0;
             var indexes = s.IndexesOf(m, ignoreCase, position).ToArray();
             var builder = new StringBuilder(s, insertion.Length * indexes.Length);
             foreach (var index in indexes)
             {
                 builder.Insert(index + indexShift + afterShift, insertion);
                 indexShift += insertion.Length;
             }
             return builder.ToString();
         });
 }
コード例 #32
0
 /// <summary>
 /// Load ds ve phat hanh
 /// </summary>
 private void LoadDSTheHuy()
 {
     grdTheHuy.DataMember = "ListTheHuy";
     grdTheHuy.SetDataBinding(The.GetDSThe(), "ListTheHuy");
 }
コード例 #33
0
ファイル: CommonLogic.cs プロジェクト: canro91/Testing101
 private static string InsertWithChecks(this string source, string insertion, string marker, bool ignoreCase, The position, bool after)
 {
     return(source.Insert(insertion, marker,
                          (s, i, m) =>
     {
         var indexShift = 0;
         var afterShift = after ? marker.Length : 0;
         var indexes = s.IndexesOf(m, ignoreCase, position).ToArray();
         var builder = new StringBuilder(s, insertion.Length * indexes.Length);
         foreach (var index in indexes)
         {
             builder.Insert(index + indexShift + afterShift, insertion);
             indexShift += insertion.Length;
         }
         return builder.ToString();
     }));
 }
コード例 #34
0
 internal RemoveStringStartingOccurrenceToFrom(RemoveStringStartingOccurrenceTo source, The position)
 {
     _source   = source;
     _position = position;
 }
コード例 #35
0
 public void should_throw_an_exception_stipulating_that_the_default_alternative_cannot_be_deleted()
 {
     The.Action(() => sut.RemoveParameterGroupAlternative(_groupAlternative, _alternative)).ShouldThrowAn <CannotDeleteDefaultParameterAlternativeException>();
 }
コード例 #36
0
 public void should_throw_an_exception()
 {
     The.Action(() => sut.RunBatchAsync(_exportRunOptions)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #37
0
 public void should_thrown_an_exception_explaining_that_the_axis_cannot_be_removed()
 {
     The.Action(() => { _axisSettingsPresenter.AxisRemoved += Raise.With(new AxisEventArgs(_axisY2)); }).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #38
0
 public void should_be_able_to_retrieve_all_the_values()
 {
     The.Action(() => sut.SetValue(individualId: 2, pkValue: 0.2f)).ShouldThrowAn <Exception>();
 }
コード例 #39
0
 public void should_use_the_distribution_max_as_upper_bound()
 {
     The.Action(() => sut.RandomDeviateIn(_randomGenerator)).ShouldThrowAn <LimitsNotInUniformDistributionFunctionRangeException>();
 }
コード例 #40
0
 public void should_trow_an_exception()
 {
     The.Action(() => VisitorInvoker.InvokeVisit(_visitor, _mySimpleClass)).ShouldThrowAn <AmbiguousVisitMethodException>();
 }
コード例 #41
0
 public void should_do_nothing()
 {
     The.Action(() => VisitorInvoker.InvokeVisit(_visitor, _myVisitableClass)).ShouldThrowAn <UnableToVisitObjectException>();
 }
コード例 #42
0
 public void should_throw_an_exception()
 {
     The.Action(() => sut.Execute()).ShouldThrowAn <OSPSuiteException>();
 }
 internal RemoveStringStartingFromToOccurrencePosition(RemoveStringStartingFrom source, The position, int occurrenceCount, string marker)
 {
     _source          = source;
     _position        = position;
     _occurrenceCount = occurrenceCount;
     _marker          = marker;
 }
コード例 #44
0
 public void should_throw_an_information_exception_explaining_to_the_user_that_the_object_cannot_be_loaeder()
 {
     The.Action(() => sut.Load(_relatedItem)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #45
0
 public void should_throw_an_exception_stipulating_that_at_least_one_exception_needs_to_be_defined()
 {
     The.Action(() => sut.RemoveParameterGroupAlternative(_groupAlternative, _alternative)).ShouldThrowAn <CannotDeleteParameterAlternativeException>();
 }
コード例 #46
0
 public void should_throw_an_not_unique_id_exception()
 {
     The.Action(() => sut.Register(A.Fake <IEntity>().WithId(_entity.Id))).ShouldThrowAn <NotUniqueIdException>();
 }
コード例 #47
0
 internal RemoveStringStartingOccurrencePositionTo(RemoveStringStartingOccurrencePosition removeStringStartingOccurrencePosition, int position)
 {
     _removeStringStartingOccurrencePosition = removeStringStartingOccurrencePosition;
     _positionIndex = position;
     _position      = The.Beginning;
 }
 public void should_throw_an_exception()
 {
     The.Action(() => sut.CreateFor(_simulationParameterSelection, _parameterIdentification)).ShouldThrowAn <DimensionMismatchException>();
 }
コード例 #49
0
 public void should_throw_an_exception_indicating_that_the_simulation_should_be_calculated_first()
 {
     The.Action(() => sut.ExportResultsToExcel(_simulation)).ShouldThrowAn <PKSimException>();
 }
 public void should_throw_a_MissingMoleculeAmountException()
 {
     The.Action(() => sut.MapFromLocal(_reactionPartnerBuilder, _container, _buildConfiguration)).ShouldThrowAn <MissingMoleculeAmountException>();
 }
コード例 #51
0
ファイル: CommonLogic.cs プロジェクト: canro91/Testing101
        private static string InsertWithChecks(this string source, string insertion, string marker, bool ignoreCase, int occurrenceCount, The position, bool after)
        {
            if (occurrenceCount < 0)
            {
                throw new ArgumentOutOfRangeException("occurrence", "Negative occurrence count is not supported");
            }

            if (occurrenceCount == 0)
            {
                return(source);
            }

            return(source.Insert(insertion, marker,
                                 (s, i, m) =>
            {
                var shift = after ? marker.Length : 0;
                var indexes = s.IndexesOf(m, ignoreCase, position).Take(occurrenceCount).ToArray();
                return indexes.Any() ? s.Insert(indexes.Last() + shift, i) : s;
            }));
        }
コード例 #52
0
 public static bool IsA <T>(this T source, string stringType)
 {
     return(The.Same(source.GetType(), The.Type(stringType)));
 }
コード例 #53
0
 public void should_throw_an_exception_if_the_path_does_not_exist_in_the_simulation()
 {
     The.Action(() => sut.SetValueByPath(_simulation, pathFrom(_liver.Name, INTRACELLULAR, "TOTO"), 5, throwIfNotFound: true)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #54
0
 public void should_throw_an_exception()
 {
     The.Action(() => sut.CreatePopulation(_populationCharacteristics)).ShouldThrowAn <OSPSuiteException>();
 }
コード例 #55
0
 internal RemoveStringStartingFromToFrom(RemoveStringStartingFromTo removeStringStartingFromTo, The position)
 {
     _removeStringStartingFromTo = removeStringStartingFromTo;
     _position = position;
 }
コード例 #56
0
 public void should_throw_an_argument_exception()
 {
     The.Action(() => sut.GetBuildingBlockFor(A.Fake <IObjectBase>(), A.Fake <IBuildingBlock>())).ShouldThrowAn <ArgumentException>();
 }
コード例 #57
0
 public void should_allow_to_start_a_Step_with_an_Arg()
 {
     The.StepFrom(@"""Arg"" starting a Step".AsLocation())
     .Name.ShouldBe("starting_a_Step");
     And.LastStep.Args[0].ShouldBe("Arg");
 }
コード例 #58
0
 public void should_throw_an_exception()
 {
     The.Action(() => sut.RunAsync(_data, (x, t) => x.Id, CancellationToken.None, 4)).ShouldThrowAn <NotUniqueIdException>();
 }
コード例 #59
0
 void IPositional.Set(The position)
 {
     _position = position;
 }
コード例 #60
0
 public InsertStringBeforeOccurrenceFrom(InsertStringBeforeOccurrence insertStringBeforeOccurrence, The position)
 {
     _insertStringBeforeOccurrence = insertStringBeforeOccurrence;
     _position = position;
 }