///////////////////////////////////////////////////////////////////////
        /// <summary>Generates the Google Base specific parameters</summary>
        ///////////////////////////////////////////////////////////////////////
        protected override string CalculateQuery(string basePath)
        {
            string        path           = base.CalculateQuery(basePath);
            StringBuilder newPath        = new StringBuilder(path, 2048);
            char          paramInsertion = InsertionParameter(path);

            if (this.bq != null)
            {
                newPath.Append(paramInsertion);
                newPath.Append(BqParameter);
                newPath.Append('=');
                newPath.Append(Utilities.UriEncodeReserved(bq));
                paramInsertion = '&';
            }
            if (this.maxValues >= 0)
            {
                newPath.Append(paramInsertion);
                newPath.Append(MaxValuesParameter);
                newPath.Append('=');
                newPath.Append(NumberFormat.ToString(maxValues));
                paramInsertion = '&';
            }
            if (this.orderby != null)
            {
                newPath.Append(paramInsertion);
                newPath.Append(OrderByParameter);
                newPath.Append('=');
                newPath.Append(Utilities.UriEncodeReserved(orderby));
                paramInsertion = '&';
            }
            if (this.ascending)
            {
                newPath.Append(paramInsertion);
                newPath.Append(SortOrderParameter);
                newPath.Append("=ascending");
                paramInsertion = '&';
            }
            if (this.refine)
            {
                newPath.Append(paramInsertion);
                newPath.Append(RefineParameter);
                newPath.Append("=true");
                paramInsertion = '&';
            }
            if (this.content != null)
            {
                newPath.Append(paramInsertion);
                newPath.Append(ContentParameter);
                newPath.Append('=');
                newPath.Append(Utilities.UriEncodeReserved(content));
                paramInsertion = '&';
            }
            return(newPath.ToString());
        }
        //////////////////////////////////////////////////////////////////////
        /// <summary>Creates a GBaseAttribute of type location corresponding
        /// to the current object.</summary>
        /// <param name="name">attribute name</param>
        //////////////////////////////////////////////////////////////////////
        public GBaseAttribute CreateGBaseAttribute(string name)
        {
            GBaseAttribute retval = new GBaseAttribute(name, GBaseAttributeType.Location);

            retval.Content = address;
            if (hasCoordinates)
            {
                retval["latitude"]  = NumberFormat.ToString(latitude);
                retval["longitude"] = NumberFormat.ToString(longitude);
            }
            return(retval);
        }
        //////////////////////////////////////////////////////////////////////
        /// <summary>Creates a GBaseAttribute of type shipping corresponding
        /// to the current object.</summary>
        /// <param name="name">attribute name</param>
        //////////////////////////////////////////////////////////////////////
        public GBaseAttribute CreateGBaseAttribute(string name)
        {
            GBaseAttribute retval = new GBaseAttribute(name, GBaseAttributeType.Shipping);

            retval["country"] = country;
            retval["service"] = service;
            if (currency != null)
            {
                retval["price"] = price + " " + currency;
            }
            else
            {
                retval["price"] = NumberFormat.ToString(price);
            }
            return(retval);
        }
Ejemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>Generates XML code for the current tag.</summary>
        ///////////////////////////////////////////////////////////////////////
        public void Save(XmlWriter writer)
        {
            writer.WriteStartElement(XmlPrefix,
                                     "attribute",
                                     XmlNameSpace);
            writer.WriteAttributeString("name", name);
            writer.WriteAttributeString("type", type.Name);
            writer.WriteAttributeString("count", NumberFormat.ToString(count));

            foreach (HistogramValue value in values)
            {
                writer.WriteStartElement(GBaseNameTable.GBaseMetaPrefix,
                                         "value",
                                         GBaseNameTable.NSGBaseMeta);
                writer.WriteAttributeString("count", NumberFormat.ToString(value.Count));
                writer.WriteString(value.Content);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Ejemplo n.º 5
0
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Generates an XML representation for this object.</summary>
 ///////////////////////////////////////////////////////////////////////
 public void Save(string tagName, XmlWriter writer)
 {
     if (total > 0)
     {
         writer.WriteStartElement(GBaseNameTable.GBaseMetaPrefix, tagName, GBaseNameTable.NSGBaseMeta);
         writer.WriteAttributeString("total", NumberFormat.ToString(total));
         if (sourceCount != null)
         {
             foreach (string source in sourceCount.Keys)
             {
                 int count = (int)sourceCount[source];
                 writer.WriteStartElement(GBaseNameTable.GBaseMetaPrefix,
                                          "source",
                                          GBaseNameTable.NSGBaseMeta);
                 writer.WriteAttributeString("name", source);
                 writer.WriteAttributeString("count", NumberFormat.ToString(count));
                 writer.WriteEndElement();
             }
         }
         writer.WriteEndElement();
     }
 }
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Adds a new attribute of type number.</summary>
 /// <param name="name">attribute name</param>
 /// <param name="value">value</param>
 /// <returns>the newly-created GBaseAttribute object</returns>
 ///////////////////////////////////////////////////////////////////////
 public GBaseAttribute AddNumberAttribute(string name, int value)
 {
     return(Add(new GBaseAttribute(name,
                                   GBaseAttributeType.Number,
                                   NumberFormat.ToString(value))));
 }
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Adds a new attribute of type float.</summary>
 /// <param name="name">attribute name</param>
 /// <param name="value">value</param>
 /// <returns>the newly-created GBaseAttribute object</returns>
 ///////////////////////////////////////////////////////////////////////
 public GBaseAttribute AddFloatAttribute(string name, float value)
 {
     return(Add(new GBaseAttribute(name,
                                   GBaseAttributeType.Float,
                                   NumberFormat.ToString(value))));
 }
Ejemplo n.º 8
0
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Returns a string representation for the FloatUnit that
 /// can be used to re-created another FloatUnit.</summary>
 ///////////////////////////////////////////////////////////////////////
 public override string ToString()
 {
     return(NumberFormat.ToString(number) + " " + Unit);
 }