protected virtual void ProcessWebpartProperties(WebPartDefinitionBase definition, XDocument xml)
 {
     if (definition.Properties != null && definition.Properties.Count > 0)
     {
         foreach (var prop in definition.Properties)
         {
             var isCdata = prop.IsCData.HasValue && prop.IsCData.Value;
             xml.SetOrUpdateProperty(prop.Name, prop.Value, prop.Type, isCdata);
         }
     }
 }
        protected virtual void ProcessParameterBindings(WebPartDefinitionBase definition, XDocument xml)
        {
            if (definition.ParameterBindings != null && definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                xml.SetOrUpdateProperty("ParameterBindings", parameterBindingValue);
            }
        }