public static List <MilitaryBase> SelectAll() { List <MilitaryBase> list = null; DataProvider.ExecuteCmd(GetConnection, "dbo.MilitaryBase_SelectAll" , inputParamMapper : null , map : delegate(IDataReader reader, short set) { switch (set) { case 0: MilitaryBase p = MapMilitaryBase(reader); if (list == null) { list = new List <MilitaryBase>(); } list.Add(p); break; } } ); return(list); }
public static void CreateMilitaryBase() { MilitaryBase asset = (MilitaryBase)CreateAsset("DoVAlpha/GovernmentsDefault/data/bases", typeof(MilitaryBase)); if (asset != null) { asset.BaseName = "some army"; } }
private static MilitaryBase MapMilitaryBase(IDataReader reader) { MilitaryBase p = new MilitaryBase(); int ord = 0; //startingOrdinal p.Id = reader.GetInt32(ord++); p.MilitaryBaseName = reader.GetString(ord++); p.ServiceBranchId = reader.GetInt32(ord++); p.ServiceBranchName = reader.GetSafeString(ord++); return(p); }
private static MilitaryBase MapMilitaryBaseList(IDataReader reader, out int personId) { MilitaryBase mb = new MilitaryBase(); int ord = 0; personId = reader.GetSafeInt32(ord++); mb.Id = reader.GetSafeInt32(ord++); mb.MilitaryBaseName = reader.GetSafeString(ord++); mb.ServiceBranchId = reader.GetSafeInt32(ord++); mb.ServiceBranchName = reader.GetSafeString(ord++); return(mb); }
static void Main(string[] args) { var units = new List <MilitaryUnit>(); units.Add(new Solder("Hero 1")); units.Add(new Solder("Hero 2")); units.Add(new AirPlane("Stells")); units.Add(new Cannon("Dora")); units.Add(new Tank("PZ IV")); var militaryBase = new MilitaryBase(units); militaryBase.GoToAttack(); Console.ReadKey(); }
public static MilitaryBase SelectById(int id) { MilitaryBase militaryBase = null; DataProvider.ExecuteCmd(GetConnection, "dbo.MilitaryBase_SelectById", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", id); } , map : delegate(IDataReader reader, short set) { switch (set) { case 0: militaryBase = MapMilitaryBase(reader); break; } } ); return(militaryBase); }
public List <Person> GetAll() { List <Person> list = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Person_SelectAll" , inputParamMapper : null , map : delegate(IDataReader reader, short set) { switch (set) { case 0: Person p = MapPerson(reader); if (list == null) { list = new List <Person>(); } list.Add(p); break; case 1: int personId = 0; MilitaryBase mb = MapMilitaryBaseList(reader, out personId); Person person = list.Find(item => item.Id == personId); if (person.MilitaryBases == null) { person.MilitaryBases = new List <MilitaryBase>(); } person.MilitaryBases.Add(mb); break; case 2: int personaId = 0; PersonLanguage bl = MapLanguageList(reader, out personaId); Person persona = list.Find(item => item.Id == personaId); if (persona != null) { if (persona.Languages == null) { persona.Languages = new List <PersonLanguage>(); } persona.Languages.Add(bl); } break; case 3: int personalId = 0; Skill sk = MapSkillList(reader, out personalId); Person personal = list.Find(item => item.Id == personalId); if (personal != null) { if (personal.Skills == null) { personal.Skills = new List <Skill>(); } personal.Skills.Add(sk); } break; default: break; } } ); return(list); }
public Person PublicSelect(int id) { Person person = null; List <MilitaryBase> mbList = null; List <PersonLanguage> laList = null; List <Skill> skList = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Person_SelectById", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", id); } , map : delegate(IDataReader reader, short set) { switch (set) { case 0: person = MapPerson(reader); break; case 1: int personId = 0; MilitaryBase mb = MapMilitaryBaseList(reader, out personId); if (mbList == null) { mbList = new List <MilitaryBase>(); } mbList.Add(mb); break; case 2: PersonLanguage la = MapLanguageList(reader, out personId); if (laList == null) { laList = new List <PersonLanguage>(); } laList.Add(la); break; case 3: Skill sk = MapSkillList(reader, out personId); if (skList == null) { skList = new List <Skill>(); } skList.Add(sk); break; case 4: CompanyBase cb = MapCompany(reader, out personId); if (person.Companies == null) { person.Companies = new List <CompanyBase>(); } person.Companies.Add(cb); break; case 5: SquadBase sq = MapSquad(reader, out personId); if (person.Squads == null) { person.Squads = new List <SquadBase>(); } person.Squads.Add(sq); break; case 6: PersonNotificationPreference pnp = PreferenceMap(reader, out personId); if (person.Preferences == null) { person.Preferences = new List <PersonNotificationPreference>(); } person.Preferences.Add(pnp); break; } } ); person.MilitaryBases = mbList; person.Languages = laList; person.Skills = skList; return(person); }
static void Main(string[] args) { #region Tablica jednowymiarowa //int[] a = new int[3]; //a[0] = 1; //a[1] = 3; //a[2] = 5; //for (int i = 0; i < a.Length; i++) //{ // Console.WriteLine(a[i]); //} #endregion #region Tablica dwuwymiarowa //int[,] b = new int[10, 10]; //b[0, 0] = 10; //b[0, 2] = 20; //b[1, 3] = 30; //b[2, 4] = 40; //b[5, 6] = 50; //for (int i = 0; i < 10; i++) //{ // for (int j = 0; j < 10; j++) // { // Console.WriteLine(b[i,j]); // } //} #endregion #region Tablica wyszczerbiona //int[][] c = new int[5][]; //c[0] = new int[3]; //c[1] = new int[5]; //c[2] = new int[2]; //c[3] = new int[4]; //c[4] = new int[2]; //c[0][0] = 1; //c[0][1] = 1; //c[0][2] = 1; //c[1][0] = 2; //c[1][1] = 2; //c[1][2] = 2; //c[1][3] = 2; //c[1][4] = 2; //c[2][0] = 3; //c[2][1] = 3; //c[3][0] = 4; //c[3][1] = 4; //c[3][2] = 4; //c[3][3] = 4; //c[4][0] = 5; //c[4][1] = 5; //for (int i = 0; i < c.Length; i++) //{ // for (int j = 0; j < c[i].Length; j++) // { // Console.WriteLine(c[i][j]); // } //} #endregion #region Guid //int x = default(int); // defaultowo 0; //Console.WriteLine("x = " + x); //Guid y = new Guid(); //y = default(Guid); // defaultowo 000-000-000000.... itd //Console.WriteLine("y = " + y); #endregion #region Dictionary //klucz nie moze sie powtarzac //Dictionary<int, TestClass> a = new Dictionary<int, TestClass>(); //a.Add(1, new TestClass { TestClassID = 1, TestClassName = "test1" }); //a.Add(2, new TestClass { TestClassID = 11, TestClassName = "test2" }); //a.Add(3, new TestClass { TestClassID = 111, TestClassName = "test3" }); //a.Add(4, new TestClass { TestClassID = 1111, TestClassName = "test4" }); //foreach (var i in a) //{ // Console.WriteLine(i.Key + " | " + i.Value.TestClassID + " | " + i.Value.TestClassName); //} //Console.WriteLine(a[1].TestClassName); //pierwszyy element wg klucza (indeksu) //Console.WriteLine(a.ElementAt(0).Value.TestClassName; // pierwszy element wg indeksu jak dla tablic #endregion #region KeyValuePair //klucz moze sie powtarzac //KeyValuePair<int, TestClass> collectionA = new KeyValuePair<int, TestClass>(1, new TestClass { TestClassID = 1, TestClassName = "uwemheh1" }); //KeyValuePair<int, TestClass> collectionB = new KeyValuePair<int, TestClass>(1, new TestClass { TestClassID = 2, TestClassName = "uwemheh2" }); //List<KeyValuePair<int, TestClass>> listofKVP = new List<KeyValuePair<int, TestClass>>(); //listofKVP.Add(collectionA); //listofKVP.Add(collectionB); #endregion #region HermeryzacjaStatyczna //Console.WriteLine(Dodawanie(2,3)); //Console.WriteLine(Dodawanie(2,3,5)); #endregion #region OdwolanieDoEnuma //Console.WriteLine((int)TestEnum.Wtorek); //TestEnum nowyEnum = TestEnum.Wtorek; //switch(nowyEnum) //{ // case TestEnum.Poniedzialek: // break; // case TestEnum.Wtorek: // break; // case TestEnum.Sroda: // break; // default: // break; //} #endregion #region POLIMORFIZM DYNAMICZNY BaseBody bb = new BaseBody(); //bb.CreateBase("Baza bazowa", 20.4f, 31.4f); //bo stworzylem konstruktor MilitaryBase mb = new MilitaryBase("Wojskowa", 9.9f, 2.2f); //mb.CreateBase("Wojskowa", 9.9f, 2.2f); //bo stworzylem konstruktor MilitaryBase mb2 = new MilitaryBase("Bazwa wojskowa z ochrona", 11.1f, 22.2f, 100); //mb2.CreateBase("Bazwa wojskowa z ochrona", 11.1f, 22.2f, 100); //bo stworzylem konstruktor BaseBody mbb = new MilitaryBase("base body o ksztalcie military base", 21.1f, 32.2f); //mbb.CreateBase("base body o ksztalcie military base", 21.1f, 32.2f); //bo stworzylem konstruktor //BaseBody mbb2 = new MilitaryBase(); //mbb2.CreateBase("base body o ksztalcie military base", 21.1f, 32.2f, 200); //NIE MOZNA WYKONAC BO ROBIMY BASEBODY NA KSZTALT MILITARYBODY A TAM NIE MA METODY POLIMORFICZNEJ (DYNAMICZNEJ-NADPISYWANEJ) Z PRZECIAZENIEM TZN. Z WALLRESISTANCE //MilitaryBase mbbb() = new BaseBody(); //NIE DZIALA BO POLIMORFIZM DYNAMICZNY DZIALA ZAWSZE W DOL NIGDY W GORE, NP. DZIECIAK NIGDY NIE MOZE PRZYJAC KSZTALTU RODZICA ALE RODZIC ZAWSZE MOZE PRZYJAC KSZTALT DZIECKA #endregion Console.ReadKey(); }