Click here to Skip to main content
15,905,420 members
Home / Discussions / C#
   

C#

 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn8-Mar-10 17:49
sitebuilderLuc Pattyn8-Mar-10 17:49 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
PIEBALDconsult9-Mar-10 3:20
mvePIEBALDconsult9-Mar-10 3:20 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn9-Mar-10 3:24
sitebuilderLuc Pattyn9-Mar-10 3:24 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
PIEBALDconsult9-Mar-10 6:16
mvePIEBALDconsult9-Mar-10 6:16 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn9-Mar-10 6:33
sitebuilderLuc Pattyn9-Mar-10 6:33 
Questionhow could I print or save datagrid view records? Pin
ronakT8-Mar-10 7:46
ronakT8-Mar-10 7:46 
AnswerRe: how could I print or save datagrid view records?[modified] Pin
Dan Mos8-Mar-10 8:26
Dan Mos8-Mar-10 8:26 
AnswerRe: how could I print or save datagrid view records? Pin
Sandeep Mewara8-Mar-10 9:53
mveSandeep Mewara8-Mar-10 9:53 
AnswerRe: how could I print or save datagrid view records? Pin
David MacDermot8-Mar-10 10:08
David MacDermot8-Mar-10 10:08 
QuestionC# to control unicode bill printing in Dotmatrix printer Pin
Winmass8-Mar-10 7:43
Winmass8-Mar-10 7:43 
AnswerRe: C# to control unicode bill printing in Dotmatrix printer Pin
PIEBALDconsult8-Mar-10 11:47
mvePIEBALDconsult8-Mar-10 11:47 
AnswerRe: C# to control unicode bill printing in Dotmatrix printer Pin
98529322549-Mar-10 2:05
98529322549-Mar-10 2:05 
GeneralRe: C# to control unicode bill printing in Dotmatrix printer Pin
Winmass9-Mar-10 16:04
Winmass9-Mar-10 16:04 
QuestionForce static objects to load when program starts, not lazy (load when first used)? Pin
Matthew Klein8-Mar-10 6:24
Matthew Klein8-Mar-10 6:24 
AnswerRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Keith Barrow8-Mar-10 6:36
professionalKeith Barrow8-Mar-10 6:36 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
harold aptroot8-Mar-10 6:53
harold aptroot8-Mar-10 6:53 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Keith Barrow8-Mar-10 7:02
professionalKeith Barrow8-Mar-10 7:02 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
harold aptroot8-Mar-10 7:16
harold aptroot8-Mar-10 7:16 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Matthew Klein8-Mar-10 7:03
Matthew Klein8-Mar-10 7:03 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
harold aptroot8-Mar-10 7:14
harold aptroot8-Mar-10 7:14 
AnswerRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Keith Barrow8-Mar-10 7:14
professionalKeith Barrow8-Mar-10 7:14 
QuestionRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Matthew Klein8-Mar-10 7:46
Matthew Klein8-Mar-10 7:46 
The this is used inside the class constructor, not the static constructor, so there is an instance to add to the list.

Here is a striped down layout of how I'm trying to do it.

public class GlobalList
    {
        public static List<GlobalList> listItems = new List<GlobalList>();

        private string _someImportantData;
        public GlobalList(string data)
        {
            _someImportantData = data;
            //do more stuff
            listItems.Add(this);
        }
    }

    public abstract class PlugInBase
    {
        //All "plug-ins" will be derived from this class
        public static void Initalize() { } //I'm trying to do this to force the
//creation of MyClassGlobalList, below, but it doesn't work
    }

    public class MyClass : PlugInBase
    {
        public static GlobalList MyClassGlobalList = new GlobalList("MyClass data");

        public MyClass()
        {
            //do stuff
        }
    }

    static class ExeClass
    {
        static void Main()
        {
            MyClass.Initalize(); //this is a search of all .dll files in the "plug-in" folder,
//then run .Initalize() on all classes of type "PlugInBase"
            
            GlobalList.listItems.Exists(...) //nothing in list =(
        }
    }


I want my program to search all .dlls in a "plug-in" folder, then search those dlls for any class of type "PlugInBase", and those classes will be "initalized" so the static items can be created. But I'm not currently able to get the "MyClassGlobalList" to be created. I can't refrence it directly since my program won't know how the class derived from "PlugInBase" will create its "GlobalList" item. I'm also not able to mark Initalize in PlugInBase as abstract, so I can't deligate the creation to the child class.

Any ideas, or maybe a different approach? I'm open for anything that works at this point.

Thanks!
AnswerRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
harold aptroot8-Mar-10 8:30
harold aptroot8-Mar-10 8:30 
GeneralRe: Force static objects to load when program starts, not lazy (load when first used)? Pin
Matthew Klein8-Mar-10 8:53
Matthew Klein8-Mar-10 8:53 
QuestionProblem with Display Scheme (Windows font size) Pin
sodevrom8-Mar-10 5:40
sodevrom8-Mar-10 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.