Example #1
0
        /// <summary>
        /// Creates the comprehensive entity-type instance.
        /// </summary>
        /// <param name="resource">The resource from which the CET is extracted.</param>
        /// <returns>Comprehensive entity-type instance</returns>
        private static Cet CreateCet(string resource)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Cet));

            Stream s  = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
            Cet    et = (Cet)serializer.Deserialize(s);

            return(et);
        }
Example #2
0
        public static List <ICetItem> Transform(Cet c)
        {
            List <ICetItem> items = new List <ICetItem>();

            IEnumerable <ICetItem> extras =
                from e in c.Entities
                from j in e.Categories
                from k in j.Subcategories
                from l in k.Specifices
                from m in l.Extras
                select new CetItem()
            {
                Category    = j.Id,
                Country     = e.Country,
                Description = m.Description,
                Domain      = e.Domain,
                Extra       = m.Id != 0 ? (byte?)m.Id : null,
                Kind        = e.Kind,
                Specific    = l.Id != 0 ? (byte?)l.Id : null,
                Subcategory = k.Id != 0 ? (byte?)k.Id : null
            };

            IEnumerable <ICetItem> specifices =
                from e in c.Entities
                from j in e.Categories
                from k in j.Subcategories
                from l in k.Specifices
                select new CetItem()
            {
                Category    = j.Id,
                Country     = e.Country,
                Description = l.Description,
                Domain      = e.Domain,
                Kind        = e.Kind,
                Specific    = l.Id != 0 ? (byte?)l.Id : null,
                Maximum     = l.Id2 != 0 ? (byte?)l.Id2 : null,
                Subcategory = k.Id != 0 ? (byte?)k.Id : null
            };

            IEnumerable <ICetItem> subcategories =
                from e in c.Entities
                from j in e.Categories
                from k in j.Subcategories
                select new CetItem()
            {
                Category    = j.Id,
                Country     = e.Country,
                Description = k.Description,
                Domain      = e.Domain,
                Kind        = e.Kind,
                Subcategory = k.Id != 0 ? (byte?)k.Id : null,
                Maximum     = k.Id2 != 0 ? (byte?)k.Id2 : null
            };

            IEnumerable <ICetItem> categories =
                from e in c.Entities
                from j in e.Categories
                select new CetItem()
            {
                Category    = j.Id,
                Country     = e.Country,
                Description = j.Description,
                Domain      = e.Domain,
                Kind        = e.Kind
            };

            items = items.Concat <ICetItem>(extras).Concat <ICetItem>(specifices).Concat <ICetItem>(subcategories).Concat <ICetItem>(categories).ToList <ICetItem>();
            items.Sort();

            return(items);
        }