Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
        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;
        }
        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);
 }
 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!!");
     }
 }
Exemplo n.º 6
0
 /// <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;
 }
Exemplo n.º 7
0
        /// <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("<", "&lt;").Replace(">", "&gt;");
            }
            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;
        }
Exemplo n.º 8
0
 /// <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;
 }
Exemplo n.º 9
0
 public NameMasterRow()
 {
     _NameID = int.MinValue;
     _NameTypeID = NameTypes.Author;
     _LastName = _ForeName = _Initials = _DisplayName = string.Empty;
 }