public void Call() { // An array of creators Creater[] creators = new Creater[2]; creators[0] = new ConcreateCreator(); creators[1] = new ConcreateCreator(); // Iterate over creators and create products foreach (Creater creator in creators) { IProduct product = creator.FactoryCreator("A"); Console.WriteLine("Created {0}", product.GetType().Name); product = creator.FactoryCreator("B"); Console.WriteLine("Created {0}", product.GetType().Name); } // Wait for user Console.ReadKey(); }
/// <summary> /// Get a list of ADConnectors.User created since a give date /// </summary> /// <param name="configuration"></param> /// <param name="earliest"></param> /// <returns></returns> private static (List <User>, List <Dictionary <string, string> >) CheckNewAccount(IConfiguration configuration, DateTime earliest) { List <User> users = new List <User>(); List <Dictionary <string, string> > incompletedUsers = new List <Dictionary <string, string> >(); using (IADSearcher ad = Creater.GetADConnector(configuration.GetSection("AD"))) { List <Dictionary <string, string> > results = ad.Search(earliest); Log.Information($"Total user found: {results.Count}"); int i = 0; foreach (var user in results) { i++; Console.WriteLine("User {0}: {1} ({2} {3})", i, user["samaccountname"], user["givenname"], user["sn"]); Log.Debug("User {0}: {1} ({2} {3})", i, user["samaccountname"], user["givenname"], user["sn"]); try { users.Add(new User(user)); } catch (KeyNotFoundException) { incompletedUsers.Add(user); } } }; return(users, incompletedUsers); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); eRSA = Creater.GetADConnector(Configuration.GetSection("AD")); services.AddSingleton <IADSearcher>(eRSA); try { CRMClient crmClient = new CRMClient(Configuration["Dynamics:Authority"], Configuration["Dynamics:Resource"], Configuration["Dynamics:ClientId"], Configuration["Dynamics:ClientSecret"], Configuration["Dynamics:Version"]); services.AddSingleton <ITokenConsumer>(crmClient); } catch (FileNotFoundException ex) { Console.WriteLine(ex.ToString()); throw new ApplicationException("Cannot continue because saved token file is not found."); } Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .CreateLogger(); services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); Log.Logger.Debug("All services have been set up."); }
static void Main(string[] args) { //C# method is Invariant MusicCreater mu1 = musicCreater; //MetalCreater me1 = mu1; MetalCreater me2 = metalCreater; //MusicCreater mu2 = me2; //Convariance //Creater<Music> mu3 = musicCreater; //Creater<Metal> me3 = mu3;//get music include metal or classic or pop NG Creater <Metal> me4 = metalCreater; Creater <Music> mu4 = me4; //get metal, metal is music MusicCreater mu5 = metalCreater; // (out is not nessary) //MetalCreater me5 = musicCreater; CreaterClass <Metal> me6 = new CreaterClass <Metal>(); ICreate <Music> imusic = me6; //CreaterClass<Music> mu6 = new CreaterClass<Music>(); //ICreate<Metal> imetal = mu6; //Contravariance //Eater<Bamboo> ba1 = x => { }; //Eater<Food> fo1 = ba1; // dispose food, not only bamboo but also other thing is food too Eater <Food> fo2 = x => { }; Eater <Bamboo> ba2 = fo2; // dispose bamboo, bamboo is food //EaterClass<Bamboo> ba3 = new EaterClass<Bamboo>(); //IEat<Food> ifood = ba3; EaterClass <Food> fo3 = new EaterClass <Food>(); IEat <Bamboo> ibamboo = fo3; }
public void FromCustomObject(SqlConnection con, IntPtr pUdt) { if (ID != null) { SqlUdt.SetValue(con, pUdt, "ID", ID.ToSqlValue()); } if (CheckNo != null) { SqlUdt.SetValue(con, pUdt, "CheckNo", CheckNo.ToSqlValue()); } if (CheckType != null) { SqlUdt.SetValue(con, pUdt, "CheckType", CheckType.ToSqlValue()); } if (DutyUser != null) { SqlUdt.SetValue(con, pUdt, "DutyUser", DutyUser.ToSqlValue()); } if (CheckDesc != null) { SqlUdt.SetValue(con, pUdt, "CheckDesc", CheckDesc.ToSqlValue()); } if (CheckStatus != null) { SqlUdt.SetValue(con, pUdt, "CheckStatus", CheckStatus.ToSqlValue()); } if (BeginTime != null) { SqlUdt.SetValue(con, pUdt, "BeginTime", BeginTime.ToSqlValue()); } if (DoneTime != null) { SqlUdt.SetValue(con, pUdt, "DoneTime", DoneTime.ToSqlValue()); } if (Remarks != null) { SqlUdt.SetValue(con, pUdt, "Remarks", Remarks.ToSqlValue()); } if (IsDel != null) { SqlUdt.SetValue(con, pUdt, "IsDel", IsDel.ToSqlValue()); } if (Creater != null) { SqlUdt.SetValue(con, pUdt, "Creater", Creater.ToSqlValue()); } if (CreateTime != null) { SqlUdt.SetValue(con, pUdt, "CreateTime", CreateTime.ToSqlValue()); } if (Modifyer != null) { SqlUdt.SetValue(con, pUdt, "Modifyer", Modifyer.ToSqlValue()); } if (ModifyTime != null) { SqlUdt.SetValue(con, pUdt, "ModifyTime", ModifyTime.ToSqlValue()); } }
public void Test1() { var expectedValue = "Your sign is: dfg"; string value = Creater.CreateName(); Assert.Equal(expectedValue, value); }
public Description(int count, Creater creater) { this.creater = creater; this.count = count; this.outOfObjError = null; this.onFree = null; this.onUse = null; }
static void Main(string[] args) { Creater creater = new Creater(); Oyun atariOyunu = creater.FactoryMethod(Oyunlar.Atari); Oyun pcOyunu = creater.FactoryMethod(Oyunlar.PC); Oyun psOyunu = creater.FactoryMethod(Oyunlar.PS); atariOyunu.Platform(); pcOyunu.Platform(); psOyunu.Platform(); Console.Read(); }
private void ButtonClickCreateComplexObject(object sender, RoutedEventArgs e) { Creater creater = new Creater(); ComplexObjectBilder complexObjectBilder = new YellowComplexObjectBilder(); ComplexObject grenComplexObject = creater.complexObject(complexObjectBilder); Greed.Children.Add(complexObjectBilder.SetCircletes()); Greed.Children.Add(complexObjectBilder.SetSquaretes()); complexObjectBilder = new BlueComplexObjectBilder(); ComplexObject BlueComplexObject = creater.complexObject(complexObjectBilder); Greed.Children.Add(complexObjectBilder.SetSquaretes()); }
static void Test <T>(Creater <T> creater) where T : Man { var m1 = new Man(33); var m2 = new Man(33); T t1 = (T)m1; T t2 = (T)m2; //传入创建的create有问题 if (creater.Test(t1, t2)) // Exception NullReference { Console.WriteLine(true); } else { Console.WriteLine(false); } }
static void Main(string[] args) { GetAppSettingsFile(); #region NewsCountConfig var emlakCount = _iconfiguration["NewsCountConfig:emlakCount"]; var aileCount = _iconfiguration.GetSection("NewsCountConfig").GetSection("aileCount").Value; var yeniBirIsCount = _iconfiguration.GetSection("NewsCountConfig").GetSection("yeniBirIsCount").Value; var bigparaCount = _iconfiguration.GetSection("NewsCountConfig").GetSection("bigparaCount").Value; var mahmureCount = _iconfiguration.GetSection("NewsCountConfig").GetSection("mahmureCount").Value; #endregion #region RedisConfig var redisKey = _iconfiguration.GetSection("RedisConfig").GetSection("Key").Value; var timeOut = _iconfiguration.GetSection("RedisConfig").GetSection("Timeout").Value; RedisHelper redisHelper = new RedisHelper(); redisHelper.ReadData(redisKey); #endregion SqlHelper.TruncateDb(); #region FactoryPattern Creater creater = new Creater(); FactoryData jsonData = creater.FactoryMethod(Datas.Json); FactoryData xmlData = creater.FactoryMethod(Datas.Xml); jsonData.DataType(); xmlData.DataType(); #endregion var allDatas = SqlHelper.SelectDb(); var list = SqlHelper.SelectedData(Convert.ToInt32(emlakCount), Convert.ToInt32(aileCount), Convert.ToInt32(yeniBirIsCount), Convert.ToInt32(bigparaCount), Convert.ToInt32(mahmureCount)); var list2 = SqlHelper.SelectSomeData(); redisHelper.SaveBigData(redisKey, timeOut, list); Console.WriteLine("Press to any key..."); Console.ReadLine(); }
public void FromCustomObject(SqlConnection con, IntPtr pUdt) { SqlUdt.SetValue(con, pUdt, "ID", ID.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "CheckID", CheckID.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "WarehouseNo", WarehouseNo.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "HouseNo", HouseNo.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "AreaNo", AreaNo.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "MaterialNo", MaterialNo.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "MaterialDesc", MaterialDesc.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "AccountQty", AccountQty.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "ScanQty", ScanQty.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "Status", Status.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "StockTime", StockTime.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "Operator", Operator.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "OperationTime", OperationTime.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "ProfitLoss", ProfitLoss.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "DifferenceQty", DifferenceQty.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "IsDel", IsDel.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "Creater", Creater.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "CreateTime", CreateTime.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "Modifyer", Modifyer.ToSqlValue()); SqlUdt.SetValue(con, pUdt, "ModifyTime", ModifyTime.ToSqlValue()); }
public void Reg <S>(string key) where S : T, new() { creaters[key] = new Creater <S>(); AddReg(key); }
public DynamicPool(Creater creater) { this.creater = creater; free = new List <T>(); used = new List <T>(); }
protected virtual void OnCreater(GameObjectUI arg1) { Creater?.Invoke(arg1, EventArgs.Empty); }