Ejemplo n.º 1
0
        //Data

        //Constructor
        public ScanExpression(ExpNode input)
            : base(input)
        {
            _type = input.Type;
        }
Ejemplo n.º 2
0
 //Constructor
 public PredicateExpression(QueryNode input, ExpNode predicate)
     : base(input)
 {
     _predicate = predicate;
     _type      = input.Type;
 }
Ejemplo n.º 3
0
 //Constructor
 internal CastExpression(ExpNode target, NodeType targetType)
     : base(target)
 {
     TargetType = targetType;
 }
Ejemplo n.º 4
0
 //Constructor
 internal IsOfExpression(ExpNode target, NodeType targetType)
     : base(null)
 {
     Target     = target;
     TargetType = targetType;
 }
Ejemplo n.º 5
0
 public VariableExpression(Node node, NodeType type)
     : base(null)
 {
     _type     = type;
     _variable = node;
 }
Ejemplo n.º 6
0
        public static string ConstructEquivalentETag(ResourceType type, string ETag)
        {
            string[]            pieces         = SplitETag(ETag);
            List <NodeProperty> etagProperties = type.Properties.Where(p => p.Facets.ConcurrencyModeFixed).ToList();

            for (int i = 0; i < pieces.Length; i++)
            {
                string piece = pieces[i];
                if (piece == Null)
                {
                    continue;
                }

                NodeProperty property     = etagProperties[i];
                NodeType     propertyType = etagProperties[i].Type;
                if (propertyType == Clr.Types.String && property.Facets.FixedLength)
                {
                    piece = piece.Trim('\'');
                    if (piece.Length < property.Facets.MaxSize)
                    {
                        piece = piece + " ";
                    }
                    else if (piece.EndsWith(" "))
                    {
                        piece = piece.Remove(piece.Length - 1);
                    }
                    piece = "'" + piece + "'";
                }
                else if (propertyType.IsNumeric)
                {
                    if (piece.Contains("INF") || piece.Contains("NaN"))
                    {
                        continue;
                    }
                    else if (piece.ToLower().Contains("e")) //must be a floating point
                    {
                        // add 0's and flip capitalization
                        piece = piece.Replace("E%2b", "0e%2B0");
                        piece = piece.Replace("e%2b", "0E%2B0");
                        piece = piece.Replace("E%2B", "0e%2b0");
                        piece = piece.Replace("e%2B", "0E%2b0");
                        piece = piece.Replace("E+", "0e+0");
                        piece = piece.Replace("e+", "0E+0");
                    }
                    else if (propertyType.ClrType == typeof(double) && !(piece.EndsWith("D") || piece.EndsWith("d")))
                    {
                        if (!piece.Contains('.'))
                        {
                            piece = piece + ".0";
                        }
                        else
                        {
                            piece = piece + "0";
                        }

                        piece = piece + "E+0";
                    }
                    else if (propertyType.ClrType == typeof(float) || propertyType.ClrType == typeof(Single) || propertyType.ClrType == typeof(double))
                    {
                        if (!piece.Contains('.'))
                        {
                            piece = piece.Insert(piece.Length - 1, ".0"); //just before the 'f' or 'D'
                        }
                        else
                        {
                            piece = piece.Insert(piece.Length - 1, "0"); //just before the 'f' or 'D'
                        }
                        piece = piece.Insert(piece.Length - 1, "E+0");
                    }
                    else if (propertyType.ClrType == typeof(decimal))
                    {
                        if (!piece.Contains('.'))
                        {
                            piece = piece.Insert(piece.Length - 1, ".0"); //just before the 'M'
                        }
                        else
                        {
                            piece = piece.Insert(piece.Length - 1, "0"); //just before the 'M'
                        }
                    }

                    if (piece.StartsWith("-"))
                    {
                        piece = piece.Insert(1, "0");
                    }
                    else
                    {
                        piece = "0" + piece;
                    }
                }

                pieces[i] = piece;
            }

            return(ConstructETag(pieces));
        }
Ejemplo n.º 7
0
        public virtual void InferAssociations()
        {
            //Pull off any assoications bound to the properties
            foreach (ResourceProperty p in this.Properties)
            {
                //Skip associations on properties on basetypes, we don't need duplicate associations

                /*if(this.BaseType!=null)
                 * {
                 *  int basePropertyCount = this.BaseType.Properties.OfType<ResourceProperty>().Where(baseProp => baseProp.Name.Equals(p.Name)).Count();
                 *  if (basePropertyCount > 0)
                 *      continue;
                 * }*/
                ResourceAssociation[]    associations    = p._other.OfType <ResourceAssociation>().ToArray();
                ResourceAssociationEnd[] associationEnds = p._other.OfType <ResourceAssociationEnd>().ToArray();
                ResourceAssociationEnd   fromEnd         = null;
                ResourceAssociationEnd   toEnd           = null;

                if (associationEnds.Count() == 2)
                {
                    fromEnd = associationEnds[0];
                    toEnd   = associationEnds[1];
                }

                NodeType subtype = p.Type is CollectionType ? ((CollectionType)p.Type).SubType : p.Type;

                if (associations.Length == 0 && subtype is ResourceType)
                {
                    //Inferred Association (ie: Navigation property), with no mappings
                    //To specify mappings, explicitly use an association
                    this.Relations.Add(
                        Resource.Association(this.Name + p.Name, //AssociationName
                                             Resource.End(this.Name, this, this.Facets.Nullable ? Multiplicity.Zero : Multiplicity.One),
                                             Resource.End(p.Name, (ResourceType)subtype, p.Type is CollectionType ? Multiplicity.Many : (p.Facets.Nullable ? Multiplicity.Zero : Multiplicity.One))
                                             )
                        );
                }
                else
                {
                    //Updated specfied with Associations, with any missing data
                    foreach (ResourceAssociation a in associations)
                    {
                        //Name (ie: Default)
                        if (a.Name == null)
                        {
                            a.Name = this.Name + p.Name;
                        }

                        //End1
                        ResourceAssociationEnd e1 = a.Source;
                        e1.ResourceType = e1.ResourceType ?? this;
                        e1.Name         = e1.Name ?? this.Name;
                        e1.Multiplicity = e1.Multiplicity ?? (this.Facets.Nullable ? Multiplicity.Zero : Multiplicity.One);


                        //End2
                        ResourceAssociationEnd e2 = a.Target;
                        e2.ResourceType = e2.ResourceType ?? (ResourceType)subtype;
                        e2.Name         = e2.Name ?? p.Name;
                        e2.Multiplicity = e2.Multiplicity ?? (p.Type is CollectionType ? Multiplicity.Many : (p.Facets.Nullable ? Multiplicity.Zero : Multiplicity.One));

                        this.Relations.Add(a);
                    }
                }
                if (fromEnd != null && toEnd != null)
                {
                    p.SetFromAndToAssociationEnds(fromEnd, toEnd);
                }
            }
        }