Long live Operathor
This commit is contained in:
@@ -18,26 +18,26 @@ namespace Umbraco.Web.Editors
|
||||
[JsonCamelCaseFormatter]
|
||||
public class TemplateQueryController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
private IEnumerable<OperathorTerm> Terms
|
||||
private IEnumerable<OperatorTerm> Terms
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<OperathorTerm>()
|
||||
return new List<OperatorTerm>()
|
||||
{
|
||||
new OperathorTerm(Services.TextService.Localize("template/is"), Operathor.Equals, new [] {"string"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/isNot"), Operathor.NotEquals, new [] {"string"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/before"), Operathor.LessThan, new [] {"datetime"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/beforeIncDate"), Operathor.LessThanEqualTo, new [] {"datetime"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/after"), Operathor.GreaterThan, new [] {"datetime"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/afterIncDate"), Operathor.GreaterThanEqualTo, new [] {"datetime"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/equals"), Operathor.Equals, new [] {"int"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/doesNotEqual"), Operathor.NotEquals, new [] {"int"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/contains"), Operathor.Contains, new [] {"string"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/doesNotContain"), Operathor.NotContains, new [] {"string"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/greaterThan"), Operathor.GreaterThan, new [] {"int"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/greaterThanEqual"), Operathor.GreaterThanEqualTo, new [] {"int"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/lessThan"), Operathor.LessThan, new [] {"int"}),
|
||||
new OperathorTerm(Services.TextService.Localize("template/lessThanEqual"), Operathor.LessThanEqualTo, new [] {"int"})
|
||||
new OperatorTerm(Services.TextService.Localize("template/is"), Operator.Equals, new [] {"string"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/isNot"), Operator.NotEquals, new [] {"string"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/before"), Operator.LessThan, new [] {"datetime"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/beforeIncDate"), Operator.LessThanEqualTo, new [] {"datetime"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/after"), Operator.GreaterThan, new [] {"datetime"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/afterIncDate"), Operator.GreaterThanEqualTo, new [] {"datetime"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/equals"), Operator.Equals, new [] {"int"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/doesNotEqual"), Operator.NotEquals, new [] {"int"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/contains"), Operator.Contains, new [] {"string"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/doesNotContain"), Operator.NotContains, new [] {"string"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/greaterThan"), Operator.GreaterThan, new [] {"int"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/greaterThanEqual"), Operator.GreaterThanEqualTo, new [] {"int"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/lessThan"), Operator.LessThan, new [] {"int"}),
|
||||
new OperatorTerm(Services.TextService.Localize("template/lessThanEqual"), Operator.LessThanEqualTo, new [] {"int"})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public enum Operathor
|
||||
public enum Operator
|
||||
{
|
||||
Equals = 1,
|
||||
NotEquals = 2,
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class OperathorTerm
|
||||
public class OperatorTerm
|
||||
{
|
||||
public OperathorTerm()
|
||||
public OperatorTerm()
|
||||
{
|
||||
Name = "is";
|
||||
Operathor = Operathor.Equals;
|
||||
Operator = Operator.Equals;
|
||||
AppliesTo = new [] { "string" };
|
||||
}
|
||||
|
||||
public OperathorTerm(string name, Operathor operathor, IEnumerable<string> appliesTo)
|
||||
public OperatorTerm(string name, Operator @operator, IEnumerable<string> appliesTo)
|
||||
{
|
||||
Name = name;
|
||||
Operathor = operathor;
|
||||
Operator = @operator;
|
||||
AppliesTo = appliesTo;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public Operathor Operathor { get; set; }
|
||||
public Operator Operator { get; set; }
|
||||
public IEnumerable<string> AppliesTo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
|
||||
public PropertyModel Property { get; set; }
|
||||
public OperathorTerm Term { get; set; }
|
||||
public OperatorTerm Term { get; set; }
|
||||
public string ConstraintValue { get; set; }
|
||||
}
|
||||
|
||||
@@ -53,30 +53,30 @@
|
||||
|
||||
}
|
||||
|
||||
switch (condition.Term.Operathor)
|
||||
switch (condition.Term.Operator)
|
||||
{
|
||||
case Operathor.Equals:
|
||||
case Operator.Equals:
|
||||
operand = " == ";
|
||||
break;
|
||||
case Operathor.NotEquals:
|
||||
case Operator.NotEquals:
|
||||
operand = " != ";
|
||||
break;
|
||||
case Operathor.GreaterThan:
|
||||
case Operator.GreaterThan:
|
||||
operand = " > ";
|
||||
break;
|
||||
case Operathor.GreaterThanEqualTo:
|
||||
case Operator.GreaterThanEqualTo:
|
||||
operand = " >= ";
|
||||
break;
|
||||
case Operathor.LessThan:
|
||||
case Operator.LessThan:
|
||||
operand = " < ";
|
||||
break;
|
||||
case Operathor.LessThanEqualTo:
|
||||
case Operator.LessThanEqualTo:
|
||||
operand = " <= ";
|
||||
break;
|
||||
case Operathor.Contains:
|
||||
case Operator.Contains:
|
||||
value = string.Format("{0}{1}.Contains({2})", prefix, condition.Property.Alias, constraintValue);
|
||||
break;
|
||||
case Operathor.NotContains:
|
||||
case Operator.NotContains:
|
||||
value = string.Format("!{0}{1}.Contains({2})", prefix, condition.Property.Alias, constraintValue);
|
||||
break;
|
||||
default :
|
||||
|
||||
@@ -685,8 +685,8 @@
|
||||
<Compile Include="Models\TemplateQuery\SourceModel.cs" />
|
||||
<Compile Include="Models\TemplateQuery\TemplateQueryResult.cs" />
|
||||
<Compile Include="Models\TemplateQuery\SortExpression.cs" />
|
||||
<Compile Include="Models\TemplateQuery\Operathor.cs" />
|
||||
<Compile Include="Models\TemplateQuery\OperathorTerm.cs" />
|
||||
<Compile Include="Models\TemplateQuery\Operator.cs" />
|
||||
<Compile Include="Models\TemplateQuery\OperatorTerm.cs" />
|
||||
<Compile Include="Models\TemplateQuery\QueryCondition.cs" />
|
||||
<Compile Include="Models\TemplateQuery\QueryModel.cs" />
|
||||
<Compile Include="Models\TemplateQuery\QueryResultModel.cs" />
|
||||
|
||||
Reference in New Issue
Block a user