public override XElement ToXml()
{
var result = base.ToXml();
var connectionString = string.Join(";",
string.Format("Address={0}", Address),
string.Format("DefaultQuery={0}", DefaultQuery),
string.Format("AuthenticationType={0}", AuthenticationType)
);
if(AuthenticationType == AuthenticationType.User)
{
connectionString = string.Join(";",
connectionString,
string.Format("UserName={0}", UserName),
string.Format("Password={0}", Password)
);
}
result.Add(
new XAttribute("ConnectionString", DpapiWrapper.Encrypt(connectionString)),
new XAttribute("Type", ResourceType),
new XElement("TypeOf", ResourceType)
);
return result;
}