static void Main(string[] args) { Szinek sz = Szinek.Zold; Console.WriteLine(sz); Console.WriteLine((int)sz); Console.WriteLine(Enum.GetUnderlyingType(typeof(Szinek))); Szinek2 sz2 = (Szinek2)1; Console.WriteLine(sz2); System.Console.WriteLine((int)Muvelet.Query); foreach (var item in Enum.GetValues(typeof(Muvelet))) { Console.WriteLine((int)(Muvelet)item + " " + (Muvelet)item); } Muvelet m = Muvelet.Read | Muvelet.Write; Console.WriteLine(m); Console.WriteLine((int)m); m = Muvelet.Write | Muvelet.Sync; Console.WriteLine(m); Console.WriteLine((int)m); m = Muvelet.SzinkronTorles; Console.WriteLine(m); Console.WriteLine((int)m); Console.ReadLine(); }
public Muvelet LoadXmlById(int id) { Muvelet m = null; using (var ctx = new AllContext(serverName, baseName, userName, password)) { var query = ctx.Muvelets .Where(ss => ss.id == id) .FirstOrDefault <Muvelet>(); m = query; } string xml = m.serialization; Muvelet mResult = null; XmlSerializer serializer = new XmlSerializer(typeof(Muvelet)); StringReader reader = new StringReader(xml); mResult = (Muvelet)serializer.Deserialize(reader); reader.Close(); return(mResult); }
public void addNew(Muvelet _Muvelet) { using (var ctx = new AllContext(serverName, baseName, userName, password)) { ctx.Muvelets.Add(_Muvelet); ctx.SaveChanges(); } }
public void Bejar(Muvelet M) { ListaElem p = fej; while (p != null) { M(p.tartalom); p = p.kovetkezo; } }
public void Bejar(Muvelet M) // Delegált segítségével átadhatunk valamely metódust, amelyet szeretnénk végrehajtani a lista minden egyes elemének tartalmán. { ListaElem p = fej; while (p != null) { M(p.tartalom); p = p.kovetkezo; } }
public Muvelet LoadXmlByGuid(string guid) { Muvelet m = null; using (var ctx = new AllContext(serverName, baseName, userName, password)) { var query = ctx.Muvelets .Where(ss => ss.GUID == guid) .FirstOrDefault <Muvelet>(); m = query; } return(m); }
public Muvelet findFirstById(int id) { Muvelet m = null; using (var ctx = new AllContext(serverName, baseName, userName, password)) { var query = ctx.Muvelets .Where(ss => ss.id == id) .FirstOrDefault <Muvelet>(); m = query; } return(m); }
public void SaveWithXml(Muvelet _Muvelet) { string xml = ""; XmlSerializer serializer = new XmlSerializer(typeof(Muvelet)); StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = XmlWriter.Create(stringWriter); serializer.Serialize(xmlWriter, _Muvelet); xml = stringWriter.ToString(); _Muvelet.serialization = xml; using (var ctx = new AllContext(serverName, baseName, userName, password)) { ctx.Muvelets.Add(_Muvelet); ctx.SaveChanges(); } }
public GetObjectResponse Save(Muvelet _Muvelet) { var response = new GetObjectResponse(); try { _MuveletEntityMethods.addNew(_Muvelet); response.Result = new Ac4yProcessResult() { Code = "1" }; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = "-1", Message = exception.Message }); } return(response); }
public GetObjectResponse SaveWithXml(Muvelet _Muvelet) { return(_MuveletPersistentService.SaveWithXml(_Muvelet)); }
static void Main(string[] args) { Muvelet[] muveletek = new Muvelet[] { Add, Substract, Divide, Modulus, Multiply }; Muvelet szamologep = (Muvelet)Delegate.Combine(muveletek); int a = 13; int b = 5; results.Clear(); szamologep(a, b); foreach (var item in results) { Console.WriteLine("{0} {1} {2} = {3}", a, item.Key, b, item.Value); } a = 13; b = 0; results.Clear(); try { szamologep(a, b); } catch (Exception) { Console.WriteLine("hiba van"); } foreach (var item in results) { Console.WriteLine("{0} {1} {2} = {3}", a, item.Key, b, item.Value); } Console.WriteLine(); Dictionary <string, Tuple <int, int> > mikormit = new Dictionary <string, Tuple <int, int> >(); mikormit["Add"] = Tuple.Create(1, 1); mikormit["Substract"] = Tuple.Create(2, 2); mikormit["Divide"] = Tuple.Create(3, 3); mikormit["Modulus"] = Tuple.Create(4, 4); mikormit["Multiply"] = Tuple.Create(5, 5); // egyesevel bejarni Delegate[] lista = szamologep.GetInvocationList(); foreach (var item in lista) { try { a = mikormit[item.Method.Name].Item1; b = mikormit[item.Method.Name].Item2; int eredmeny = ((Muvelet)item)(a, b); } catch (Exception) { Console.WriteLine("hiba volt"); } } foreach (var item in results) { Console.WriteLine("{0} {1} {2} = {3}", a, item.Key, b, item.Value); } Console.WriteLine("Kerem A-t:"); string sa = Console.ReadLine(); Console.WriteLine("Kerem B-t:"); string sb = Console.ReadLine(); a = int.Parse(sa); b = int.Parse(sb); Console.WriteLine("Mit csinaljak veluk? Add, Substract, Multiply, Divide, Modulus"); string muvelet = Console.ReadLine(); MethodInfo mi = typeof(Program).GetMethod(muvelet, BindingFlags.NonPublic | BindingFlags.Static); if (mi == null) { Console.WriteLine("ejny ebejnye nincs ilyen muvelet"); } else { Delegate m = Delegate.CreateDelegate(typeof(Muvelet), mi); object[] parameterek = new object[] { a, b }; object eredmeny = m.DynamicInvoke(parameterek); Console.WriteLine("eredmeny= " + eredmeny); } Console.ReadLine(); }
static void Main(string[] args) { #region Beolvasas // 1. feladat var excludedBeolvasott = File.ReadAllLines(@"c:\temp\excluded.csv"); var reservedBeolvasott = File.ReadAllLines(@"c:\temp\reserved.csv"); var dhcpBeolvasott = File.ReadAllLines(@"c:\temp\dhcp.csv"); var testBeolvasott = File.ReadAllLines(@"c:\temp\test.csv"); foreach (var item in excludedBeolvasott) { excluded.Add(item); } foreach (var item in reservedBeolvasott) { var allokacio = new Allokacio(item); reserved.Add(allokacio); } foreach (var item in dhcpBeolvasott) { var allokacio = new Allokacio(item); dhcp.Add(allokacio); } foreach (var item in testBeolvasott) { var muvelet = new Muvelet(item); test.Add(muvelet); } #endregion // 2. feladat foreach (var muvelet in test) { if (muvelet.Operacio == "request") { var letezoKapcsolat = KiVanOsztvaAcim(muvelet.Cim); if (letezoKapcsolat) { break; } else { var fenntartottCim = FenntartottaMacCim(muvelet.Cim); if (fenntartottCim) { var biztosLetezik = KiVanOsztvaAcim(muvelet.Cim); if (biztosLetezik) { break; } else { var allokacio = reserved.SingleOrDefault(x => x.MAC == muvelet.Cim); CimTarolasaASzerveren(allokacio); } } else { const string prefix = "192.168.10."; var kezdoIp = 99; string ipcim = ""; do { kezdoIp += 1; if (kezdoIp > 199) { throw new Exception("Az IP cím vége túllépte a 199-et."); } ipcim = $"{prefix}{kezdoIp}"; } while (!(SzabadAzIPcim(ipcim) && !TiltottAzIpCim(ipcim) && !FenntartottAzIpCim(ipcim))); var allokacio = new Allokacio(muvelet.Cim, ipcim); CimTarolasaASzerveren(allokacio); } } } else { Release(muvelet.Cim); } } // 3. feladat List <string> eredmeny = new List <string>(); foreach (var item in dhcp) { var csv = $"{item.MAC};{item.IPcim}"; eredmeny.Add(csv); } File.WriteAllLines(@"c:\temp\dhcp_kesz.csv", eredmeny); Console.ReadLine(); }