Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

If you are not forced to use xml then json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of classes:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck RubberDuck's naming suggestion.

If you are not forced to use xml then json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of classes:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

If you are not forced to use xml then json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of classes:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

added 1 character in body
Source Link
t3chb0t
  • 44.7k
  • 9
  • 84
  • 190

If you are not forced to use xml then `jsonjson might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of objectsclasses:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

If you are not forced to use xml then `json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of objects:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

If you are not forced to use xml then json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of classes:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

Source Link
t3chb0t
  • 44.7k
  • 9
  • 84
  • 190

If you are not forced to use xml then `json might be a better solution. You wouldn't have to worry about parsing. Here'a sample:

Everything you need to do to load it into an object is:

class Program
{
 static void Main(string[] args)
 {
 var jobs = File.ReadAllText("jobs.json");
 var jobsService = JsonConvert.DeserializeObject<JobService>(jobs);
 }
} 

For this to work you'd to define a couple of objects:

public class JobService
{
 public IList<Job> Jobs { get; set; }
}
public class Job
{
 public IList<ProcedureParameter> ProcedureParameters { get; set; }
 public EmailSettings EmailSettings { get; set; }
}
public class Recipient
{
 public IList<string> Addressess { get; set; }
}
public class ProcedureParameter
{
 public string Name { get; set; }
 public string Value { get; set; }
}
public class EmailSettings
{
 public string SubjectName { get; set; }
 public string AttachmentName { get; set; }
 public IList<string> Recipients { get; set; } 
}

Your json would then directly be converted into an object:

{
 "Jobs": [
 {
 "Name": "Report",
 "EmailSettings": {
 "SubjectName": "Subject",
 "AttachmentName": "SomeFileName1.csv",
 "Recipients": [
 "[email protected]",
 "[email protected]"
 ]
 }
 }
 ]
}

It'd also be a good idea to follow @RubberDuck's naming suggestion.

default

AltStyle によって変換されたページ (->オリジナル) /