Exemplo n.º 1
0
        public void IgnoreDisabledDataItems()
        {
            AddressBookEntry entry = new AddressBookEntry();

            entry.FirstName = "John";
            entry.LastName  = "Doe";
            entry.Data.Add(new EntryDataItem()
            {
                Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject()
                {
                    Loop = "123"
                }
            });
            // This item shall be ignored when retrieving all data items.
            entry.Data.Add(new EntryDataItem()
            {
                Identifier = LoopEntryObject.TypeId, IsEnabled = false, Data = new LoopEntryObject()
                {
                    Loop = "i'm being ignored"
                }
            });

            var result = entry.GetDataItems <LoopEntryObject>(LoopEntryObject.TypeId).ToList();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("123", result[0].Loop);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Occurs when an address book entry has be retrieved.
 /// </summary>
 /// <param name="entry">The address book entry that was retrieved.</param>
 protected virtual void OnAddressBookEntryRetrieved(AddressBookEntry entry)
 {
     if (AddressBookEntryRetrieved != null)
     {
         AddressBookEntryRetrieved(this, entry);
     }
 }
Exemplo n.º 3
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            string name        = TxtName.TryGetText();
            string surname     = TxtSurname.TryGetText();
            string phoneNumber = TxtPhoneText.TryGetText();

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(phoneNumber))
            {
                //TODO perform something useful
                return;
            }
            else if (name.Contains(",") || surname.Contains(",") || phoneNumber.Contains(","))
            {
                //TODO perform something useful pt2
                return;
            }
            else
            {
                AddressBookEntry entry = new AddressBookEntry()
                {
                    Name        = name,
                    Surname     = surname,
                    PhoneNumber = phoneNumber
                };
                NetworkManager.Instance.SendNewAddressBookEntry(entry, bookName);
                NetworkManager.Instance.Receive();
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Email,Avatar,FileName,Adress1,Address2,City,ZipCode,Phone,DateAdded")] AddressBookEntry addressBookEntry)
        {
            if (id != addressBookEntry.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(addressBookEntry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AddressBookEntryExists(addressBookEntry.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(addressBookEntry));
        }
Exemplo n.º 5
0
        public void Ctor()
        {
            var entry = new AddressBookEntry();

            Assert.That(entry.SerializedEndpoint, Is.Null);
            Assert.That(entry.Signature, Is.Null);
        }
        /// <summary>
        /// Determines whether there are any recipient-specific settings that
        /// mean the message should not go through mail filtering.
        /// </summary>
        /// <param name="sender">The address of the sender.</param>
        /// <param name="recipient">The address of the recipient.</param>
        /// <param name="server">The server instance.</param>
        /// <returns>Whether the sender is a safe sender.</returns>
        private bool ShouldBypassFilter(RoutingAddress sender, RoutingAddress recipient, SmtpServer server)
        {
            if (server == null || sender == null || recipient == null)
            {
                return(false);
            }

            AddressBook addressBook = server.AddressBook;

            if (addressBook != null)
            {
                AddressBookEntry addressBookEntry = addressBook.Find(recipient);
                if (addressBookEntry != null)
                {
                    if (addressBookEntry.AntispamBypass ||
                        addressBookEntry.IsSafeSender(sender) ||
                        addressBookEntry.IsSafeRecipient(recipient))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public IActionResult AddAddress([FromBody] AddressBookEntryRequest request)
        {
            Guard.NotNull(request, nameof(request));

            // Checks the request is valid.
            if (!this.ModelState.IsValid)
            {
                return(ModelStateErrors.BuildErrorResponse(this.ModelState));
            }

            try
            {
                AddressBookEntry item = this.addressBookManager.AddNewAddress(request.Label, request.Address);

                return(this.Json(new AddressBookEntryModel {
                    Label = item.Label, Address = item.Address
                }));
            }
            catch (AddressBookException e)
            {
                this.logger.LogError("Exception occurred: {0}", e.ToString());
                return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.Conflict, e.Message, e.ToString()));
            }
            catch (Exception e)
            {
                this.logger.LogError("Exception occurred: {0}", e.ToString());
                return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "There was a problem adding an address to the address book.", e.ToString()));
            }
        }
Exemplo n.º 8
0
        public void Ctor()
        {
            var entry = new AddressBookEntry();

            Assert.Null(entry.SerializedEndpoint);
            Assert.Null(entry.Signature);
        }
Exemplo n.º 9
0
        private AddressBookEntry ConvertFromAddressBook(ABPerson from)
        {
            AddressBookEntry entry = new AddressBookEntry();

            entry.ExternalContactId     = from.Id.ToString();
            entry.ExternalContactSource = Constants.ExternalContactSource;
            entry.IsCompany             = this.IsCompany(from);
            entry.FirstName             = from.FirstName;
            entry.LastName    = from.LastName;
            entry.CompanyName = from.Organization;
            entry.ExternalModificationDate = this.ToDateTime(from.ModificationDate);

            if (from.HasImage)
            {
                NSData imageData = from.GetImage(ABPersonImageFormat.OriginalSize);
                byte[] image     = new byte[imageData.Length];

                Marshal.Copy(imageData.Bytes, image, 0, Convert.ToInt32(imageData.Length));

                entry.Image = image;
            }

            List <KeyValuePair <string, Address> > addresses = new List <KeyValuePair <string, Address> >();

            foreach (ABMultiValueEntry <PersonAddress> address in from.GetAllAddresses())
            {
                Address newAddress = new Address();

                newAddress.Street     = address.Value.Street;
                newAddress.City       = address.Value.City;
                newAddress.Province   = address.Value.State;
                newAddress.PostalCode = address.Value.Zip;
                newAddress.Country    = address.Value.Country;

                addresses.Add(new KeyValuePair <string, Address>(this.NormalizeLabel(address.Label), newAddress));
            }

            entry.Addresses = addresses;

            List <KeyValuePair <string, string> > emailAddresses = new List <KeyValuePair <string, string> >();

            foreach (ABMultiValueEntry <string> emailAddress in from.GetEmails())
            {
                emailAddresses.Add(new KeyValuePair <string, string>(this.NormalizeLabel(emailAddress.Label), emailAddress.Value));
            }

            entry.EmailAddresses = emailAddresses;

            List <KeyValuePair <string, string> > phoneNumbers = new List <KeyValuePair <string, string> >();

            foreach (ABMultiValueEntry <string> phoneNumber in from.GetPhones())
            {
                phoneNumbers.Add(new KeyValuePair <string, string>(this.NormalizeLabel(phoneNumber.Label), phoneNumber.Value));
            }

            entry.PhoneNumbers = phoneNumbers;

            return(entry);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry()
            {
                Address   = "123 Coder ln",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44850",
                FirstName = "Paul",
                LastName  = "O'Connor",
                Age       = 40,
            };

            AddressBookEntry John = new AddressBookEntry()
            {
                Address   = "456 Dirt Road",
                City      = "Eastfield",
                State     = "IN",
                Zip       = "44550",
                FirstName = "John",
                LastName  = "Doe",
                Age       = 30,
            };

            AddressBookEntry Daniel = new AddressBookEntry()
            {
                Address   = "321",
                City      = "Mishawaka",
                State     = "IN",
                Zip       = "44456",
                FirstName = "Daniel",
                LastName  = "Schroeder",
                Age       = 32,
            };

            AddressBookEntry Bob = new AddressBookEntry()
            {
                Address   = "789 Visual ln",
                City      = "Northfield",
                State     = "IN",
                Zip       = "44660",
                FirstName = "Bob",
                LastName  = "Smith",
                Age       = 50,
            };

            //Create 3 more Address Book entries !!DONE
            //Create a constructor in the AddressBook Entry where a user has to pass in
            //3 parameters: FirstName, LastName, Age

            Console.WriteLine(Paul.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(John.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(Daniel.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(Bob.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry()
            {
                Address   = "123 Coder Pl",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Conner",
                Age       = 40
            };

            AddressBookEntry Mizhcel = new AddressBookEntry()
            {
                Address   = "8882 Foret Ln",
                City      = "Chainchest",
                State     = "IN",
                Zip       = "44913",
                FirstName = "Mizhcel",
                LastName  = "Blokz",
                Age       = 36
            };

            AddressBookEntry Darth = new AddressBookEntry()
            {
                Address   = "223 DeathStar Ln",
                City      = "San Fran",
                State     = "CA",
                Zip       = "88888",
                FirstName = "Darth",
                LastName  = "Vader",
                Age       = 37
            };
            AddressBookEntry Defult = new AddressBookEntry()
            {
                Address   = "123 abc Ln",
                City      = "New York City",
                State     = "NY",
                Zip       = "123456",
                FirstName = "First Name",
                LastName  = "Last Name",
                Age       = 35
            };

            Console.WriteLine("Enter First Name");
            string fName = Console.ReadLine();

            Console.WriteLine("Enter Last Name");
            string lName = Console.ReadLine();

            Console.WriteLine("Enter Age");
            int age = Int32.Parse(Console.ReadLine());

            Defult.ChangeEntry(fName, lName, age);

            Console.WriteLine("Name: {0} {1}\nAge: {2}", Defult.FirstName, Defult.LastName, Defult.Age);
            Console.ReadLine();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Compares two objects and breaks the data integrity seal if the objects are not equal.
 /// </summary>
 protected AddressBookEntry PokeSeal(AddressBookEntry OldValue, AddressBookEntry NewValue)
 {
     if (OldValue != NewValue)
     {
         BreakSeal();
     }
     return(NewValue);
 }
Exemplo n.º 13
0
		public void PropertySetGet() {
			var serializedEndpoint = new byte[] { 0x1, 0x2 };
			var signature = new byte[] { 0x3, 0x4 };
			var entry = new AddressBookEntry() {
				SerializedEndpoint = serializedEndpoint,
				Signature = signature,
			};
			Assert.That(entry.SerializedEndpoint, Is.EqualTo(serializedEndpoint));
			Assert.That(entry.Signature, Is.EqualTo(signature));
		}
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry()
            {
                Address   = "123 Coder pl",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Conner",
                Age       = 40
            };

            AddressBookEntry Tommy = new AddressBookEntry()
            {
                Address   = "Meridian st",
                City      = "Indidanpolis",
                State     = "IN",
                Zip       = "46217",
                FirstName = "Tommy",
                LastName  = "Hurly",
                Age       = 21
            };

            AddressBookEntry Billy = new AddressBookEntry()
            {
                Address   = "Washington st",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44105",
                FirstName = "Billy",
                LastName  = "Hurly",
                Age       = 23
            };

            AddressBookEntry Bre = new AddressBookEntry()
            {
                Address   = "123 Coder pl",
                City      = "Mcaster",
                State     = "IN",
                Zip       = "4305",
                FirstName = "Breeanna",
                LastName  = "Elliott",
                Age       = 21
            };

            Console.WriteLine(Paul.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(Billy.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(Tommy.GetAddress());
            Console.WriteLine("");
            Console.WriteLine(Bre.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Email,Avatar,FileName,Adress1,Address2,City,ZipCode,Phone,DateAdded")] AddressBookEntry addressBookEntry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(addressBookEntry);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(addressBookEntry));
        }
        public void Update(AddressBookEntry addressBookEntry)
        {
            var entry = Load(addressBookEntry.Id);

            if (entry == null)
            {
                throw new ArgumentException();
            }

            _session.GetAddressBookEntries().Remove(entry);
            _session.GetAddressBookEntries().Add(addressBookEntry);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Adds a user to the directory.
        /// </summary>
        /// <param name="name">The full name of th user.</param>
        /// <param name="userCode">The authentication code used for the user.</param>
        /// <param name="displayName">The display name on the copier control panel for the user.</param>
        /// <param name="emailAddress">The email address of the user to add.</param>
        /// <param name="options">Allows for additional processing and manipulation to occur before adding the user. Requires internal knowledge of the external service proxy.</param>
        /// <returns>The index of the newly created user.</returns>
        public uint AddUser(string name, string userCode, string displayName, string emailAddress = null, Action <AddressBookEntry> options = null)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name must not be empty or null.", name);
            }

            AddressBookEntry entry = new AddressBookEntry(RicohEntryType.User)
            {
                Name = name
            };

            if (!String.IsNullOrEmpty(userCode))
            {
                entry.Usercode = userCode;
            }
            if (!String.IsNullOrEmpty(displayName))
            {
                entry.DisplayName = displayName;
            }
            if (!String.IsNullOrEmpty(emailAddress))
            {
                entry.EmailAddress = emailAddress;
            }

            return(Connect(() => {
                property[] defaultProperties = new[] {
                    new property()
                    {
                        propName = "isDestination", propVal = "true"
                    },
                    new property()
                    {
                        propName = "isSender", propVal = "true"
                    },
                };
                try {
                    if (options != null)
                    {
                        options.Invoke(entry);
                    }

                    var properties = PrepareProperties(defaultProperties.Concat(entry.ToProperties()));
                    var result = Client.putObjects(SessionId, "entry", null, new property[][] { properties }, null);
                    return (result.Length > 0 ? Convert.ToUInt32(result[0]) : 0);
                }
                catch (FaultException ex) {
                    // TODO: Need to inspect the returned XML message from the server to check for UDIRECTORY_DIRECTORY_INCONSISTENT
                    Trace.TraceError("Failed to add the address book entry for: {0} [{1}]. Possibly duplicate usercode?", entry.DisplayName, entry.Usercode);
                    return ((uint)0);
                }
            }, RicohSessionType.ExclusiveSession));
        }
Exemplo n.º 18
0
        bool IAddressFilter.QueryAcceptEntry(Operation operation, AddressBookEntry entry)
        {
            if (operation.Loops.Count == 0)
            {
                return true;
            }

            IEnumerable<LoopEntryObject> leo = entry.GetDataItems<LoopEntryObject>(LoopEntryObject.TypeId);
            IEnumerable<string> loops = leo.Select(eo => eo.Loop);

            return loops.Intersect(operation.Loops).Any();
        }
Exemplo n.º 19
0
        public void PropertySetGet()
        {
            var serializedEndpoint = new byte[] { 0x1, 0x2 };
            var signature          = new byte[] { 0x3, 0x4 };
            var entry = new AddressBookEntry()
            {
                SerializedEndpoint = serializedEndpoint,
                Signature          = signature,
            };

            Assert.That(entry.SerializedEndpoint, Is.EqualTo(serializedEndpoint));
            Assert.That(entry.Signature, Is.EqualTo(signature));
        }
Exemplo n.º 20
0
        public void IgnoreDisabledDataItems()
        {
            AddressBookEntry entry = new AddressBookEntry();
            entry.FirstName = "John";
            entry.LastName = "Doe";
            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject() { Loop = "123" } });
            // This item shall be ignored when retrieving all data items.
            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = false, Data = new LoopEntryObject() { Loop = "i'm being ignored" } });

            var result = entry.GetDataItems<LoopEntryObject>(LoopEntryObject.TypeId).ToList();
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("123", result[0].Loop);
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry()
            {
                Address   = "123 Coder Place",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Connor",
                Age       = 40
            };
            AddressBookEntry Sue = new AddressBookEntry()
            {
                Address   = "987 Coder Street",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Sue",
                LastName  = "Pickles",
                Age       = 30
            };
            AddressBookEntry Jon = new AddressBookEntry()
            {
                Address   = "999 Main Street",
                City      = "Indy",
                State     = "IN",
                Zip       = "46220",
                FirstName = "Jon",
                LastName  = "Atz",
                Age       = 78
            }; AddressBookEntry Tom = new AddressBookEntry()

            {
                Address   = "234 Garden Grove",
                City      = "San Fran",
                State     = "CA",
                Zip       = "66666",
                FirstName = "Tom",
                LastName  = "Thumb",
                Age       = 400
            };



            Console.WriteLine(Paul.GetAddress());
            Console.WriteLine(Sue.GetAddress());
            Console.WriteLine(Jon.GetAddress());
            Console.WriteLine(Tom.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            AddressBookEntry paul = new AddressBookEntry()
            {
                Address   = "123 Coder ln",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Connor",
                Age       = 40
            };

            AddressBookEntry dave = new AddressBookEntry()
            {
                Address   = "113 Hunter pl",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46202",
                FirstName = "Dave",
                LastName  = "Brown",
                Age       = 53
            };

            AddressBookEntry phil = new AddressBookEntry()
            {
                Address   = "7934 Middlebrook ave",
                City      = "Zionsville",
                State     = "IN",
                Zip       = "46019",
                FirstName = "Phil",
                LastName  = "Jones",
                Age       = 34
            };

            AddressBookEntry chuck = new AddressBookEntry()
            {
                Address   = "9024 E Main St",
                City      = "Whitestown",
                State     = "IN",
                Zip       = "46075",
                FirstName = "Chuck",
                LastName  = "Nelson",
                Age       = 48
            };

            Console.WriteLine(paul.GetAddress());
            Console.WriteLine(paul.GetDetails());
            Console.ReadLine();
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry("Paul", "O'Connor", 45)
            {
                Address   = "123 Coder pl",
                City      = "Westfield",
                State     = "IN",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Connor",
                Age       = 45
            };

            AddressBookEntry Adam = new AddressBookEntry("Adam", "Demaree", 26)
            {
                Address   = "600 N Alabama St. Apt. 1203",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46204",
                FirstName = "Adam",
                LastName  = "Demaree",
                Age       = 26
            };

            AddressBookEntry Lauren = new AddressBookEntry("Lauren", "Winters", 26)
            {
                Address   = "1010 N Central Ave. Apt. 313",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46202",
                FirstName = "Lauren",
                LastName  = "Winters",
                Age       = 26
            };

            AddressBookEntry Dad = new AddressBookEntry("Trip", "Demaree", 57)
            {
                Address   = "7845 E Gelding Dr. Suite 103",
                City      = "Scottsdale",
                State     = "AZ",
                Zip       = "85260",
                FirstName = "Trip",
                LastName  = "Demaree",
                Age       = 57
            };

            Console.WriteLine(Paul.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 24
0
        private AddressBook CreateAddressBookWithOneEntryAndOneDataItem(bool dataItemIsEnabled)
        {
            AddressBook addressBook = new AddressBook();

            AddressBookEntry entry = new AddressBookEntry();
            entry.FirstName = "John";
            entry.LastName = "Doe";

            MailAddressEntryObject data = new MailAddressEntryObject() { Address = new MailAddress("*****@*****.**") };
            entry.Data.Add(new EntryDataItem() { Data = data, Identifier = MailEntryObjectTypeIdentifier, IsEnabled = dataItemIsEnabled });

            addressBook.Entries.Add(entry);

            return addressBook;
        }
Exemplo n.º 25
0
        public List <AddressBookEntry> InitializeAddressBookEntries()
        {
            var addressBookEntry1 = AddressBookEntry.Create("allen", "iverson", "123 All Star Way", "", "Philadelphia",
                                                            "PA", "84001", "888-123-1234", "123-234-3456", "*****@*****.**");
            var addressBookEntry2 = AddressBookEntry.Create("larry", "brown", "456 Coach Circle", "", "Philadelphia",
                                                            "PA", "84002", "866-234-4567", "231-456-7890", "*****@*****.**");
            var addressBookEntry3 = AddressBookEntry.Create("jeremy", "clarkson", "789 Test Track", "", "Salt Lake City",
                                                            "UT", "84003", "877-345-6789", "789-456-1320", "*****@*****.**");
            var addressBookEntry4 = AddressBookEntry.Create("richard", "hammond", "007 Long Drive", "", "Salt Lake City",
                                                            "UT", "84004", "800-456-7890", "753-951-1478", "*****@*****.**");

            return(new List <AddressBookEntry> {
                addressBookEntry1, addressBookEntry2, addressBookEntry3, addressBookEntry4
            });
        }
Exemplo n.º 26
0
		public void Serializability() {
			var entry = new AddressBookEntry() {
				SerializedEndpoint = new byte[] { 0x1, 0x2 },
				Signature = new byte[] { 0x3, 0x4 },
			};

			var ms = new MemoryStream();
			var serializer = new DataContractSerializer(typeof(AddressBookEntry));
			serializer.WriteObject(ms, entry);
			ms.Position = 0;
			var deserializedEntry = (AddressBookEntry)serializer.ReadObject(ms);

			Assert.That(deserializedEntry.SerializedEndpoint, Is.EqualTo(entry.SerializedEndpoint));
			Assert.That(deserializedEntry.Signature, Is.EqualTo(entry.Signature));
		}
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            AddressBookEntry Nathan = new AddressBookEntry()
            {
                Address   = "1708 East 66th Street",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46220",
                FirstName = "Nathan",
                LastName  = "Randall",
                Age       = "39",
            };
            AddressBookEntry Dawn = new AddressBookEntry()
            {
                Address   = "1708 East 66th Street",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46220",
                FirstName = "Dawn",
                LastName  = "Neumann",
                Age       = "44",
            };
            AddressBookEntry Lilly = new AddressBookEntry()
            {
                Address   = "1708 East 66th Street",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46220",
                FirstName = "Lilly",
                LastName  = "The Cat",
                Age       = "8",
            };
            AddressBookEntry MacGreggor = new AddressBookEntry()
            {
                Address   = "1708 East 66th Street",
                City      = "Indianapolis",
                State     = "IN",
                Zip       = "46220",
                FirstName = "MacGreggor",
                LastName  = "The Dog",
                Age       = "14",
            };


            Console.WriteLine(Lilly.GetInfo());
            Console.WriteLine(Nathan.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 28
0
        private AddressBook CompileAddressBookFromViewModel()
        {
            AddressBook addressBook = new AddressBook();

            foreach (EntryViewModel evm in this.Entries)
            {
                AddressBookEntry abe = new AddressBookEntry();
                abe.FirstName = evm.FirstName;
                abe.LastName  = evm.LastName;

                foreach (EntryDataItemViewModel edivm in evm.DataItems)
                {
                    EntryDataItem edi = new EntryDataItem();
                    // Decide which value to use
                    if (edivm.Editor != null)
                    {
                        edi.IsEnabled  = edivm.IsEnabled;
                        edi.Identifier = CustomDataEditors.CustomDataEditorCache.GetTypeEditorIdentifier(edivm.Editor.GetType());
                        edi.Data       = edivm.Editor.Value;

                        // If there is no data available, skip this entry.
                        if (edi.Data == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (edivm.Source != null)
                        {
                            edi = edivm.Source;
                        }

                        // TODO: What happens if there is no editor, AND no value?
                        continue;
                    }

                    abe.Data.Add(edi);
                }

                addressBook.Entries.Add(abe);
            }


            return(addressBook);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Set the tag id of the tag that matches the entry book address properties. If
        /// no email address is assigned, then no address book entry is used. Otherwise
        /// the first character of the displayName is used.
        /// </summary>
        /// <param name="entry">The address book entry to set the tag id for.</param>
        private void SetTagId(AddressBookEntry entry)
        {
            if (entry == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(entry.EmailAddress))
            {
                return;
            }

            uint?tagId = GetTagId(entry.DisplayName);

            if ((tagId != null) && (tagId > 0))
            {
                entry.Set("tagId", String.Format("1,{0}", tagId));
            }
        }
Exemplo n.º 30
0
        public void Serializability()
        {
            var entry = new AddressBookEntry()
            {
                SerializedEndpoint = new byte[] { 0x1, 0x2 },
                Signature          = new byte[] { 0x3, 0x4 },
            };

            var ms         = new MemoryStream();
            var serializer = new DataContractSerializer(typeof(AddressBookEntry));

            serializer.WriteObject(ms, entry);
            ms.Position = 0;
            var deserializedEntry = (AddressBookEntry)serializer.ReadObject(ms);

            Assert.That(deserializedEntry.SerializedEndpoint, Is.EqualTo(entry.SerializedEndpoint));
            Assert.That(deserializedEntry.Signature, Is.EqualTo(entry.Signature));
        }
Exemplo n.º 31
0
        public void DeleteAddressBookEntry_ShouldReturnSuccessResult_WhenDeleted()
        {
            // Arrange
            const string addressBookEntryId = "AddressBookEntries/123";
            var          addressBookEntry   = AddressBookEntry.Create(addressBookEntryId, "ln", "st1", "st2", "c", "st", "84000", "hp", "mp", "em");

            _unitOfWork.Setup(u => u.AddressBookEntries.Load(addressBookEntryId)).Returns(addressBookEntry);
            _addressBookService = new AddressBookServiceBuilder().WithUnitOfWorkFactory(_unitOfWorkFactory).Build();

            // Act
            var result = _addressBookService.DeleteAddressBookEntry(addressBookEntryId);

            // Assert
            result.ResultType.Should().Be(AddressBookCommandResultType.Success);
            _unitOfWork.Verify(m => m.AddressBookEntries.Delete(addressBookEntry.Id), Times.Once);
            _unitOfWork.Verify(m => m.Commit(), Times.Once);
            _unitOfWork.Verify(m => m.Dispose(), Times.Once);
        }
        private bool ValidateServerBox()
        {
            string server = txtServer.Text;

            if (string.IsNullOrWhiteSpace(server))
            {
                ServerIsValid = null;
                return(false);
            }

            if (AddressBookEntry.IsValidServerEntry(server))
            {
                ServerIsValid = true;
                return(true);
            }

            ServerIsValid = false;
            return(false);
        }
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            AddressBookEntry Paul = new AddressBookEntry()
            {
                Address   = "123 Coder St",
                City      = "Westfield",
                Zip       = "44056",
                FirstName = "Paul",
                LastName  = "O'Connor",
                Age       = 40
            };
            AddressBookEntry Devan = new AddressBookEntry()
            {
                Address   = "111 Coder St",
                City      = "Lafayette",
                Zip       = "47905",
                FirstName = "Devan",
                LastName  = "Peetz",
                Age       = 25
            };
            AddressBookEntry Steve = new AddressBookEntry()
            {
                Address   = "100 Coder St",
                City      = "West Lafayette",
                Zip       = "47906",
                FirstName = "Steve",
                LastName  = "Neal",
                Age       = 26
            };
            AddressBookEntry Stuart = new AddressBookEntry()
            {
                Address   = "155 Coder St",
                City      = "West Lafayette",
                Zip       = "47906",
                FirstName = "Stuart",
                LastName  = "Bilan",
                Age       = 24
            };

            Console.WriteLine(Paul.GetAddress());
            Console.ReadLine();
        }
Exemplo n.º 34
0
        public IActionResult RemoveAddress([FromQuery]string label)
        {
            Guard.NotEmpty(label, nameof(label));

            try
            {
                AddressBookEntry removedEntry = this.addressBookManager.RemoveAddress(label);

                if (removedEntry == null)
                {
                    return ErrorHelpers.BuildErrorResponse(HttpStatusCode.NotFound, $"No item with label '{label}' was found in the address book.", string.Empty);
                }

                return this.Json(new AddressBookEntryModel { Label = removedEntry.Label, Address = removedEntry.Address });
            }
            catch (Exception e)
            {
                this.logger.LogError("Exception occurred: {0}", e.ToString());
                return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "There was a problem removing an address from the address book.", e.ToString());
            }
        }
Exemplo n.º 35
0
        public void ByLoopAddressFilterTest()
        {
            IAddressFilter filter = new ByLoopAddressFilter();

            Operation operation = new Operation();
            operation.Loops.Add("123");
            operation.Loops.Add("456");
            operation.Loops.Add("789");

            AddressBookEntry entry = new AddressBookEntry();
            entry.FirstName = "John";
            entry.LastName = "Doe";
            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject() { Loop = "123" } });

            Assert.IsTrue(filter.QueryAcceptEntry(operation, entry));

            entry.Data.Clear();
            Assert.IsFalse(filter.QueryAcceptEntry(operation, entry));

            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject() { Loop = "nada" } });
            Assert.IsFalse(filter.QueryAcceptEntry(operation, entry));
        }
Exemplo n.º 36
0
		public void Ctor() {
			var entry = new AddressBookEntry();
			Assert.That(entry.SerializedEndpoint, Is.Null);
			Assert.That(entry.Signature, Is.Null);
		}
Exemplo n.º 37
0
 public void ExtractEndpointWithoutCrypto()
 {
     var entry = new AddressBookEntry();
     Assert.Throws<ArgumentNullException>(() => entry.ExtractEndpoint());
 }
Exemplo n.º 38
0
 public void Ctor()
 {
     var entry = new AddressBookEntry();
     Assert.Null(entry.SerializedEndpoint);
     Assert.Null(entry.Signature);
 }
Exemplo n.º 39
0
        private AddressBook CompileAddressBookFromViewModel()
        {
            AddressBook addressBook = new AddressBook();

            foreach (EntryViewModel evm in this.Entries)
            {
                AddressBookEntry abe = new AddressBookEntry();
                abe.FirstName = evm.FirstName;
                abe.LastName = evm.LastName;

                foreach (EntryDataItemViewModel edivm in evm.DataItems)
                {
                    EntryDataItem edi = new EntryDataItem();
                    // Decide which value to use
                    if (edivm.Editor != null)
                    {
                        edi.IsEnabled = edivm.IsEnabled;
                        edi.Identifier = CustomDataEditors.CustomDataEditorCache.GetTypeEditorIdentifier(edivm.Editor.GetType());
                        edi.Data = edivm.Editor.Value;

                        // If there is no data available, skip this entry.
                        if (edi.Data == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (edivm.Source != null)
                        {
                            edi = edivm.Source;
                        }

                        // TODO: What happens if there is no editor, AND no value?
                        continue;
                    }

                    abe.Data.Add(edi);
                }

                addressBook.Entries.Add(abe);
            }

            return addressBook;
        }
Exemplo n.º 40
0
        void IStringSettingConvertible.Convert(string settingValue)
        {
            Logger.Instance.LogFormat(LogType.Debug, this, Resources.AddressBook_StartScanMessage);

            XDocument doc = XDocument.Parse(settingValue);

            foreach (XElement entryE in doc.Root.Elements("Entry"))
            {
                AddressBookEntry entry = new AddressBookEntry();
                entry.FirstName = entryE.TryGetAttributeValue("FirstName", null);
                entry.LastName = entryE.TryGetAttributeValue("LastName", null);

                // Find all other custom attributes
                foreach (XElement customElementE in entryE.Elements())
                {
                    string providerType = customElementE.Name.LocalName;

                    IAddressProvider provider = GetAddressProvider(providerType);
                    if (provider == null)
                    {
                        continue;
                    }

                    object customObject = provider.Convert(customElementE);
                    if (customObject == null)
                    {
                        continue;
                    }

                    EntryDataItem eo = new EntryDataItem();
                    eo.IsEnabled = IsEnabled(customElementE);
                    eo.Identifier = providerType;
                    eo.Data = customObject;
                    entry.Data.Add(eo);
                }

                Entries.Add(entry);
            }

            Logger.Instance.LogFormat(LogType.Debug, this, Resources.AddressBook_FinishScanMessage, Entries.Count);
        }