Ejemplo n.º 1
0
        public static SingletonInstance <T> GetInstance()
        {
            if (myself != null)
            {
                return(myself);
            }
            lock (locker)
            {
                myself = new SingletonInstance <T>();
            }

            return(myself);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            string text = @"Do you like green eggs and ham? 
                            I do not like them, Sam-I-am.
                            I do not like green eggs and ham.";

            Dictionary <string, int> frequencies = CountWords(text);

            foreach (KeyValuePair <string, int> entry in frequencies)
            {
                string word      = entry.Key;
                int    frequency = entry.Value;
                Console.WriteLine("{0}: {1}", word, frequency);
            }

            List <string> strings = new List <string>();

            strings.Add("Sam");
            strings.Add("Jon");
            strings.Add("Ned");
            strings.Add("Stark");

            List <string> names = strings.ConvertAll(ConvertName);

            foreach (string name in names)
            {
                Console.WriteLine(name);
            }

            Console.WriteLine(GetType <List <string> >(new List <string>()));

            SingletonInstance <LambdaTest> instance1 = SingletonInstance <LambdaTest> .GetInstance();

            instance1.Name = "instance new 1234567890";

            SingletonInstance <LambdaTest> instance2 = SingletonInstance <LambdaTest> .GetInstance();

            Console.WriteLine("{0} - {1}", instance1.GetType().ToString(), instance1.Name);
            Console.WriteLine("{0} - {1}", instance2.GetType().ToString(), instance2.Name);

            LambdaTest inst = SingletonInstance <LambdaTest> .CreateInstance();

            inst.LambdaTests();
        }