How do i create a new resource reader(c#)
I would like to know that how do i create a new resource reader(c#). Does any body knows about it that how can i do so? Can any body help me out in order to create a new resource reader(c#)? Any kind of information on the above issue would be appreciated.
Re: How do i create a new resource reader(c#)
The following code sample will help you to create shows how to create a Data Reader.
Quote:
public static SqlDataReader ReturnReader(string Query)
{
string ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["Connection String"].ConnectionString;
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand command = new SqlCommand();
command.Connection = con;
command.Connection.Open();
command.CommandText = Query;
return command.ExecuteReader();
}
Re: How do i create a new resource reader(c#)
For using a custom resource reader, it is also necessary to create a custom resource set and a custom resource manager. However, doing this is not a hard task, because you can derive the custom classes from existing classes.
Re: How do i create a new resource reader(c#)
The following code for example defines a new instance of the ResourceReader class that will read from the specified stream. The code then retrieves an enumerator, iterates through the stream, and prints key/value pairs to the console.
Quote:
using System;
using System.Resources;
using System.Collections;
using System.IO;
public class ReadResources
{
public static void Main(string[] args)
{
// Create a file stream to encapsulate items.resources.
FileStream fs = new FileStream("items.resources", FileMode.Open);
// Open a resource reader to read from the stream.
IResourceReader reader = new ResourceReader(fs);
// Get an enumerator for the reader.
IDictionaryEnumerator en = reader.GetEnumerator();
// Enumerate through the file, printing out the key/value pairs.
while (en.MoveNext())
{
Console.WriteLine();
Console.WriteLine("Name: {0}", en.Key);
Console.WriteLine("Value: {0}", en.Value);
}
fs.Close();
reader.Close();
}
}