/// <summary> /// Gets the search filter instance. /// </summary> /// <param name="localName">Name of the local.</param> /// <returns></returns> private static SearchFilter GetSearchFilterInstance(string localName) { SearchFilter searchFilter; switch (localName) { case XmlElementNames.Exists: searchFilter = new Exists(); break; case XmlElementNames.Contains: searchFilter = new ContainsSubstring(); break; case XmlElementNames.Excludes: searchFilter = new ExcludesBitmask(); break; case XmlElementNames.Not: searchFilter = new Not(); break; case XmlElementNames.And: searchFilter = new SearchFilterCollection(LogicalOperator.And); break; case XmlElementNames.Or: searchFilter = new SearchFilterCollection(LogicalOperator.Or); break; case XmlElementNames.IsEqualTo: searchFilter = new IsEqualTo(); break; case XmlElementNames.IsNotEqualTo: searchFilter = new IsNotEqualTo(); break; case XmlElementNames.IsGreaterThan: searchFilter = new IsGreaterThan(); break; case XmlElementNames.IsGreaterThanOrEqualTo: searchFilter = new IsGreaterThanOrEqualTo(); break; case XmlElementNames.IsLessThan: searchFilter = new IsLessThan(); break; case XmlElementNames.IsLessThanOrEqualTo: searchFilter = new IsLessThanOrEqualTo(); break; default: searchFilter = null; break; } return(searchFilter); }
public void No_match_if_equal() { var isLessThanEight = new IsLessThan <int>(8); var matches = isLessThanEight.Matches(8); Assert.False(matches); }
public void No_match_if_not_less() { var isLessThanEight = new IsLessThan <int>(8); var matches = isLessThanEight.Matches(9); Assert.IsFalse(matches); }
public void No_match_if_not_less() { var isLessThanEight = new IsLessThan<int>(8); var matches = isLessThanEight.Matches(9); Assert.IsFalse(matches); }
public void IsLessThan_HandleType_ShouldReturnIsLessThan() { var decisionType = enDecisionType.IsLessThan; //------------Setup for test-------------------------- var isLessThan = new IsLessThan(); //------------Execute Test--------------------------- //------------Assert Results------------------------- Assert.AreEqual(decisionType, isLessThan.HandlesType()); }
/// <summary> /// Deserializes the specified configuration in an <see cref="Iterate"/> object /// </summary> /// <param name="configuration">The configuration.</param> /// <returns></returns> public override SqlTag Deserialize(IConfiguration configuration) { IsLessThan isLessThan = new IsLessThan(accessorFactory); isLessThan.Prepend = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "prepend"); isLessThan.Property = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "property"); isLessThan.CompareProperty = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "compareProperty"); isLessThan.CompareValue = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "compareValue"); return(isLessThan); }
public SqlTag Deserialize(XmlNode node) { IsLessThan than = new IsLessThan(this._configScope.DataExchangeFactory.AccessorFactory); NameValueCollection attributes = NodeUtils.ParseAttributes(node, this._configScope.Properties); than.Prepend = NodeUtils.GetStringAttribute(attributes, "prepend"); than.Property = NodeUtils.GetStringAttribute(attributes, "property"); than.CompareProperty = NodeUtils.GetStringAttribute(attributes, "compareProperty"); than.CompareValue = NodeUtils.GetStringAttribute(attributes, "compareValue"); return(than); }
public void IsLessThan_IsLessThanUnitTest_InvokeWithDecimals_TrueIsReturned() { //init var comparer = new IsLessThan(); //exe var actual = comparer.Invoke(new[] { "2.75", "100.25" }); //assert Assert.IsTrue(actual, "IsLessThan returned the wrong result when comparing integers"); }
// ReSharper disable InconsistentNaming public void IsLessThan_IsLessThanUnitTest_Invoke_TrueIsReturned() // ReSharper restore InconsistentNaming { //init var comparer = new IsLessThan(); //exe var actual = comparer.Invoke(new[] { "2", "100" }); //assert Assert.IsTrue(actual, "IsLessThan returned the wrong result when comparing integers"); }
public void IsLessThan_IsLessThanUnitTest_Invoke_FalseIsReturned() { //init var comparer = new IsLessThan(); //exe var actual = comparer.Invoke(new[] { "100", "2" }); //assert Assert.IsFalse(actual, "IsLessThan returned the wrong result when comparing integers"); }
public void FunctionUnderTest_ExpectedResult_UnderCondition(int threshold, int actual, bool expected) { // Arrange var sut = new IsLessThan { Threshold = threshold, Actual = actual }; // Act // Assert Assert.Equal(expected, sut.IsSatisfied()); }
public void IsLessThan_Returns_Expected_For_Given(int threshold, int actual, bool expected) { // Arrange var sut = new IsLessThan { Threshold = threshold, Actual = actual }; // Act // Assert Assert.AreEqual(expected, sut.IsSatisfied()); }
public void IsLessThan_IsLessThanUnitTest_Invoke_TrueIsReturned() { //init var comparer = new IsLessThan(); //exe var actual = comparer.Invoke(new[] { "2", "100" }); //assert Assert.IsTrue(actual, "IsLessThan returned the wrong result when comparing integers"); //exe actual = comparer.Invoke(new[] { "SomeVal", "Val2" }); //assert Assert.IsTrue(actual, "IsLessThan returned the wrong result when comparing strings"); //exe actual = comparer.Invoke(new[] { string.Empty }); //assert Assert.IsFalse(actual, "IsLessThan returned the wrong result when comparing empty string"); }
/// <summary> /// Gets the search filter instance. /// </summary> /// <param name="localName">Name of the local.</param> /// <returns></returns> private static SearchFilter GetSearchFilterInstance(string localName) { SearchFilter searchFilter; switch (localName) { case XmlElementNames.Exists: searchFilter = new Exists(); break; case XmlElementNames.Contains: searchFilter = new ContainsSubstring(); break; case XmlElementNames.Excludes: searchFilter = new ExcludesBitmask(); break; case XmlElementNames.Not: searchFilter = new Not(); break; case XmlElementNames.And: searchFilter = new SearchFilterCollection(LogicalOperator.And); break; case XmlElementNames.Or: searchFilter = new SearchFilterCollection(LogicalOperator.Or); break; case XmlElementNames.IsEqualTo: searchFilter = new IsEqualTo(); break; case XmlElementNames.IsNotEqualTo: searchFilter = new IsNotEqualTo(); break; case XmlElementNames.IsGreaterThan: searchFilter = new IsGreaterThan(); break; case XmlElementNames.IsGreaterThanOrEqualTo: searchFilter = new IsGreaterThanOrEqualTo(); break; case XmlElementNames.IsLessThan: searchFilter = new IsLessThan(); break; case XmlElementNames.IsLessThanOrEqualTo: searchFilter = new IsLessThanOrEqualTo(); break; default: searchFilter = null; break; } return searchFilter; }
/// <summary> /// Das ist der Kern der Routine, hier wird alles aufgerollt und dann /// geht es los. /// </summary> public IList <WorkReportItemDTO> RetrieveAppointments() { //Aufruf nur sinnvoll, wenn Objekt konfiguriert if (String.IsNullOrEmpty(_username) || String.IsNullOrEmpty(_password)) { throw new ArgumentException("Username / Password not set!"); } if (String.IsNullOrEmpty(_exchangeServerURI)) { throw new ArgumentException("Exchange Server URI not set!"); } List <WorkReportItemDTO> workReportItems = new List <WorkReportItemDTO>(); NetworkCredential credential = new NetworkCredential(_username, _password); Service service = new Service(_exchangeServerURI, credential); try { FindFolderResponse allCalendarFolders = service.FindFolder(StandardFolder.Calendar, FolderQueryTraversal.Deep); Folder rootCalendarFolder = service.GetFolder(StandardFolder.Calendar); allCalendarFolders.Folders.Add(rootCalendarFolder); IList <Independentsoft.Exchange.FolderId> calenderFoldersToBeSearched = new List <Independentsoft.Exchange.FolderId>(); string[] defaultCalendarSearchList = (System.Windows.Application.Current as App)._currentConfiguration.CalendarList; for (int i = 0; i < allCalendarFolders.Folders.Count; i++) { string folderName = allCalendarFolders.Folders[i].DisplayName; if (defaultCalendarSearchList == null || defaultCalendarSearchList.Contains(folderName)) { Trace.WriteLine($"Accepted FolderName: {allCalendarFolders.Folders[i].DisplayName}"); FolderId f = allCalendarFolders.Folders[i].FolderId; calenderFoldersToBeSearched.Add(f); } else { Trace.WriteLine($"Ignored FolderName: {allCalendarFolders.Folders[i].DisplayName}"); } } //wenn ich keine calendar folders habe, brauche ich gar nicht suchen. das ist sinnlos und würde //nur das web service mit einem Fehler aussteigen lassen if (calenderFoldersToBeSearched.Count == 0) { return(workReportItems); } IsGreaterThanOrEqualTo restrictionStartInterval = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.StartTime, _startInterval); IsLessThan restrictionEndInterval = new IsLessThan(AppointmentPropertyPath.StartTime, _endInterval); And restrictionInterval = new And(restrictionStartInterval, restrictionEndInterval); IList <FindItemResponse> responses = service.FindItem(calenderFoldersToBeSearched, AppointmentPropertyPath.AllPropertyPaths, restrictionInterval); foreach (FindItemResponse response in responses) { for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { if (_appointmentSelectPredicate(response.Items[i] as Appointment) == true) { WorkReportItemDTO wre = new WorkReportItemDTO(); Appointment appointment = (Appointment)response.Items[i]; wre.CustomerName = appointment.Subject; wre.StartTime = appointment.StartTime; wre.EndTime = appointment.EndTime; wre.WorkDescription = appointment.BodyPlainText; string s = appointment.BodyHtmlText; workReportItems.Add(wre); } } } } workReportItems.Sort(); } catch (Exception ex) { Trace.WriteLine(ex.Message); throw; } return(workReportItems); }
public ITag Build(XmlNode xmlNode) { ITag tag = null; var prepend = xmlNode.Attributes?["Prepend"]?.Value.Trim(); var property = xmlNode.Attributes?["Property"]?.Value.Trim(); var compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim(); #region Init Tag switch (xmlNode.Name) { case "#text": case "#cdata-section": { var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim(); return(new SqlText { BodyText = bodyText }); } case "Include": { var refId = xmlNode.Attributes?["RefId"]?.Value; var include_tag = new Include { RefId = refId, Prepend = prepend }; //includes.Add(include_tag); tag = include_tag; break; } case "IsEmpty": { tag = new IsEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsTrue": { tag = new IsTrue { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsFalse": { tag = new IsFalse { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsProperty": { tag = new IsProperty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Placeholder": { tag = new Placeholder { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Switch": { tag = new Switch { Property = property, Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Case": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, Test = xmlNode.Attributes?["Test"]?.Value.Trim(), ChildTags = new List <ITag>() }; break; } case "Bind": { tag = new BindTag { Name = xmlNode.Attributes["Name"]?.Value, Value = xmlNode.Attributes["Value"]?.Value, }; break; } case "Trim": { tag = new TrimTag { Prefix = xmlNode.Attributes["Prefix"]?.Value, PrefixOverrides = xmlNode.Attributes["PrefixOverrides"]?.Value, Suffix = xmlNode.Attributes["Suffix"]?.Value, ChildTags = new List <ITag>() }; break; } case "Default": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Defalut { Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Dynamic": { tag = new Dynamic { Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Where": { tag = new Where { ChildTags = new List <ITag>() }; break; } case "If": { var test = xmlNode.Attributes["Test"]?.Value; tag = new IfTag { Test = test }; } break; case "Set": { tag = new Set { ChildTags = new List <ITag>() }; break; } case "For": { var open = xmlNode.Attributes?["Open"]?.Value.Trim(); var separator = xmlNode.Attributes?["Separator"]?.Value.Trim(); var close = xmlNode.Attributes?["Close"]?.Value.Trim(); var key = xmlNode.Attributes?["Key"]?.Value.Trim(); tag = new For { Prepend = prepend, Property = property, Open = open, Close = close, Separator = separator, Key = key, ChildTags = new List <ITag>() }; break; } case "Env": { var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim(); tag = new Env { Prepend = prepend, DbProvider = dbProvider, ChildTags = new List <ITag>() }; break; } case "#comment": { break; } default: { throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}."); }; } #endregion return(tag); }
public static ITag LoadTag(XmlNode xmlNode, IList <Include> includes) { ITag tag = null; bool isIn = xmlNode.Attributes?["In"] != null; var prepend = xmlNode.Attributes?["Prepend"]?.Value.Trim(); var property = xmlNode.Attributes?["Property"]?.Value.Trim(); var compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim(); #region Init Tag switch (xmlNode.Name) { case "#text": case "#cdata-section": { var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim(); return(new SqlText { BodyText = bodyText }); } case "Include": { var refId = xmlNode.Attributes?["RefId"]?.Value; var include_tag = new Include { RefId = refId, Prepend = prepend }; includes.Add(include_tag); tag = include_tag; break; } case "IsEmpty": { tag = new IsEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsTrue": { tag = new IsTrue { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsFalse": { tag = new IsFalse { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsProperty": { tag = new IsProperty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Switch": { tag = new Switch { Property = property, //Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Case": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Default": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Defalut { Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Dynamic": { tag = new Dynamic { Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Where": { tag = new Where { ChildTags = new List <ITag>() }; break; } case "Set": { tag = new Set { ChildTags = new List <ITag>() }; break; } case "For": { var open = xmlNode.Attributes?["Open"]?.Value.Trim(); var separator = xmlNode.Attributes?["Separator"]?.Value.Trim(); var close = xmlNode.Attributes?["Close"]?.Value.Trim(); var key = xmlNode.Attributes?["Key"]?.Value.Trim(); tag = new For { Prepend = prepend, Property = property, Open = open, Close = close, Separator = separator, Key = key, ChildTags = new List <ITag>() }; break; } case "Env": { var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim(); tag = new Env { Prepend = prepend, DbProvider = dbProvider, ChildTags = new List <ITag>() }; break; } case "#comment": { break; } default: { throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}."); }; } #endregion foreach (XmlNode childNode in xmlNode) { ITag childTag = LoadTag(childNode, includes); if (childTag != null && tag != null) { (tag as Tag).ChildTags.Add(childTag); } } return(tag); }
public void Less_True() { IsLessThan.Value(2).Evaluate(1).Should().BeTrue(); }
private ITag LoadTag(XmlNode xmlNode, Statement statement) { ITag tag = null; var prepend = xmlNode.Attributes?["Prepend"]?.Value.Trim(); var property = xmlNode.Attributes?["Property"]?.Value.Trim(); var compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim(); #region Init Tag switch (xmlNode.Name) { case "#text": case "#cdata-section": { var innerText = xmlNode.InnerText; var bodyText = innerText; //bodyText += innerText.Trim().Replace("\r", " ").Replace("\n", " "); //bodyText += " "; return(new SqlText { Statement = statement, BodyText = bodyText }); } case "Include": { var refId = xmlNode.Attributes?["RefId"]?.Value; if (refId.IndexOf('.') < 0) { refId = $"{statement.SmartSqlMap.Scope}.{refId}"; } var include_tag = new Include { RefId = refId, Prepend = xmlNode.Attributes?["Prepend"]?.Value }; statement.IncludeDependencies.Add(include_tag); tag = include_tag; break; } case "IsEmpty": { tag = new IsEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsTrue": { tag = new IsTrue { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsFalse": { tag = new IsFalse { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsProperty": { tag = new IsProperty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Placeholder": { tag = new Placeholder { Prepend = xmlNode.Attributes?["Prepend"]?.Value, Property = property, ChildTags = new List <ITag>() }; break; } case "Switch": { tag = new Switch { Property = property, Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Case": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Default": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim(); var switchPrepend = switchNode.Attributes?["Prepend"]?.Value.Trim(); tag = new Switch.Defalut { Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Dynamic": { tag = new Dynamic { Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Where": { tag = new Where { ChildTags = new List <ITag>() }; break; } case "Set": { tag = new Set { ChildTags = new List <ITag>() }; break; } case "For": { var open = xmlNode.Attributes?["Open"]?.Value.Trim(); var separator = xmlNode.Attributes?["Separator"]?.Value.Trim(); var close = xmlNode.Attributes?["Close"]?.Value.Trim(); var key = xmlNode.Attributes?["Key"]?.Value.Trim(); tag = new For { Prepend = prepend, Property = property, Open = open, Close = close, Separator = separator, Key = key, ChildTags = new List <ITag>() }; break; } case "Env": { var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim(); tag = new Env { Prepend = prepend, DbProvider = dbProvider, ChildTags = new List <ITag>() }; break; } case "#comment": { return(null); } default: { throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}."); }; } tag.Statement = statement; #endregion foreach (XmlNode childNode in xmlNode) { ITag childTag = LoadTag(childNode, statement); if (childTag != null && tag != null) { childTag.Parent = tag; (tag as Tag).ChildTags.Add(childTag); } } return(tag); }
public static ITag LoadTag(XmlNode xmlNode) { ITag tag = null; bool isIn = xmlNode.Attributes?["In"] != null; var prepend = xmlNode.Attributes?["Prepend"]?.Value; var property = xmlNode.Attributes?["Property"]?.Value; var compareValue = xmlNode.Attributes?["CompareValue"]?.Value; #region Init Tag switch (xmlNode.Name) { case "#text": case "#cdata-section": { var bodyText = xmlNode.InnerText.Replace("\n", ""); return(new SqlText { BodyText = bodyText }); } case "IsEmpty": { tag = new IsEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsTrue": { tag = new IsTrue { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsFalse": { tag = new IsFalse { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Switch": { tag = new Switch { Property = property, //Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Case": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.Attributes?["Property"]?.Value; var switchPrepend = switchNode.Attributes?["Prepend"]?.Value; tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "#comment": { break; } default: { break; }; } #endregion foreach (XmlNode childNode in xmlNode) { ITag childTag = LoadTag(childNode); (tag as Tag).ChildTags.Add(childTag); } return(tag); }
public static ITag LoadTag(XmlNode xmlNode, IList <Include> includes) { ITag tag = null; bool isIn = !string.IsNullOrEmpty(xmlNode.GetValueInXmlAttributes("In")); var prepend = xmlNode.GetValueInXmlAttributes("Prepend"); var property = xmlNode.GetValueInXmlAttributes("Property"); var compareValue = xmlNode.GetValueInXmlAttributes("CompareValue"); #region Init Tag string lowerXmlNodeName = xmlNode.Name.ToLower(); switch (lowerXmlNodeName) { case "#text": case "#cdata-section": { var bodyText = " " + xmlNode.GetInnerTextInXmlAttributes(); return(new SqlText { BodyText = bodyText }); } //case "OrderBy": case "orderby": { var bodyText = " " + xmlNode.GetInnerTextInXmlAttributes(); tag = new OrderBy { ChildTags = new List <ITag>(), BodyText = bodyText }; break; } //case "Include": case "include": { var refId = xmlNode.GetValueInXmlAttributes("RefId"); var include_tag = new Include { RefId = refId }; includes.Add(include_tag); tag = include_tag; break; } //case "If": case "if": { var Test = xmlNode.GetValueInXmlAttributes("Test"); tag = new IfTag { Test = Test, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsEmpty": case "isempty": { tag = new IsEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsEqual": case "isequal": { tag = new IsEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsGreaterEqual": case "isgreaterequal": { tag = new IsGreaterEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsGreaterThan": case "isgreaterthan": { tag = new IsGreaterThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsLessEqual": case "islessequal": { tag = new IsLessEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsLessThan": case "islessthan": { tag = new IsLessThan { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsNotEmpty": case "isnotempty": { tag = new IsNotEmpty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsNotEqual": case "isnotequal": { tag = new IsNotEqual { In = isIn, Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } //case "IsNotNull": case "isnotnull": { tag = new IsNotNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsNull": case "isnull": { tag = new IsNull { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsTrue": case "istrue": { tag = new IsTrue { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsFalse": case "isfalse": { tag = new IsFalse { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "IsProperty": case "isproperty": { tag = new IsProperty { In = isIn, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "Switch": case "switch": { tag = new Switch { Property = property, //Prepend = prepend, ChildTags = new List <ITag>() }; break; } //case "Case": case "case": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.GetValueInXmlAttributes("Property"); var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend"); tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } //case "Default": case "default": { var switchNode = xmlNode.ParentNode; var switchProperty = switchNode.GetValueInXmlAttributes("Property"); var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend"); tag = new Switch.Defalut { Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } //case "Choose": case "choose": { tag = new ChooseTag { //Property = property, //Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "when": { var Test = xmlNode.GetValueInXmlAttributes("Test"); //var switchNode = xmlNode.ParentNode; //var switchProperty = switchNode.GetValueInXmlAttributes("Property"); //var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend"); tag = new ChooseTag.ChooseWhenTag { Test = Test, //Property = switchProperty, //Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "otherwise": { //var switchNode = xmlNode.ParentNode; //var switchProperty = switchNode.GetValueInXmlAttributes("Property"); //var switchPrepend = switchNode.GetValueInXmlAttributes("Prepend"); tag = new ChooseTag.ChooseOtherwiseTag { //Property = switchProperty, //Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "trim": { var Prefix = xmlNode.GetValueInXmlAttributes("Prefix", "", false); var Suffix = xmlNode.GetValueInXmlAttributes("Suffix", "", false); var PrefixOverrides = xmlNode.GetValueInXmlAttributes("PrefixOverrides"); var SuffixOverrides = xmlNode.GetValueInXmlAttributes("SuffixOverrides"); tag = new TrimTag { Prefix = Prefix, Suffix = Suffix, PrefixOverrides = PrefixOverrides, SuffixOverrides = SuffixOverrides, ChildTags = new List <ITag>() }; break; } case "set": { tag = new SetTag() { ChildTags = new List <ITag>() }; break; } case "where": { tag = new WhereTag { ChildTags = new List <ITag>() }; break; } //case "Where": //case "where": // { // tag = new Where // { // ChildTags = new List<ITag>() // }; // break; // } //case "Dynamic": case "dynamic": { tag = new Dynamic { Prepend = prepend, ChildTags = new List <ITag>() }; break; } //case "Variable": case "variable": { var bodyText = xmlNode.GetInnerTextInXmlAttributes(); tag = new Variable { BodyText = bodyText, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "Bind": case "bind": { var Name = xmlNode.GetValueInXmlAttributes("Name"); var Value = xmlNode.GetValueInXmlAttributes("Value"); //var bodyText = xmlNode.GetInnerTextInXmlAttributes(); tag = new BindTag { Name = Name, Value = Value, Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } //case "Foreach": case "foreach": { var open = xmlNode.GetValueInXmlAttributes("Open"); var separator = xmlNode.GetValueInXmlAttributes("Separator"); var close = xmlNode.GetValueInXmlAttributes("Close"); var item = xmlNode.GetValueInXmlAttributes("Item"); var index = xmlNode.GetValueInXmlAttributes("Index"); tag = new Foreach { Prepend = prepend, Property = property, Open = open, Close = close, Separator = separator, Item = item, Index = index, ChildTags = new List <ITag>() }; break; } //case "Env": case "env": { var dbProvider = xmlNode.GetValueInXmlAttributes("DbProvider"); var DbType = xmlNode.GetValueInXmlAttributes("DbType"); tag = new Env { Prepend = prepend, DbProvider = dbProvider, DbType = DbType, ChildTags = new List <ITag>() }; break; } case "#comment": { break; } default: { throw new Exception(string.Format("Statement.LoadTag unkonw tagName:{0}.", xmlNode.Name)); }; } #endregion //加载组合查询条件查询 foreach (XmlNode childNode in xmlNode) { ITag childTag = LoadTag(childNode, includes); if (childTag != null && tag != null) { (tag as Tag).ChildTags.Add(childTag); } } return(tag); }
private ITag LoadTag(XNode xmlNode, IList <Include> includes) { ITag tag = null; var prepend = xmlNode?.GetAttribute("Prepend")?.Trim(); var property = xmlNode?.GetAttribute("Property")?.Trim(); var compareValue = xmlNode?.GetAttribute("CompareValue")?.Trim(); #region Init Tag switch (xmlNode.GetName()) { case "#text": case "#cdata-section": { var bodyText = " " + xmlNode.GetValue().Replace("\n", "").Trim(); return(new SqlText { LineInfo = XmlLineInfo.Create(xmlNode), BodyText = bodyText }); } case "If": { tag = new IfTag { Test = xmlNode.GetAttribute("Test") }; break; } case "Include": { var refId = xmlNode?.GetAttribute("RefId"); var include_tag = new Include { RefId = refId, Prepend = prepend }; includes.Add(include_tag); tag = include_tag; break; } case "IsEmpty": { tag = new IsEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "Bind": { tag = new BindTag { Name = xmlNode.GetAttribute("Name"), Value = xmlNode.GetAttribute("Value"), }; break; } case "Trim": { tag = new TrimTag { Prefix = xmlNode.GetAttribute("Prefix"), PrefixOverrides = xmlNode.GetAttribute("PrefixOverrides"), Suffix = xmlNode.GetAttribute("Suffix"), ChildTags = new List <ITag>(), }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { Prepend = prepend, Property = property, CompareValue = compareValue, ChildTags = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsTrue": { tag = new IsTrue { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsFalse": { tag = new IsFalse { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "IsProperty": { tag = new IsProperty { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Placeholder": { tag = new Placeholder { Prepend = prepend, Property = property, ChildTags = new List <ITag>() }; break; } case "Switch": { tag = new Switch { Property = property, Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Case": { var switchNode = xmlNode.Parent; var switchProperty = xmlNode?.GetAttribute("Property")?.Trim(); var switchPrepend = xmlNode?.GetAttribute("Prepend")?.Trim(); tag = new Switch.Case { CompareValue = compareValue, Property = switchProperty, Prepend = switchPrepend, Test = xmlNode?.GetAttribute("Test")?.Trim(), ChildTags = new List <ITag>() }; break; } case "Default": { var switchNode = xmlNode.Parent; var switchProperty = xmlNode?.GetAttribute("Property")?.Trim(); var switchPrepend = xmlNode?.GetAttribute("Prepend")?.Trim(); tag = new Switch.Defalut { Property = switchProperty, Prepend = switchPrepend, ChildTags = new List <ITag>() }; break; } case "Dynamic": { tag = new Dynamic { Prepend = prepend, ChildTags = new List <ITag>() }; break; } case "Where": { tag = new Where { ChildTags = new List <ITag>() }; break; } case "Set": { tag = new Set { ChildTags = new List <ITag>() }; break; } case "For": { var open = xmlNode?.GetAttribute("Open")?.Trim(); var separator = xmlNode?.GetAttribute("Separator")?.Trim(); var close = xmlNode?.GetAttribute("Close")?.Trim(); var key = xmlNode?.GetAttribute("Key")?.Trim(); var index = xmlNode?.GetAttribute("Index")?.Trim(); tag = new For { Prepend = prepend, Property = property, Open = open, Close = close, Index = index, Separator = separator, Key = key, ChildTags = new List <ITag>() }; break; } case "Env": { var dbProvider = xmlNode?.GetAttribute("DbProvider")?.Trim(); tag = new Env { Prepend = prepend, DbProvider = dbProvider, ChildTags = new List <ITag>() }; break; } case "#comment": { break; } default: { throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.GetName()}."); }; } #endregion if (tag != null) { tag.LineInfo = XmlLineInfo.Create(xmlNode); } if (xmlNode is XElement ell) { foreach (XNode childNode in ell.Nodes()) { ITag childTag = LoadTag(childNode, includes); if (childTag != null && tag != null) { childTag.Parent = tag; (tag as Tag).ChildTags.Add(childTag); } } } return(tag); }
public void Equal_False() { IsLessThan.Value(1).Evaluate(1).Should().BeFalse(); }
public static ITag LoadTag(XNode node) { ITag tag = null; if (node.NodeType == System.Xml.XmlNodeType.Text || node.NodeType == System.Xml.XmlNodeType.CDATA) { tag = new SqlText { BodyText = node.ToString() }; } if (node.NodeType == System.Xml.XmlNodeType.Element) { XElement elenode = node as XElement; bool isIn = elenode.Attribute("In") != null; var prepend = elenode.Attribute("Prepend")?.Value.Trim(); var property = elenode.Attribute("Property")?.Value.Trim(); var compareValue = elenode.Attribute("CompareValue")?.Value.Trim(); var nodeName = elenode.Name.LocalName; switch (nodeName) { case "IsEmpty": { tag = new IsEmpty { Prepend = prepend, Property = property, Children = new List <ITag>() }; break; } case "IsEqual": { tag = new IsEqual { Prepend = prepend, Property = property, CompareValue = compareValue, Children = new List <ITag>() }; break; } case "IsNotEqual": { tag = new IsNotEqual { Prepend = prepend, CompareValue = compareValue, Property = property, Children = new List <ITag>() }; break; } case "IsGreaterEqual": { tag = new IsGreaterEqual { Prepend = prepend, Property = property, CompareValue = compareValue, }; break; } case "IsGreaterThan": { tag = new IsGreaterThan { Prepend = prepend, Property = property, CompareValue = compareValue, Children = new List <ITag>() }; break; } case "IsLessEqual": { tag = new IsLessEqual { Prepend = prepend, Property = property, CompareValue = compareValue, Children = new List <ITag>() }; break; } case "IsLessThan": { tag = new IsLessThan { Prepend = prepend, Property = property, CompareValue = compareValue, Children = new List <ITag>() }; break; } case "IsNotEmpty": { tag = new IsNotEmpty { Prepend = prepend, Property = property, Children = new List <ITag>() }; break; } case "IsNotNull": { tag = new IsNotNull { Prepend = prepend, Property = property, Children = new List <ITag>() }; break; } case "IsNull": { tag = new IsNull { Prepend = prepend, Property = property, Children = new List <ITag>() }; break; } case "Switch": { tag = new Switch { // Prepend = prepend, Property = property, Children = new List <ITag>() }; break; } case "Case": { var switchNode = node.Parent; var switchProperty = switchNode.Attribute("Property")?.Value.Trim(); var switchPrepend = switchNode.Attribute("Prepend")?.Value.Trim(); tag = new Switch.Case { Prepend = switchPrepend, Property = switchProperty, CompareValue = compareValue, Children = new List <ITag>() }; break; } case "Default": { var switchNode = node.Parent; var switchProperty = switchNode.Attribute("Property")?.Value.Trim(); var switchPrepend = switchNode.Attribute("Prepend")?.Value.Trim(); tag = new Switch.Default { Prepend = switchPrepend, Property = switchProperty, Children = new List <ITag>() }; break; } case "Where": { tag = new Where { Children = new List <ITag>() }; break; } case "Dynamic": { tag = new Dynamic { Prepend = prepend, Children = new List <ITag>() }; break; } case "IsProperty": { tag = new IsProperty { Prepend = prepend, Children = new List <ITag>(), Property = property }; break; } default: { throw new BaraException($"Statement can't load TagName:{nodeName}"); } } foreach (var childNode in elenode.Nodes()) { ITag childTag = LoadTag(childNode); if (childTag != null && tag != null) { (tag as Tag).Children.Add(childTag); } } } return(tag); }
private static ConditionResult VerifyCondition(List <object> objects, IsLessThan cond) { return(ConvertToValueConditionAndVerify(objects, cond)); }
public void Greater_False() { IsLessThan.Value(1).Evaluate(2).Should().BeFalse(); }