• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

How to optimize Fluent Interface in Web services?

it is my mail class which is a model:

   public class Mail
    {
        public MailService Set { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string Subject { get; set; }
        public string Body { get; set; }
        public List Recipients { get; set; }
        public List Bcc { get; set; }
        public List Cc { get; set; }
        public bool Send { get; set; }
        public Mail()
        {
            Set = new MailService(this);
        }

    }

Open in new window

Also i created a web service which is controller :
namespace MyFluentInterface.Services
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class MailService : System.Web.Services.WebService
    {
          [NonSerialized]
          private readonly Mail _mail;
          public MailService()
          {

          }
          public MailService(Mail mail)
        {
            _mail = mail;
        }

        #region IMail Members

        [WebMethod]
          public MailService UserName(string username)
        {
            _mail.UserName = username;
            return this;
        }
        [WebMethod]
        public MailService Password(string password)
        {
            _mail.Password = password;
            return this;
        }
        [WebMethod]
        public MailService Subject(string subject)
        {
            _mail.Subject = subject;
            return this;
        }
        [WebMethod]
        public MailService Body(string body)
        {
            _mail.Body = body;
            return this;
        }
        [WebMethod]
        public MailService Recipients(List recipients)
        {
            _mail.Recipients = recipients;
            return this;
        }
        [WebMethod]
        public MailService Bcc(List bcc)
        {
            _mail.Bcc = bcc;
            return this;
        }
        [WebMethod]
        public MailService Cc(List Cc)
        {
            _mail.Cc = Cc;
            return this;
        }

        [WebMethod]
        public bool Send()
        {
            _mail.Send = true; // Bir olayin sonucunda bu elde edilmeli
            return true;
        }
        #endregion
    }
}

Open in new window

Also i have a VIEW project to test:

    public class Test
    {
        private Mail mail { get; set; }
        public Test()
        {
            mail = new Mail();

        }
        public bool Send()
        {
            return mail.Set.Subject("fdsfs").Body("fsdg").Send();
        }
    }

Open in new window

i utilize from Fluent interface.i used it in web service. But this error returns me:

Cannot serialize member System.ComponentModel.MarshalByValueComponent.Site of type System.ComponentModel.ISite because it is an interface.

How to solve it?
0
programmerist
Asked:
programmerist
  • 2
1 Solution
 
strickddCommented:
You will need to create a class that uses this interface and mark it as serializeable.

[Serializable]
public class MyObject : ISite
{
  
}

Open in new window

0
 
programmeristAuthor Commented:
Not working Sorry :(
0
 
programmeristAuthor Commented:
ARE YOU THERE?????????????????????????? i want to see answer . i wont refresh my subscribe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now