public async Task VipisatBan(string id, string length, string comment, string kickReason) { List <ulong> Admins; Admins = ReadWriter.TakeUintList("./ini/AdminList"); var message = this.Context.Message as SocketUserMessage; var context = new SocketCommandContext(this.Context.Client, message); if (!IsAdmin(message.Author, Admins)) { return; } string[] args = message.ToString().Split('|'); ulong DiscId = Convert.ToUInt64(id); ulong time = Convert.ToUInt64(length); DateTime dataTime = System.DateTime.Now; dataTime = dataTime.AddMinutes(time); File.AppendAllText("./ini/BanList", id + "|" + context.Client.GetUser(DiscId).Username + "|" + dataTime + "|" + comment + "|" + kickReason + "\n"); await context.Channel.SendMessageAsync($"Лошок " + $"{this.Context.Client.GetUser(DiscId).Mention}" + $" был забанен"); }
public async Task PrintBanList() { List <string> Bans; Bans = ReadWriter.TakeStringList("./ini/BanList"); int i = 0; var message = this.Context.Message as SocketUserMessage; var context = new SocketCommandContext(this.Context.Client, message); foreach (string it in Bans) { string[] args = it.Split('|'); string str = $"[{++i}] Лох {args[1]} с ID {args[0]} забен на {args[2]}"; if (args.Length >= 4) { str += " | Comment: " + args[3]; } if (args.Length >= 5) { str += " | Kick reason: " + args[4]; } await context.Channel.SendMessageAsync(str); } }
static void Main(string[] args) { ReadWriter myReadWriter = new ReadWriter(new ConsoleReaderWriterFactory()); string test = myReadWriter.Read(); myReadWriter.Write("this is abstract factory power"); }
public async Task UnBan(string uid) { var message = this.Context.Message as SocketUserMessage; var context = new SocketCommandContext(this.Context.Client, message); await context.Channel.SendMessageAsync($"Лошок с ID {uid} откинулся"); await ReadWriter.RemoveObj(Convert.ToUInt64(uid), "./ini/BanList"); }
/// <summary> /// Adds "types" using a string convention to be able to allow processing of the same class type in different ways. /// </summary> /// <param name="monitor"></param> /// <param name="t"></param> /// <param name="readWriter"></param> public static void addObjectCustomType(IMonitor monitor, string t, ReadWriter readWriter) { if (objectTypes.ContainsKey(t.ToString()) == false) { objectTypes.Add(t, readWriter); monitor.Log("Added custom supported type: " + t.ToString() + " to ModdedUtilitiesNetworking.", LogLevel.Info); } else { monitor.Log("Error custom adding supported type: " + t.ToString() + " to ModdedUtilitiesNetworking. Type already supported!", LogLevel.Alert); } }
public ApplicationViewModel() { db = new HoteldbContext(); dbSize = db.Hotels.Count(); Hotels = new ObservableCollection <HotelInfo>(); Cache = new Caching <HotelInfo>(); CacheList = new ObservableCollection <HotelInfo>(); Favorites = JDeserializer <ObservableCollection <HotelInfo> > .Deser(ReadWriter <ObservableCollection <HotelInfo> > .Read()) ?? new ObservableCollection <HotelInfo>(); }
public TCPClient() { readWriter = new SizeReadWriter(new PacketReadWriter( (packet) => { if (packet.packetID == PacketID.SyncTime || packet.packetID == PacketID.Pong) { StaticComponent <ServerTime> .Instance.OnRecvTimePacket(packet); } else { Debug.Log(string.Format("Recved Packet ID:{0} size:{1} msg:{2}", packet.packetID, packet.data.Length, Encoding.UTF8.GetString(packet.data))); RecvedPackets.Enqueue(packet); } })); }
public ApplicationViewModel() { db = new CompetitionsListsdbContext(); dbSize = db.CompetitionsLists.Count(); CompetitionsLists = new ObservableCollection <CompetitionsListInfo>(); Cache = new Caching <CompetitionsListInfo>(); CacheList = new ObservableCollection <CompetitionsListInfo>(); Favorites = JDeserializer <ObservableCollection <CompetitionsListInfo> > .Deser(ReadWriter <ObservableCollection <CompetitionsListInfo> > .Read()) ?? new ObservableCollection <CompetitionsListInfo>(); }
public ApplicationViewModel() { db = new PriorityproductsdbContext(); dbSize = db.Priorityproducts.Count(); Priorityproducts = new ObservableCollection <PriorityproductInfo>(); Cache = new Caching <PriorityproductInfo>(); CacheList = new ObservableCollection <PriorityproductInfo>(); Favorites = JDeserializer <ObservableCollection <PriorityproductInfo> > .Deser(ReadWriter <ObservableCollection <PriorityproductInfo> > .Read()) ?? new ObservableCollection <PriorityproductInfo>(); }
public SizeReadWriter(ReadWriter readWriter) { this.readWriter = readWriter; }
public static void Write(OutputModel outputModel, DatabasePlan databasePlan, PartitionPlan partitionPlan) { var s = $@" namespace {databasePlan.Namespace}; public class {partitionPlan.ClassName} : Cosmogenesis.Core.DbPartitionBase {{ protected virtual {databasePlan.Namespace}.{databasePlan.DbClassName} {databasePlan.DbClassName} {{ get; }} = default!; {PkClass(partitionPlan)} /// <summary>Mocking constructor</summary> protected {partitionPlan.ClassName}() {{ }} internal protected {partitionPlan.ClassName}( {new[] { ConstructorClassParameter(databasePlan), ConstructorKeyParameter(partitionPlan) }.Where(x => !string.IsNullOrEmpty(x)).JoinNonEmpty()}) : base( db: {databasePlan.DbClassNameArgument}, partitionKey: {partitionPlan.GetPkPlan.FullMethodName}({partitionPlan.GetPkPlan.DocumentToParametersMapping("pkData")}), serializer: {databasePlan.Namespace}.{databasePlan.SerializerClassName}.Instance) {{ this.{databasePlan.DbClassName} = {databasePlan.DbClassNameArgument} ?? throw new System.ArgumentNullException(nameof({databasePlan.DbClassNameArgument})); {PkClassSetter(partitionPlan)} }} {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName}? queryBuilder; /// <summary> /// Methods to build queries for later execution. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName} QueryBuilder => this.queryBuilder ??= new( {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, partitionKey: this.PartitionKey); {databasePlan.Namespace}.{partitionPlan.QueryClassName}? query; /// <summary> /// Methods to execute queries. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.QueryClassName} Query => this.query ??= new( {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, {partitionPlan.QueryBuilderClassNameArgument}: this.QueryBuilder); /// <summary> /// A batch of operations to be executed atomically (or not at all) within a {partitionPlan.Name} in the {databasePlan.Name} database. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CreateBatch() => new( transactionalBatch: this.CreateBatchForPartition(), partitionKey: this.PartitionKeyString, validateStateBeforeSave: this.{databasePlan.DbClassName}.ValidateStateBeforeSave, {partitionPlan.ClassNameArgument}: this); {databasePlan.Namespace}.{partitionPlan.ReadClassName}? read; /// <summary> /// Methods to read documents. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.ReadClassName} Read => this.read ??= new( {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, partitionKey: this.PartitionKey); {databasePlan.Namespace}.{partitionPlan.ReadOrThrowClassName}? readOrThrow; /// <summary> /// Methods to read documents, or throw DbConflictException is they are not found. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.ReadOrThrowClassName} ReadOrThrow => this.readOrThrow ??= new( {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, partitionKey: this.PartitionKey); {databasePlan.Namespace}.{partitionPlan.CreateClassName}? create; /// <summary> /// Methods to create documents. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.CreateClassName} Create => this.create ??= new(this); {databasePlan.Namespace}.{partitionPlan.ReadOrCreateClassName}? readOrCreate; /// <summary> /// Methods to read documents, or create them if they did not yet exist. /// </summary> public virtual {databasePlan.Namespace}.{partitionPlan.ReadOrCreateClassName} ReadOrCreate => this.readOrCreate ??= new(this); {ReadMany(databasePlan, partitionPlan)} {CreateOrReplace(databasePlan, partitionPlan)} {string.Concat(partitionPlan.Documents.Select(x => Create(partitionPlan, x)))} {string.Concat(partitionPlan.Documents.Select(x => CreateOrReplace(partitionPlan, x)))} {string.Concat(partitionPlan.Documents.Select(x => ReadOrCreate(partitionPlan, x)))} {string.Concat(partitionPlan.Documents.Select(ReplaceIfMutable))} {string.Concat(partitionPlan.Documents.Select(DeleteIfTransient))} }} "; outputModel.Context.AddSource($"partition_{partitionPlan.ClassName}.cs", s); BatchWriter.Write(outputModel, databasePlan, partitionPlan); CreateWriter.Write(outputModel, databasePlan, partitionPlan); ReadOrCreateWriter.Write(outputModel, databasePlan, partitionPlan); CreateOrReplaceWriter.Write(outputModel, databasePlan, partitionPlan); ReadWriter.Write(outputModel, databasePlan, partitionPlan); ReadOrThrowWriter.Write(outputModel, databasePlan, partitionPlan); ReadManyWriter.Write(outputModel, databasePlan, partitionPlan); QueryBuilderWriter.Write(outputModel, databasePlan, partitionPlan); QueryWriter.Write(outputModel, databasePlan, partitionPlan); }
public static void Main(string[] args) { var mostAndLeastCommon = ReadWriter.GetMostAndLeastCommonLetters(InputPath); ReadWriter.ReplaceMostRareLetter(mostAndLeastCommon, InputPath, OutputPath); }
static void Main(string[] args) { ReadWriter.ApplyConversion(inputPath, outputPath); }
public ApplicationViewModel() { db = new TransportNodesdbContext(); dbSize = db.TransportNodes.Count(); TransportNodes = new ObservableCollection <TransportNodeInfo>(); Cache = new Caching <TransportNodeInfo>(); CacheList = new ObservableCollection <TransportNodeInfo>(); Favorites = JDeserializer <ObservableCollection <TransportNodeInfo> > .Deser(ReadWriter <ObservableCollection <TransportNodeInfo> > .Read()) ?? new ObservableCollection <TransportNodeInfo>(); }
public ApplicationViewModel() { db = new FootballFieldsdbContext(); dbSize = db.FootballFields.Count(); FootballFields = new ObservableCollection <FootballFieldInfo>(); Cache = new Caching <FootballFieldInfo>(); CacheList = new ObservableCollection <FootballFieldInfo>(); Favorites = JDeserializer <ObservableCollection <FootballFieldInfo> > .Deser(ReadWriter <ObservableCollection <FootballFieldInfo> > .Read()) ?? new ObservableCollection <FootballFieldInfo>(); }