Exemplo n.º 1
0
 public EntityPropertyInfo(
     string name,
     Type type,
     FacetInfo facets,
     List <IndexInfo> indexes)
 {
     this.name    = name;
     this.type    = type;
     this.facets  = facets;
     this.indexes = indexes.ToList().AsReadOnly();
 }
Exemplo n.º 2
0
		public TypeInfo(InfoBinderInterface binder, int namespaceIndex, string localName, int baseTypeIndex, int memberBegin,
					 int memberEnd, FacetInfo[] facets, WhitespaceType whitespace)
		{
			this.namespaceIndex = namespaceIndex;
			this.localName = localName;
			this.baseTypeIndex = baseTypeIndex;
			this.memberBegin = memberBegin;
			this.memberEnd = memberEnd;
			this.facets = facets;
			this.whitespace = whitespace;
			this.binder = binder;
			this.formatter = null;
		}
Exemplo n.º 3
0
 public static Facet <bool> Required(bool value)
 => FacetInfo.Create(CommonFacetNames.Required, value);
Exemplo n.º 4
0
 public static Facet <T> Max <T>(T value)
 => FacetInfo.Create(CommonFacetNames.Max, value);
Exemplo n.º 5
0
 public static Facet <T> MinLength <T>(T value)
 => FacetInfo.Create(CommonFacetNames.MinLength, value);
Exemplo n.º 6
0
 public IFacet <V> FindOrElse <V>(string Name, V Else, bool AllowConversion)
 => TryFind <V>(Name, AllowConversion).ValueOrElse(() => FacetInfo.Create(Name, Else));
Exemplo n.º 7
0
 static FacetCheckResult Check(string value, FacetInfo facet, WhitespaceType whitespaceNormalization)
 {
     return(FacetCheckResult.Fail);
 }
Exemplo n.º 8
0
 static int GetFacetIntFallback(FacetInfo[] facets, string facetName, string fallbackName, int defaultValue)
 {
     if (facets == null)
         return defaultValue;
     int value = defaultValue;
     foreach (FacetInfo facet in facets)
     {
         if (facet.facetName == facetName)
             return facet.intValue;
         if (fallbackName != null && facet.facetName == fallbackName)
             value = facet.intValue;
     }
     return value;
 }
Exemplo n.º 9
0
 public static Facet <string> Pattern(string value)
 => FacetInfo.Create(CommonFacetNames.Pattern, value);
Exemplo n.º 10
0
 public void Init()
 {
     instance = new FacetInfo();
 }
Exemplo n.º 11
0
			public static FacetCheckResult Check(string value, FacetInfo facet, WhitespaceType whitespaceNormalization)
			{
				if (LengthFacetCheckHelper.ComputeLength(value, whitespaceNormalization) <= facet.intValue * 2)
					return FacetCheckResult.Success;
				return FacetCheckResult.Fail;
			}
Exemplo n.º 12
0
			public static FacetCheckResult Check (string value, FacetInfo facet, WhitespaceType whitespaceNormalization)
			{
				if (LengthFacetCheckHelper.IsEqual(value, facet.stringValue, whitespaceNormalization))
					return FacetCheckResult.EnumSuccess;
				return FacetCheckResult.EnumFail;
			}
Exemplo n.º 13
0
			public static FacetCheckResult Check(string s, FacetInfo facet, WhitespaceType whitespace)
			{
				return FacetCheckResult.Success;
			}
Exemplo n.º 14
0
 string[] GetAllFacets(FacetInfo[] facets, string name)
 {
     System.Collections.ArrayList result = new System.Collections.ArrayList();
     if (facets != null)
     {
         foreach (FacetInfo facet in facets)
         {
             if (facet.facetName == name)
                 result.Add(facet.stringValue);
         }
     }
     if (result.Count > 0)
         return (string[]) result.ToArray(typeof(string));
     return null;
 }
Exemplo n.º 15
0
 static string GetFacetString(FacetInfo[] facets, string facetName)
 {
     if (facets == null)
         return null;
     foreach (FacetInfo facet in facets)
     {
         if (facet.facetName == facetName)
             return facet.stringValue;
     }
     return null;
 }
Exemplo n.º 16
0
 public static Facet <T> Precision <T>(T value)
 => FacetInfo.Create(CommonFacetNames.Precision, value);
Exemplo n.º 17
0
 public static Facet <T> Scale <T>(T value)
 => FacetInfo.Create(CommonFacetNames.Scale, value);
Exemplo n.º 18
0
        /// <summary>
        /// Gets an expression for a facet.
        /// </summary>
        /// <param name="parameterExpression">The parameter expression.</param>
        /// <param name="facet">The facet.</param>
        /// <returns></returns>
        protected virtual Expression GetFacetExpression(ParameterExpression parameterExpression, FacetInfo facet)
        {
            string fieldName = this.DtoFieldNameToEntityFieldName(facet.Name);

            string[]         tokens = fieldName.Split('.');
            MemberExpression member = Expression.Property(parameterExpression, tokens[0]);

            for (int i = 1; i < tokens.Length; i++)
            {
                member = Expression.Property(member, tokens[i]);
            }
            Expression firstExpression = this.GetValueExpression(member, facet.Values[0]);

            for (int i = 1; i < facet.Values.Count; i++)
            {
                Expression currentExpression = this.GetValueExpression(member, facet.Values[i]);
                firstExpression = Expression.Or(firstExpression, currentExpression);
            }
            return(firstExpression);
        }
Exemplo n.º 19
0
 static FacetCheckResult Check(string value, FacetInfo facet, WhitespaceType whitespaceNormalization)
 {
     return FacetCheckResult.Fail;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Adds a new facet value.
 /// </summary>
 /// <param name="facetName">Name of the facet.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public QueryInfo Where(string facetName, FacetOperation operation, string value)
 {
     FacetInfo facet = this.GetFacetInfo(facetName);
     if (facet == null)
     {
         facet = new FacetInfo(facetName);
         this.Facets.Add(facet);
     }
     facet.Values.Add(new FacetValueInfo(operation, value));
     return this;
 }