Esempio n. 1
0
		public override object Serialize(object collection, int depth)
		{
			ReferenceTypeSerializer referenceTypeSerializer = new ReferenceTypeSerializer(this.referringResourceType, this.resourceProperty);
			List<DSResource> dSResources = new List<DSResource>();
			if (collection != null)
			{
				IEnumerable enumerable = LanguagePrimitives.GetEnumerable(collection);
				if (enumerable != null)
				{
					foreach (object obj in enumerable)
					{
						dSResources.Add(referenceTypeSerializer.Serialize(obj, depth) as DSResource);
					}
				}
				else
				{
					throw new ArgumentException("reference set is not a collection type", "collection");
				}
			}
			return dSResources;
		}
Esempio n. 2
0
        public override object Serialize(object collection, int depth)
        {
            ReferenceTypeSerializer referenceTypeSerializer = new ReferenceTypeSerializer(this.referringResourceType, this.resourceProperty);
            List <DSResource>       dSResources             = new List <DSResource>();

            if (collection != null)
            {
                IEnumerable enumerable = LanguagePrimitives.GetEnumerable(collection);
                if (enumerable != null)
                {
                    foreach (object obj in enumerable)
                    {
                        dSResources.Add(referenceTypeSerializer.Serialize(obj, depth) as DSResource);
                    }
                }
                else
                {
                    throw new ArgumentException("reference set is not a collection type", "collection");
                }
            }
            return(dSResources);
        }