Example #1
0
        private static string _AddTypeHints(string json, List <string> types)
        {
            Debug.Assert(json != null);
            Debug.Assert(types != null);

            string res = json;

            Regex regex     = new Regex(RPAT_OBJECT_VALUE);
            int   jsonIndex = 0;

            foreach (var jsonType in types)
            {
                var type = GPObjectHelper.GetTypeByJsonName(jsonType);
                if (type == null)
                {
                    continue;
                }

                var match = regex.Match(res, jsonIndex);
                if (!match.Success)
                {
                    break;
                }

                var typeHint = string.Format(TYPE_HINT, type.Name, type.Namespace);

                jsonIndex = match.Index + match.Length;
                res       = res.Insert(jsonIndex, typeHint);
            }

            return(res);
        }
Example #2
0
 /// <summary>
 /// Constructor with parameters.
 /// </summary>
 /// <param name="info">Serialization Info.</param>
 /// <param name="context">Streaming Context.</param>
 /// <exception cref="SerializationException">If geometry type is not supported.</exception>
 protected GeometryHolder(SerializationInfo info, StreamingContext context)
 {
     if (GPObjectHelper.IsPoint(info))
     {
         // Create point.
         this._value = _CreatePoint(info);
     }
     else if (GPObjectHelper.IsPolyline(info))
     {
         this._value = _ReadPolyline(info);
     }
     else
     {
         // Unsupported geometry type.
         throw new SerializationException(
                   Properties.Messages.Error_UnsupportedGPGeometryObject);
     }
 }