private static void MakeIncrementalNameChanges(NameTypes oldStyle, NameTypes newStyle, Action <ExpressionSyntax> expressionValidator, bool topLevel = false, CSharpParseOptions options = null) { string oldName = GetNameString(oldStyle); string newName = GetNameString(newStyle); string code = oldName + @" m() {}"; if (!topLevel) { code = @"class C { " + code + @"}"; } else if (oldStyle == NameTypes.PointerName || newStyle == NameTypes.PointerName) { code = "unsafe " + code; } var oldTree = SyntaxFactory.ParseSyntaxTree(code, options: options); // Make the change to the node var newTree = oldTree.WithReplaceFirst(oldName, newName); var nameTree = topLevel ? GetGlobalMethodDeclarationSyntaxChange(newTree) : GetExpressionSyntaxChange(newTree); expressionValidator(nameTree); }
private static string GetNameString(NameTypes newStyle) { switch (newStyle) { case NameTypes.SingleName: return("abc"); case NameTypes.PredefinedName: return("int"); case NameTypes.PointerName: return("b*"); case NameTypes.GenericName: return("b<T>"); case NameTypes.DottedName: return("b.b"); case NameTypes.ArrayName: return("b[]"); case NameTypes.AliasedName: return("b::d"); default: throw new Exception("Unexpected type here!!"); } }
public Pathfinder_Name(NameTypes t, params string[] Names) : base() { nt = t; _names = Names; if ((t & NameTypes.Regex) != NameTypes.None) { _regexString = new Regex[Names.Length]; for (int i = 0; i < Names.Length; i++) { if (string.IsNullOrEmpty(Names[i])) { continue; } try { _regexString[i] = new Regex(Names[i], (t & NameTypes.CaseInsensitive) != NameTypes.None ? RegexOptions.IgnoreCase : RegexOptions.None); } catch { // User entered invalid regex pattern } } } else if ((t & NameTypes.CaseInsensitive) != NameTypes.None) { for (int i = 0; i < _names.Length; i++) { _names[i] = _names[i].ToLower(); } } }
public static T Receive(NameTypes pipeType) { using (var nps = new NamedPipeServerStream(pipeType.ToString(), PipeDirection.In)) { return(Receive(nps)); } }
public Categories(NameTypes categoryType) { CategoryViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <NameTypes>(categoryType); Messenger.Reset(); }
public static void Send(NameTypes pipeType, T t) { using (var npc = new NamedPipeClientStream(".", pipeType.ToString(), PipeDirection.Out)) { var bf = new BinaryFormatter(); npc.Connect(); bf.Serialize(npc, t); } }
public NamedPipe(NameTypes pipeType) { disposed = false; started = false; pipeName = pipeType.ToString(); thread = new Thread(Main); thread.SetApartmentState(ApartmentState.STA); thread.Name = $"NamePipe: {pipeType} Thread"; thread.IsBackground = true; }
public NamedPipe(NameTypes pipeType) { _disposed = false; _started = false; _pipeName = pipeType.ToString(); _thread = new Thread(Main); _thread.SetApartmentState(ApartmentState.STA); _thread.Name = "NamePipe: " + pipeType.ToString() + " Thread"; _thread.IsBackground = true; }
public AppState(string id, DirectoryInfo location, NameTypes nameTypes) { Id = string.IsNullOrWhiteSpace(id) ? "Unknown" : id; Location = location ?? new DirectoryInfo("."); NameTypes = nameTypes; CurrentNameType = nameTypes.IsSingleGender() ? nameTypes : NameTypes.Boys; Rnd = new MT19937Generator(); OwnBoyVetos = new List <Name>(Vetos.Load(Path.Combine(Location.FullName, Id + ".boys.vetos.txt")).Select(n => (Name)n)); OwnGirlVetos = new List <Name>(Vetos.Load(Path.Combine(Location.FullName, Id + ".girls.vetos.txt")).Select(n => (Name)n)); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="pKey">文字列キー</param> /// <param name="pJISX0213Level">JISX0213Levels</param> /// <param name="pNameType">NameTypes</param> /// <param name="pETax">true=e-Taxで利用可能</param> /// <param name="pGakunenbetuKanji">GakunenbetuKanjis</param> /// <param name="pNISA">true=NISAで利用可能</param> /// <param name="pELTAX">true=eLTAXで利用可能</param> public InfomationRecord(string pKey, JISX0213Levels pJISX0213Level, NameTypes pNameType, bool pETax, GakunenbetuKanjis pGakunenbetuKanji, bool pNISA, bool pELTAX) { this.KeyUnicodeString = pKey; this.JISX0213Level = pJISX0213Level; this.NameType = pNameType; this.ETaxAvailable = pETax; this.GakunenbetuKanji = pGakunenbetuKanji; this.NISAAvailable = pNISA; this.ELTAXAvailable = pELTAX; }
// ValidateName validates the entered name. The only check on this validation is that it cannot be empty. // The type parameter is passed to generate an applicable error message for the implementing party. public static string ValidateName(string enteredName, NameTypes type) { if (enteredName == "") { throw new InvalidInputException($"Provide {(type == NameTypes.Client ? "username" : "server name")}", $"Please provide a {(type == NameTypes.Client ? "username" : "server name")} in order to " + $"{(type == NameTypes.Client ? "connect to" : "start")} the server."); } return(enteredName); }
public KnownNetwork(string networkName, NameTypes type, DateTimeOffset firstConnect, DateTimeOffset lastConnect, bool managed, string dnsSuffix, string gatewayMacAddress, string profileGuid) { NetworkName = networkName; NameType = type; FirstConnect = firstConnect.DateTime; LastConnected = lastConnect.DateTime; Managed = managed; DNSSuffix = dnsSuffix; GatewayMacAddress = gatewayMacAddress; ProfileGUID = profileGuid; }
/** * @param prefix * Name prefix * @param first * First name * @param Middle * Middle name * @param last * Last name * @param suffix * Name suffix * @param raw * `raw` is an unparsed name like "Eric T Van Cartman", usefull * when you want to search by name and don't want to work hard to * parse it. Note that in response data there's never name.Raw, * the names in the response are always parsed, this is only for * querying with an unparsed name. * @param type * Type is one of "present", "maiden", "former", "alias", "autogenerated" or "alternative". * @param validSince * `validSince` is a <code>DateTime</code> object, it's the First * time Pipl's crawlers found this data on the page. */ public Name(string prefix = null, string first = null, string middle = null, string last = null, string suffix = null, string raw = null, NameTypes? type = null, DateTime? validSince = null) : base(validSince) { this.Prefix = prefix; this.First = first; this.Middle = middle; this.Last = last; this.Suffix = suffix; this.Raw = raw; this.Type = type; }
public static void Send(NameTypes pipeType, T t) { try { using (var npc = new NamedPipeClientStream(".", pipeType.ToString(), PipeDirection.Out)) { var bf = new BinaryFormatter(); npc.Connect(); bf.Serialize(npc, t); } } catch (UnauthorizedAccessException) { throw; } }
private Ranks GetRanks(NameTypes tp) { var votes = Location.EnumerateFiles(string.Format("*.{0}.xml", tp.ToString().ToLowerInvariant())); var vetos = Location.EnumerateFiles(string.Format("*.{0}.vetos.txt", tp.ToString().ToLowerInvariant())); var ranks = new Ranks( Names.FromDirectory(Location, tp).Distinct(), votes.SelectMany(file => Votes.Load(file)), vetos.SelectMany(file => Vetos.Load(file))) { NameType = tp }; ranks.Recalculate(); return(ranks); }
public static IEnumerable <Name> FromDirectory(DirectoryInfo directory, NameTypes types) { if (types.HasFlag(NameTypes.Boys)) { foreach (var boy in ReadNames(new FileInfo(Path.Combine(directory.FullName, "boys.txt")))) { yield return(boy); } } if (types.HasFlag(NameTypes.Girls)) { foreach (var girl in ReadNames(new FileInfo(Path.Combine(directory.FullName, "girls.txt")))) { yield return(girl); } } }
// ValidateIp validates the IP Address passed as a parameter. It validates if it is not empty and then it parses // it to a valid IP address. public static IPAddress ValidateIp(string enteredIp, NameTypes type) { IPAddress validatedIp; if (enteredIp == "") { throw new InvalidInputException("Provide server IP", $"Please provide a server IP in order to {(type == NameTypes.Client ? "connect to" : "start")} the server."); } if (IPAddress.TryParse(enteredIp, out validatedIp) == false) { throw new InvalidInputException("Invalid server ip", "The IP Address you entered was invalid."); } return(validatedIp); }
public void UpdateCurrentNameType() { if (NameTypes.IsSingleGender()) { return; } if (Rnd.NextDouble() < 0.8) { return; } if (CurrentNameType == NameTypes.Boys) { CurrentNameType = NameTypes.Girls; } else { CurrentNameType = NameTypes.Boys; } }
private static void MakeIncrementalNameChange( NameTypes oldStyle, NameTypes newStyle, Action <ExpressionSyntax> expressionValidator ) { MakeIncrementalNameChanges(oldStyle, newStyle, expressionValidator); MakeIncrementalNameChanges( oldStyle, newStyle, expressionValidator, options: TestOptions.Script ); MakeIncrementalNameChanges( oldStyle, newStyle, expressionValidator, topLevel: true, options: TestOptions.Script ); }
private static bool Login(string id, DirectoryInfo location, NameTypes nameTypes) { Console.WriteLine("Select names for {0}", nameTypes); Console.WriteLine("Format: {0}", Config.Format); Console.Write("User ID: {0}", id); if (string.IsNullOrWhiteSpace(id)) { Console.WriteLine("{empty}"); return(false); } else { Console.WriteLine(); } Console.WriteLine("Files location: {0}{1}", location, location.Exists ? "" : "*"); if (!location.Exists) { location.Create(); } Console.WriteLine(); Console.WriteLine("ready?"); Console.ReadLine(); return(true); }
/// <summary> /// Formats the author. /// </summary> /// <param name="authors">The authors.</param> /// <param name="authorTemplate">The author template.</param> /// <param name="nametype">The nametype.</param> /// <returns></returns> public static string FormatPublisher(List<NameMasterRow> authors, Publisher publisherTemplate, NameTypes nametype, bool bInHtmlFormat) { string text = string.Empty; List<NameMasterRow> listAuthors = new List<NameMasterRow>(); foreach (NameMasterRow author in authors) { if (author.NameTypeID == nametype) listAuthors.Add(author); } int count = listAuthors.Count; for (int i = 0; i < count; i++) { text += listAuthors[i].LastName; } text = ApplyStandardFormat(publisherTemplate, text, bInHtmlFormat); return text; }
/// <summary> /// 常用・人名用漢字種類設定 /// </summary> /// <param name="pType">NameTypes</param> public void SetNameType(NameTypes pType) { this.NameType = pType; }
static PeopleNames MakePerson(List <string> personColumns) { PeopleNames Person = new PeopleNames(); Person.nafn = personColumns.ElementAt(0); string afgrtt = personColumns.ElementAt(1); if (afgrtt == "Sam") { Person.afgreitt = true; } else if (afgrtt == "Haf") { Person.afgreitt = false; } else { // Console.WriteLine("ERROR IN -AFGREITT-"); } int brta = int.MaxValue; try { brta = Int32.Parse(personColumns.ElementAt(2).Substring(0, 1)); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }; Person.birta = brta; string tegnd = personColumns.ElementAt(3).ToUpper(); NameTypes n = new NameTypes(); switch (tegnd) { case "DR": n = NameTypes.DR; break; case "MI": n = NameTypes.MI; break; case "RDR": n = NameTypes.RDR; break; case "ST": n = NameTypes.ST; break; case "RST": n = NameTypes.RST; break; default: Console.WriteLine("ERROR IN TEGUND"); break; } Person.tegund = n; Person.skyring = personColumns.ElementAt(4); Person.urskurdur = personColumns.ElementAt(5); Person.ID = int.Parse(personColumns.ElementAt(6).Split(',')[0]); return(Person); }
public IClusterManagedName CreateNewNameOfType([DefaultValue(NameTypes.WesternName)] NameTypes ofType) { //Ignoring ofType for the moment as there is only one impl. return(Container.NewTransientInstance <WesternName>()); }
private string ParseName(string name, NameTypes nameType) { int spaceIndex = name.IndexOf(' ', 0); switch (nameType) { case NameTypes.FirstName: return spaceIndex > 0 ? name.Substring(0, spaceIndex) : name; case NameTypes.LastName: return spaceIndex > 0 ? name.Substring(spaceIndex) : string.Empty; } return string.Empty; }
public static FileInfo GetFile(DirectoryInfo root, NameTypes tp, string id) { var fileName = string.Format("{0}.{1}.vetos.txt", id, tp.ToString().ToLowerInvariant()); return(new FileInfo(Path.Combine(root.FullName, fileName))); }
public static bool IsSingleGender(this NameTypes tp) => tp == NameTypes.Boys || tp == NameTypes.Girls;
/// <summary> /// Return number of authors with provided NameType /// </summary> /// <param name="authors">Author list</param> /// <param name="nametype">NameType</param> /// <returns></returns> public static int CountAuthor(List<NameMasterRow> authors, NameTypes nametype) { int num = 0; foreach (NameMasterRow name in authors) { if (name.NameTypeID == nametype) num++; } return num; }
private static void MakeIncrementalNameChanges(NameTypes oldStyle, NameTypes newStyle, Action<ExpressionSyntax> expressionValidator, bool topLevel = false, CSharpParseOptions options = null) { string oldName = GetNameString(oldStyle); string newName = GetNameString(newStyle); string code = oldName + @" m() {}"; if (!topLevel) { code = @"class C { " + code + @"}"; } else if (oldStyle == NameTypes.PointerName || newStyle == NameTypes.PointerName) { code = "unsafe " + code; } var oldTree = SyntaxFactory.ParseSyntaxTree(code, options: options); // Make the change to the node var newTree = oldTree.WithReplaceFirst(oldName, newName); var nameTree = topLevel ? GetGlobalMethodDeclarationSyntaxChange(newTree) : GetExpressionSyntaxChange(newTree); expressionValidator(nameTree); }
private static void MakeIncrementalNameChange(NameTypes oldStyle, NameTypes newStyle, Action<ExpressionSyntax> expressionValidator) { MakeIncrementalNameChanges(oldStyle, newStyle, expressionValidator); MakeIncrementalNameChanges(oldStyle, newStyle, expressionValidator, options: TestOptions.Script); MakeIncrementalNameChanges(oldStyle, newStyle, expressionValidator, topLevel: true, options: TestOptions.Script); }
/// <summary> /// Formats the author. /// </summary> /// <param name="authors">The authors.</param> /// <param name="nametype">The nametype.</param> /// <returns></returns> public static string FormatAuthor(List<NameMasterRow> authors, Author authorTemplate, NameTypes nametype, bool bIsInHtmlFormat) { string text = string.Empty; string strFollowedBy = string.Empty; List<NameMasterRow> listAuthors = new List<NameMasterRow>(); foreach (NameMasterRow author in authors) { if (author.NameTypeID == nametype) { if(author.LastName.Length > 0) listAuthors.Add(author); } } int count = listAuthors.Count; if (count >= authorTemplate.MaxAuthors) { if (count > authorTemplate.ListAuthors) count = authorTemplate.ListAuthors; } for (int i = 0; i < count; i++) { AuthorFormat formatIndex = authorTemplate.OtherAuthors; if (i == 0) formatIndex = authorTemplate.FirstAuthor; if (text.Length > 0) { if (i < count - 1) text += CitationTools.GetAuthorDelimitor(authorTemplate.BetweenAuthors); else text += authorTemplate.BeforeLast; } string authorname = CitationTools.FormatName(listAuthors[i], formatIndex); switch (authorTemplate.Capitalization) { case Capitalization.AsIs: break; case Capitalization.FirstIsCapital: authorname = authorname.Substring(0, 1).ToUpper() + authorname.Substring(1).ToLower(); break; case Capitalization.AllCapital: authorname = authorname.ToUpper(); break; } text += authorname.Replace("<", "<").Replace(">", ">"); } if (listAuthors.Count >= authorTemplate.MaxAuthors) { if (authorTemplate.FollowedBy_Italic) { if(bIsInHtmlFormat) text += "<i>" + authorTemplate.FollowedBy + "</i>"; else strFollowedBy = GetWordMLFormatString(authorTemplate.FollowedBy, TextFormat.Italic); } else text += authorTemplate.FollowedBy; } text = ApplyStandardFormat(authorTemplate, text, bIsInHtmlFormat, strFollowedBy, false); return text; }
private static string GetNameString(NameTypes newStyle) { switch (newStyle) { case NameTypes.SingleName: return "abc"; case NameTypes.PredefinedName: return "int"; case NameTypes.PointerName: return "b*"; case NameTypes.GenericName: return "b<T>"; case NameTypes.DottedName: return "b.b"; case NameTypes.ArrayName: return "b[]"; case NameTypes.AliassedName: return "b::d"; default: throw new Exception("Unexpected type here!!"); } }
public NameMasterRow() { _NameID = int.MinValue; _NameTypeID = NameTypes.Author; _LastName = _ForeName = _Initials = _DisplayName = string.Empty; }