stuart-d2
5/13/2015 - 10:32 AM

StructMVC Demonstrates the basic M_C idiom, but instead of the typical use of a class for the Model, a struct is used instead.

StructMVC Demonstrates the basic M_C idiom, but instead of the typical use of a class for the Model, a struct is used instead.


//A struct, used in the asp.net idiom.
//A model -- ReferrerInfo, instead of being setup like a class, is set up as a struct

//using System;
//using System.Collections.Generic;  

class Program
{

static void Main()
{
	// e.g., The controller.  
	//new dictionary, string and referrerInfo consumed as entries
	var d = new Dictionary<string, ReferrerInfo>();
	
	//New Struct
	ReferrerInfo i;
	i.OriginalString = "foo";
	i.Target = "poo";
	i.Time = DateTime.Now; 
	
	//add the struct to the dictionary 
	d.Add("info", i);  
}

/// <summary
/// Contains information about referrers
/// This is typically what you'd see in the 'models' section
/// But instead of a class, this is a struct
/// `</summary> 

//The Model
struct ReferrerInfo
{
	public string OriginalString; //Reference
	public string Target; // Reference
	public DateTime Time;  // value
}; 


}