Exemple #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            // The Length property provides the number of array elements
            //System.Console.WriteLine("parameter count = {0}", args.Length);
            int  DevID = 0;
            bool NextD = false;

            for (int i = 0; i < args.Length; i++)
            {
                //System.Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
                if (NextD == true)
                {
                    NextD = false;
                    DevID = System.Convert.ToInt32(args[i]);
                }

                if (args[i].ToLower() == "-d")
                {
                    NextD = true;
                }
            }

            if (DevID == 0)
            {
                return;
            }

            DeviceProcessor Srv = new DeviceProcessor();

            Srv.DivID = DevID;
            Srv.Run();
            Srv = null;
        }
        public void DependancyInjectionTest()
        {
            Program.PerformIoCActions();
            SimpleContainer simpleContainer = new SimpleContainer();
            SamsungDevice   device          = new SamsungDevice();

            simpleContainer.RegisterInstance <IDevice>(device);
            DeviceProcessor deviceProcessor = new DeviceProcessor(device);

            simpleContainer.RegisterInstance <IDeviceProcessor>(deviceProcessor);
            deviceProcessor = (DeviceProcessor)simpleContainer.Resolve(typeof(IDeviceProcessor));
            var processor = deviceProcessor as IDeviceProcessor;

            Assert.IsNotNull(processor, "IDeviceProcessor has not been implemented correctly");
            // call the GetDevicePrice method
            Console.WriteLine("Device Price: {0:C}", processor.GetDevicePrice());
        }
Exemple #3
0
 static void Main(string[] args)
 {
     //SQLiteHelper.CreateDataBase();
     //SQLiteConnection con = new SQLiteConnection("data source=test1.db");
     //con.SetPassword("pass");
     //con.Open();
     //con.Close();
     //SQLiteHelper.ExecuteDataSet("select * from device",null);
     //Device d = new Device();
     //d.ID = 1;
     //Type type = d.GetType();
     //var properityInfo = type.GetProperties().Where(p=>p.CanWrite).ToList();
     //properityInfo.ForEach(p =>
     //{
     //   object o=p.GetValue(d,p.GetIndexParameters());
     //   Console.WriteLine(o);
     //});
     IDataProcessor processor = new DeviceProcessor();
     Dictionary<string, object> dic = new Dictionary<string, object>();
     dic.Add("PID", 10001);
     Device d = processor.QueryOne<Device>("select * from device where pid=@PID", dic);
     d.GetType().GetProperties().Where(p => p.CanRead).ToList().ForEach(p =>
     {
         Console.WriteLine("the column of {0} is {1}",p.Name,p.GetValue(d,p.GetIndexParameters()));
     });
     //修改
     //Dictionary<string, object> dic = new Dictionary<string, object>();
     //dic.Add("text","test"+DateTime.Now.ToString());
     //processor.ExecuteNonQuery("update device set remark=@text",dic);
     //d = processor.QueryOne<Device>("select * from device", null);
     //d.GetType().GetProperties().Where(p => p.CanRead).ToList().ForEach(p =>
     //{
     //    Console.WriteLine("the column of {0} is {1}", p.Name, p.GetValue(d, p.GetIndexParameters()));
     //});
     //Utils.WriteToXML();
     //string s = Utils.Decode(Utils.ReadPwdFromXML(), Utils.ReadKeyFromXML(), Utils.ReadIVFromXML());
     processor.OnCreated();
     processor.Query<Device>("select * from device",null);
     Console.ReadKey();
 }