Esempio n. 1
0
 void WriteDefaultDouble(GeometryToken geometryToken, double val, double defaultValue)
 {
     if (val != defaultValue)
     {
         WriteAttribute(geometryToken, DoubleToString(val));
     }
 }
Esempio n. 2
0
        static internal string FirstCharToLower(GeometryToken attrKind)
        {
            var attrString = attrKind.ToString();

            attrString = attrString.Substring(0, 1).ToLowerInvariant() + attrString.Substring(1, attrString.Length - 1);
            return(attrString);
        }
Esempio n. 3
0
 void WriteBorderInfo(GeometryToken token, BorderInfo borderInfo)
 {
     WriteStartElement(token);
     WriteAttribute(GeometryToken.InnerMargin, borderInfo.InnerMargin);
     WriteAttribute(GeometryToken.FixedPosition, borderInfo.FixedPosition);
     WriteAttribute(GeometryToken.Weight, borderInfo.Weight);
     WriteEndElement();
 }
Esempio n. 4
0
        void WriteAttribute(GeometryToken attrKind, object val)
        {
            var attrString = FirstCharToLower(attrKind);

            if (val is Point)
            {
                XmlWriter.WriteAttributeString(attrString, PointToString((Point)val));
            }
            else if (val is Double)
            {
                XmlWriter.WriteAttributeString(attrString, DoubleToString((double)val));
            }
            else
            {
                XmlWriter.WriteAttributeString(attrString, val.ToString());
            }
        }
Esempio n. 5
0
        //static  void WriteStartElement(XmlWriter writer, Tokens token) {
        //    writer.WriteStartElement(token.ToString());
        //}

        /// <summary>
        /// WriteStringElement with double
        /// </summary>
        /// <param name="tokens"></param>
        /// <param name="element"></param>
        void WriteStringElement(GeometryToken tokens, double element)
        {
            XmlWriter.WriteElementString(tokens.ToString(), XmlConvert.ToString(element));
        }
Esempio n. 6
0
 /// <summary>
 /// writes the starte element with the token
 /// </summary>
 /// <param name="token"></param>
 void WriteStartElement(GeometryToken token)
 {
     XmlWriter.WriteStartElement(FirstCharToLower(token));
 }
Esempio n. 7
0
 private void WritePointElement(GeometryToken siteV, Point point)
 {
     //XmlWriter.WriteAttributeString("pt",point.X.ToString() +","+point.Y.ToString());
     XmlWriter.WriteElementString("pt", PointToString(point));
 }
 bool TryGetAttribute(GeometryToken token, out string val) {
     return (val = GetAttribute(token)) != null;
 }
 /// <summary>
 /// writes the starte element with the token
 /// </summary>
 /// <param name="token"></param>
 void WriteStartElement(GeometryToken token) {
     XmlWriter.WriteStartElement( FirstCharToLower( token));
 }
 void WriteAttribute(GeometryToken attrKind, object val) {
     var attrString = FirstCharToLower(attrKind);
     if (val is Point)
         XmlWriter.WriteAttributeString(attrString, PointToString((Point) val));
     else if (val is Double)
         XmlWriter.WriteAttributeString(attrString, DoubleToString((double) val));
     else
         XmlWriter.WriteAttributeString(attrString, val.ToString());
 }
 double GetDoubleAttribute(GeometryToken token) {
     var val = GetAttribute(token);
     if (val == null)
         Error(String.Format("attribute {0} not found", token));
     double ret;
     if (double.TryParse(val, out ret))
         return ret;
     Error("cannot parse an int value " + val);
     return 0;
 }
 bool TokenIs(GeometryToken t) {
     return XmlReader.IsStartElement(GeometryGraphWriter.FirstCharToLower(t)) ||
            XmlReader.IsStartElement(t.ToString());
 }
 Point TryGetPointAttribute(GeometryToken token) {
     string val = GetAttribute(token);
     return val == null ? new Point() : ParsePoint(val);
 }
 int GetIntAttributeOrDefault(GeometryToken token, int defaultVal) {
     string val = GetAttribute(token);
     if (val == null)
         return defaultVal;
     int ret;
     if (int.TryParse(val, out ret))
         return ret;
     Error("cannot parse a bool value " + val);
     return 0;
 }
 bool GetBoolAttributeOrDefault(GeometryToken token, bool defaultVal) {
     string val = GetAttribute(token);
     if (val == null)
         return defaultVal;
     bool ret;
     if (bool.TryParse(val, out ret))
         return ret;
     Error("cannot parse a bool value " + val);
     return false;
 }
 double GetDoubleAttributeOrDefault(GeometryToken token, double defaultVal) {
     string val = GetAttribute(token);
     if (val == null)
         return defaultVal;
     double ret;
     if (double.TryParse(val, out ret))
         return ret;
     Error("cannot parse a double value " + val);
     return 0;
 }
 void WriteBorderInfo(GeometryToken token, BorderInfo borderInfo) {
     WriteStartElement(token);
     WriteAttribute(GeometryToken.InnerMargin, borderInfo.InnerMargin);
     WriteAttribute(GeometryToken.FixedPosition, borderInfo.FixedPosition);
     WriteAttribute(GeometryToken.Weight, borderInfo.Weight);
     WriteEndElement();
 }
 ///<summary>
 ///used only in Debug configuration
 ///<param name="token">the token that should be here</param>
 ///</summary>
 void CheckToken(GeometryToken token) {
     if (!XmlReader.IsStartElement(GeometryGraphWriter.FirstCharToLower(token)) &&
         !XmlReader.IsStartElement(token.ToString())) {
         string positionInfo = GetPositionInfo();
         throw new InvalidDataException(
             String.Format(CultureInfo.InvariantCulture,
                 "expected {0}, {1}", token, positionInfo));
     }
 }
 string GetMustAttribute(GeometryToken token) {
     var s = GeometryGraphWriter.FirstCharToLower(token);
     var ret = XmlReader.GetAttribute(GeometryGraphWriter.FirstCharToLower(token));
     if (ret != null)
         return ret;
     Error("attribute " + s + " not found");
     return null;
 }
 bool ReadBooleanElement(GeometryToken tokens) {
     CheckToken(tokens);
     return ReadElementContentAsBoolean();
 }
 int ReadIntElement(GeometryToken token) {
     CheckToken(token);
     return ReadElementContentAsInt();
 }
 void WriteDefaultDouble(GeometryToken geometryToken, double val, double defaultValue) {
     if (val != defaultValue)
         WriteAttribute(geometryToken, DoubleToString(val));
 }
 BorderInfo ReadBorderInfo(GeometryToken token) {
     XmlRead();
     CheckToken(token);
     var bi = new BorderInfo {
         InnerMargin = GetDoubleAttribute(GeometryToken.InnerMargin),
         FixedPosition = GetDoubleAttribute(GeometryToken.FixedPosition),
         Weight = GetDoubleAttribute(GeometryToken.Weight)
     };
     return bi;
 }
 static internal string FirstCharToLower(GeometryToken attrKind) {
     var attrString =  attrKind.ToString();
     attrString = attrString.Substring(0, 1).ToLower(CultureInfo.InvariantCulture) + attrString.Substring(1, attrString.Length - 1);
     return attrString;
 }
Esempio n. 25
0
 void WriteStringElement(GeometryToken tokens, bool b)
 {
     XmlWriter.WriteElementString(tokens.ToString(), XmlConvert.ToString(b));
 }
        //static  void WriteStartElement(XmlWriter writer, Tokens token) {
        //    writer.WriteStartElement(token.ToString());
        //}

        /// <summary>
        /// WriteStringElement with double
        /// </summary>
        /// <param name="tokens"></param>
        /// <param name="element"></param>
        void WriteStringElement(GeometryToken tokens, double element) {
            XmlWriter.WriteElementString(tokens.ToString(), XmlConvert.ToString(element));
        }
 string GetAttribute(GeometryToken token) {
     return XmlReader.GetAttribute(GeometryGraphWriter.FirstCharToLower(token));
 }