S
shapper
Hello,
I have an object which properties I want to have default values.
However, I would like to be able to update these values. I have
something like:
// View
public class View {
public IList<Asset> Assets { get; set; }
public String Author { get; set; }
public IList<String> Scripts { get; set; }
public String Title { get; set; }
public View() {
Assets = assetRepository.GetAssets().ToList();
Author = "Me";
Author = "My Company";
Scripts = new List<String>();
foreach (Asset a in Assets.Where(a => a.Type == "Script").OrderBy
(a => a.Priority)) Scripts.Add(a.Content);
} // View
}
Then I am using it as follows:
MyModel model = new MyModel {
View = new View {
Title = "Homepage - Welcome" }
};
model.View.Assets.Add(assetService.GetAsset("Script.TinyMce"));
As you can see I am trying to change the title default value and
adding new values to Assets.
But then I need to add this Asset to Scripts as I do in the
constructor.
I am just a little bit confused on how to implement the View class and
what methods needed.
When I change something, something else stops working.
Could someone advice me on this?
Thanks
Miguel
I have an object which properties I want to have default values.
However, I would like to be able to update these values. I have
something like:
// View
public class View {
public IList<Asset> Assets { get; set; }
public String Author { get; set; }
public IList<String> Scripts { get; set; }
public String Title { get; set; }
public View() {
Assets = assetRepository.GetAssets().ToList();
Author = "Me";
Author = "My Company";
Scripts = new List<String>();
foreach (Asset a in Assets.Where(a => a.Type == "Script").OrderBy
(a => a.Priority)) Scripts.Add(a.Content);
} // View
}
Then I am using it as follows:
MyModel model = new MyModel {
View = new View {
Title = "Homepage - Welcome" }
};
model.View.Assets.Add(assetService.GetAsset("Script.TinyMce"));
As you can see I am trying to change the title default value and
adding new values to Assets.
But then I need to add this Asset to Scripts as I do in the
constructor.
I am just a little bit confused on how to implement the View class and
what methods needed.
When I change something, something else stops working.
Could someone advice me on this?
Thanks
Miguel