Beispiel #1
0
 public ContactReader(bool useRawContacts, ContentQueryTranslator translator, ContentResolver content, Resources resources)
 {
     this.rawContacts = useRawContacts;
     this.translator  = translator;
     this.content     = content;
     this.resources   = resources;
 }
		protected override IEnumerable GetObjectReader (ContentQueryTranslator translator)
		{
			if (translator == null || translator.ReturnType == null || translator.ReturnType == typeof(Contact))
				return new ContactReader (UseRawContacts, translator, content, resources);
			else if (translator.ReturnType == typeof(Phone))
				return new GenericQueryReader<Phone> (translator, content, resources, ContactHelper.GetPhone);
			else if (translator.ReturnType == typeof(Email))
				return new GenericQueryReader<Email> (translator, content, resources, ContactHelper.GetEmail);
			else if (translator.ReturnType == typeof(Address))
				return new GenericQueryReader<Address> (translator, content, resources, ContactHelper.GetAddress);
			else if (translator.ReturnType == typeof(Relationship))
				return new GenericQueryReader<Relationship> (translator, content, resources, ContactHelper.GetRelationship);
			else if (translator.ReturnType == typeof(InstantMessagingAccount))
				return new GenericQueryReader<InstantMessagingAccount> (translator, content, resources, ContactHelper.GetImAccount);
			else if (translator.ReturnType == typeof(Website))
				return new GenericQueryReader<Website> (translator, content, resources, ContactHelper.GetWebsite);
			else if (translator.ReturnType == typeof(Organization))
				return new GenericQueryReader<Organization> (translator, content, resources, ContactHelper.GetOrganization);
			else if (translator.ReturnType == typeof(Note))
				return new GenericQueryReader<Note> (translator, content, resources, ContactHelper.GetNote);
			else if (translator.ReturnType == typeof(string))
				return new ProjectionReader<string> (content, translator, (cur,col) => cur.GetString (col));
			else if (translator.ReturnType == typeof(int))
				return new ProjectionReader<int> (content, translator, (cur, col) => cur.GetInt (col));

			throw new ArgumentException();
		}
 public void Setup()
 {
     this.queryable  = new MockQueryable <Contact>();
     this.translator = new ContentQueryTranslator(this.queryable.Provider, new ContactTableFinder {
         UseRawContacts = false
     });
 }
        protected override IEnumerable GetObjectReader(ContentQueryTranslator translator)
        {
            if (translator == null || translator.ReturnType == null || translator.ReturnType == typeof(Contact))
            {
                return(new ContactReader(UseRawContacts, translator, content, resources));
            }
            else if (translator.ReturnType == typeof(Phone))
            {
                return(new GenericQueryReader <Phone>(translator, content, resources, ContactHelper.GetPhone));
            }
            else if (translator.ReturnType == typeof(Email))
            {
                return(new GenericQueryReader <Email>(translator, content, resources, ContactHelper.GetEmail));
            }
            else if (translator.ReturnType == typeof(Address))
            {
                return(new GenericQueryReader <Address>(translator, content, resources, ContactHelper.GetAddress));
            }
            else if (translator.ReturnType == typeof(Relationship))
            {
                return(new GenericQueryReader <Relationship>(translator, content, resources, ContactHelper.GetRelationship));
            }
            else if (translator.ReturnType == typeof(InstantMessagingAccount))
            {
                return(new GenericQueryReader <InstantMessagingAccount>(
                           translator,
                           content,
                           resources,
                           ContactHelper.GetImAccount));
            }
            else if (translator.ReturnType == typeof(Website))
            {
                return(new GenericQueryReader <Website>(translator, content, resources, ContactHelper.GetWebsite));
            }
            else if (translator.ReturnType == typeof(Organization))
            {
                return(new GenericQueryReader <Organization>(translator, content, resources, ContactHelper.GetOrganization));
            }
            else if (translator.ReturnType == typeof(Note))
            {
                return(new GenericQueryReader <Note>(translator, content, resources, ContactHelper.GetNote));
            }
            else if (translator.ReturnType == typeof(String))
            {
                return(new ProjectionReader <String>(content, translator, (cur, col) => cur.GetString(col)));
            }
            else if (translator.ReturnType == typeof(Int32))
            {
                return(new ProjectionReader <Int32>(content, translator, (cur, col) => cur.GetInt(col)));
            }

            throw new ArgumentException();
        }
		public void Setup()
		{
			this.queryable = new MockQueryable<Contact>();
			this.translator = new ContentQueryTranslator (this.queryable.Provider, new ContactTableFinder { UseRawContacts = false });
		}