Is there an example showing how to implement the recent provider changes for sending additional information to the provider? I'm working on a custom provider that does NOT use an XML data source and I'm looking mainly at the Implementing A Provider That Supports Multi-valued Resources example, but it is still using the old implementation. I understand what the changes are, but I'm having trouble converting the old "GetResourceTypes" and "GetResourceByType" methods to the new "GetResources" method.
Basically I need help converting the following code to the new "GetResources" implementation. Any help would be greatly appreciated.
Basically I need help converting the following code to the new "GetResources" implementation. Any help would be greatly appreciated.
public override IEnumerable<ResourceType> GetResourceTypes(RadScheduler owner){ ResourceType[] resourceTypes = new ResourceType[2]; resourceTypes[0] = new ResourceType("Teacher", false); resourceTypes[1] = new ResourceType("Student", true); return resourceTypes;} public override IEnumerable<Resource> GetResourcesByType(RadScheduler owner, string resourceType){ switch (resourceType) { case "Teacher" : return Teachers.Values; case "Student" : return Students.Values; default: throw new InvalidOperationException( "Unknown resource type: " + resourceType); }}private IDictionary<int, Resource> Teachers{ get { if (_teachers == null) { _teachers = new Dictionary<int, Resource>(); foreach (Resource teacher in LoadTeachers()) { _teachers.Add((int)teacher.Key, teacher); } } return _teachers; }}private IDictionary<int, Resource> Students{ get { _students = new Dictionary<int, Resource>(); foreach (Resource student in LoadStudents()) { _students.Add((int)student.Key, student); } return _students; }}private IEnumerable<Resource> LoadTeachers(){ List<Resource> resources = new List<Resource>(); using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT [TeacherID], [Name], [Phone] FROM [DbProvider_Teachers]"; using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Resource res = new Resource(); res.Type = "Teacher"; res.Key = reader["TeacherID"]; res.Text = Convert.ToString(reader[ "Name" ]); res.Attributes["Phone"] = Convert.ToString(reader["Phone"]); resources.Add(res); } } } return resources;}private IEnumerable<Resource> LoadStudents(){ List<Resource> resources = new List<Resource>(); using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT [StudentID], [Name] FROM [DbProvider_Students]"; using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Resource res = new Resource(); res.Type = "Student"; res.Key = reader["StudentID"]; res.Text = Convert.ToString(reader[ "Name" ]); resources.Add(res); } } } return resources;}