Exemplo n.º 1
0
        private void ParseName()
        {
            if (CompleteName.Length == 0 || !CompleteName.Contains("/"))
            {
                Name = CompleteName;
                return;
            }
            if (IsRemote)
            {
                Name = CompleteName.Substring(CompleteName.LastIndexOf("remotes/") + 8);
                return;
            }
            if (IsTag)
            {
                // we need the one containing ^{}, because it contains the reference
                var temp =
                    CompleteName.Contains("^{}")
                        ? CompleteName.Substring(0, CompleteName.Length - 3)
                        : CompleteName;

                Name = temp.Substring(CompleteName.LastIndexOf("tags/") + 5);
                return;
            }
            if (IsHead)
            {
                Name = CompleteName.Substring(CompleteName.LastIndexOf("heads/") + 6);
                return;
            }
            Name = CompleteName.Substring(CompleteName.LastIndexOf("/") + 1);
        }
Exemplo n.º 2
0
        private void ParseName()
        {
            if (IsRemote)
            {
                Name = CompleteName.Substring(CompleteName.LastIndexOf("remotes/") + 8);
            }
            else if (IsTag)
            {
                // we need the one containing ^{}, because it contains the reference
                var temp =
                    CompleteName.Contains(TagDereferenceSuffix)
                        ? CompleteName.Substring(0, CompleteName.Length - TagDereferenceSuffix.Length)
                        : CompleteName;

                Name = temp.Substring(CompleteName.LastIndexOf("tags/") + 5);
            }
            else if (IsHead)
            {
                Name = CompleteName.Substring(CompleteName.LastIndexOf("heads/") + 6);
            }
            else
            {
                //if we don't know ref type then we don't know if '/' is a valid ref character
                Name = CompleteName.SkipStr("refs/");
            }

            if (Name.IsNullOrWhiteSpace())
            {
                Name = CompleteName;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="completeName">
 /// <see cref="Microsoft.Phone.UserData.CompleteName">CompleteName</see> object
 /// </param>
 public W3ContactName(CompleteName completeName)
 {
     this.FirstName  = completeName.FirstName;
     this.MiddleName = completeName.MiddleName;
     this.LastName   = completeName.LastName;
     this.Prefix     = completeName.Title;
     this.Suffix     = completeName.Suffix;
 }
Exemplo n.º 4
0
    void Start()
    {
        str          = textMesh.text;
        nameOfPlayer = GetName.playerName;
        //counter = BallController.count;
        flag = 0;

        cn = GameObject.FindGameObjectWithTag("Viewer").GetComponent <CompleteName>();
        //correctWord = "";
    }
Exemplo n.º 5
0
        private Dictionary <string, List <ContactInfo> > GetContactListMap(IEnumerable <Contact> contacts)
        {
            int count      = 0;
            int duplicates = 0;
            Dictionary <string, List <ContactInfo> > contactListMap = null;

            if (contacts == null)
            {
                return(null);
            }
            contactListMap = new Dictionary <string, List <ContactInfo> >();
            foreach (Contact cn in contacts)
            {
                CompleteName cName = cn.CompleteName;

                foreach (ContactPhoneNumber ph in cn.PhoneNumbers)
                {
                    if (string.IsNullOrWhiteSpace(ph.PhoneNumber)) // if no phone number simply ignore the contact
                    {
                        count++;
                        continue;
                    }
                    ContactInfo cInfo = new ContactInfo(null, cn.DisplayName.Trim(), ph.PhoneNumber);
                    int         idd   = cInfo.GetHashCode();
                    cInfo.Id    = Convert.ToString(Math.Abs(idd));
                    contactInfo = cInfo;
                    if (contactListMap.ContainsKey(cInfo.Id))
                    {
                        if (!contactListMap[cInfo.Id].Contains(cInfo))
                        {
                            contactListMap[cInfo.Id].Add(cInfo);
                        }
                        else
                        {
                            duplicates++;
                            Debug.WriteLine("Duplicate Contact !! for Phone Number {0}", cInfo.PhoneNo);
                        }
                    }
                    else
                    {
                        List <ContactInfo> contactList = new List <ContactInfo>();
                        contactList.Add(cInfo);
                        contactListMap.Add(cInfo.Id, contactList);
                    }
                }
            }
            Debug.WriteLine("Total duplicate contacts : {0}", duplicates);
            Debug.WriteLine("Total contacts with no phone number : {0}", count);
            return(contactListMap);
        }
Exemplo n.º 6
0
        Task <Tuple <string, string> > SearchContactInUserDataAsync(string filter)
        {
            TaskCompletionSource <Tuple <string, string> > tcs =
                new TaskCompletionSource <Tuple <string, string> >();
            Tuple <string, string> result = null;
            EventHandler <MowblyContactsSearchEventArgs> OnContactsSearchCompleted = (sender, e) =>
            {
                if (e.Status)
                {
                    Contact c = e.Contacts.FirstOrDefault();
                    // Param can be Phone or Email or Name
                    ContactPhoneNumber phone = c.PhoneNumbers.FirstOrDefault();
                    if (phone != null)
                    {
                        result = Tuple.Create <string, string>(phone.PhoneNumber, phone.Kind.ToString());
                    }
                    else
                    {
                        ContactEmailAddress email = c.EmailAddresses.FirstOrDefault();
                        if (email != null)
                        {
                            result = Tuple.Create <string, string>(email.EmailAddress, email.Kind.ToString());
                        }
                        else
                        {
                            CompleteName name = c.CompleteName;
                            if (name != null)
                            {
                                result = Tuple.Create <string, string>(name.FirstName, "name");
                            }
                        }
                    }
                }
                tcs.SetResult(result);
            };

            SearchContactInUserDataAsync(filter, OnContactsSearchCompleted);

            return(tcs.Task);
        }
Exemplo n.º 7
0
        private async static Task TryInitPlayers(ApplicationDbContext context)
        {
            if (await context.Players.AnyAsync())
            {
                return;
            }

            var team = await context.Teams.FirstOrDefaultAsync();

            var francoNameResult    = CompleteName.Create("Franco", "Armani");
            var quinterosNameResult = CompleteName.Create("Franco", "Armani");

            var francoEmail    = Email.Create("*****@*****.**");
            var quinterosEmail = Email.Create("*****@*****.**");

            await context.Players.AddRangeAsync(new List <Player>()
            {
                new Player(francoNameResult.Value, new DateTime(1986, 10, 16), francoEmail.Value, "1132123123", team),
                new Player(quinterosNameResult.Value, new DateTime(1993, 1, 18), quinterosEmail.Value, "1132123123", team)
            });

            await context.SaveChangesAsync();
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([FromBody] PlayerCreateDto player)
        {
            var team = await _teamRepository.GetByIdAsync(player.TeamId);

            if (team == null)
            {
                return(BadRequest($"Invalid country Id { player.TeamId }"));
            }

            if (await _playerRepository.ExistAsync(p => p.Email == player.Email))
            {
                return(BadRequest($"Invalid email - It is already registered in the system"));
            }

            var completeNameResult = CompleteName.Create(player.FirstName, player.LastName);

            if (completeNameResult.IsFailure)
            {
                return(BadRequest(completeNameResult.Error));
            }

            var emailResult = Email.Create(player.Email);

            if (emailResult.IsFailure)
            {
                return(BadRequest(emailResult.Error));
            }

            var newPlayer = new Player(completeNameResult.Value, player.BirthDate, emailResult.Value, player.Phone, team);

            await _playerRepository.AddAsync(newPlayer);

            await _unitOfWork.Commit();

            return(Ok());
        }
        private void OnContactsSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                IEnumerator <Contact> contacts = e.Results.GetEnumerator();
                if (contacts.MoveNext())
                {
                    Contact contact = contacts.Current;
                    List <ContactDetail> details = new List <ContactDetail>();
                    ContactDetail.Type   type;
                    string value;
                    string kind;

                    // Name & NickName
                    CompleteName name = contact.CompleteName;
                    if (name != null)
                    {
                        string cName = name.Title + " " + name.FirstName + " " + name.MiddleName + " " + name.LastName;
                        ContactName.Text = cName.ToUpper();
                    }
                    else
                    {
                        ContactName.Text = contact.DisplayName;
                    }

                    // Photos
                    Stream stream = contact.GetPicture();
                    if (stream == null)
                    {
                        Picture.Visibility = System.Windows.Visibility.Collapsed;
                    }
                    else
                    {
                        BitmapImage img = new BitmapImage();
                        img.SetSource(stream);
                        Picture.Source = img;
                    }

                    // Phones
                    type = ContactDetail.Type.Phone;
                    foreach (ContactPhoneNumber phoneNumber in contact.PhoneNumbers)
                    {
                        if (phoneNumber.PhoneNumber != null)
                        {
                            value = phoneNumber.PhoneNumber;
                            kind  = phoneNumber.Kind.ToString();
                            details.Add(new ContactDetail(type, value, kind));

                            // Sms, if mobile
                            if (phoneNumber.Kind == PhoneNumberKind.Mobile)
                            {
                                details.Add(new ContactDetail(ContactDetail.Type.Sms, value, kind));
                            }
                        }
                    }

                    // Urls
                    type = ContactDetail.Type.Website;
                    foreach (string website in contact.Websites)
                    {
                        value = website;
                        kind  = String.Empty;
                    }

                    // Emails
                    type = ContactDetail.Type.Email;
                    foreach (ContactEmailAddress email in contact.EmailAddresses)
                    {
                        value = email.EmailAddress;
                        kind  = email.Kind.ToString().ToLower();

                        details.Add(new ContactDetail(type, value, kind));
                    }

                    // Organizations
                    IEnumerator <ContactCompanyInformation> companies = contact.Companies.GetEnumerator();
                    ContactCompanyInformation company;
                    while (companies.MoveNext())
                    {
                        company = (ContactCompanyInformation)companies.Current;

                        if (company.CompanyName != null)
                        {
                            type  = ContactDetail.Type.Company;
                            value = company.CompanyName;
                            kind  = String.Empty;
                            details.Add(new ContactDetail(type, value, kind));
                        }

                        if (company.JobTitle != null)
                        {
                            type  = ContactDetail.Type.JobTitle;
                            value = company.JobTitle;
                            kind  = String.Empty;
                            details.Add(new ContactDetail(type, value, kind));
                        }
                    }

                    // Address
                    type = ContactDetail.Type.Address;
                    foreach (ContactAddress address in contact.Addresses)
                    {
                        CivicAddress ca = address.PhysicalAddress;
                        // Street, City, PostalCode, Region, Country
                        value = ca.AddressLine1 + " " + ca.AddressLine2 + " " + ca.Building + "\n" +
                                ca.City + " " + ca.StateProvince + " " + ca.PostalCode + "\n" +
                                ca.CountryRegion;
                        kind = address.Kind.ToString();

                        details.Add(new ContactDetail(type, value, kind));
                    }

                    // Display the data
                    DetailsList.DataContext = details;
                }
                else
                {
                    ContactName.Text        = Mowbly.GetString(Constants.STRING_CONTACT_NOT_FOUND);
                    ContactAccounts.Text    = "";
                    Picture.Visibility      = System.Windows.Visibility.Collapsed;
                    DetailsList.DataContext = null;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to view contact.Reason: " + ex.Message);
            }
        }
Exemplo n.º 10
0
 public User(CompleteName completeName, Cpf cpf)
 {
     CompleteName = completeName;
     Cpf          = cpf;
 }