Beispiel #1
0
        private void ConvertFullRecordField(Types.AbstractRecord fullRecord, IRecord record, Filter.XPathTypeNavigator navigator)
        {
            var r=fullRecord as Types.Record;

            if (navigator.LocalName=="BoundingBox")
            {
                object value=navigator.GetValue(record);
                if (value==null)
                    return;

                // Covariance is a feature of .NET 4.0 http://msdn.microsoft.com/en-us/library/dd233059.aspx
                var ensg=value as IEnumerable<ISimpleGeometry>;
                if (ensg==null)
                {
                    var geom=value as ISimpleGeometry;
                    if (geom!=null)
                        ensg=new ISimpleGeometry[] { geom };
                }

                foreach (ISimpleGeometry g in ensg)
                {
                    try
                    {
                        var box=new Ows100.BoundingBox();
                        box.InitFromGeometry(g);
                        r.BoundingBox.Add(box);
                    } catch (Exception ex)
                    {
                        try
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while creating bounding box for geometry \"{1}\". Message: \"{2}\".", ex.GetType(), g, ex.Message));
                        } catch (Exception eex)
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while logging exception {1}. Message: \"{2}\".", eex.GetType(), ex.GetType(), eex.Message));
                        }
                    }
                }

                return;
            }

            IList<DC11.DCelement> elements=CreateRecordField(record, navigator);
            foreach (DC11.DCelement e in elements)
                r.Content.DCelement.Add(e);
        }
Beispiel #2
0
        protected virtual IList<DC11.DCelement> CreateRecordField(IRecord record, Filter.XPathTypeNavigator navigator)
        {
            var ret=new List<DC11.DCelement>();

            object value=navigator.GetValue(record);
            if (value==null)
                return ret;

            if ((value is string) || !(value is IEnumerable))
                value=new object[] { value };

            foreach (object v in (IEnumerable)value)
            {
                DC11.DCelement e=null;
                switch (navigator.LocalName)
                {
                case "abstract":
                    e=new DCTerms.@abstract();
                    break;
                case "created":
                    e=new DCTerms.created();
                    break;
                case "creator":
                    e=new DC11.creator();
                    break;
                case "contributor":
                    e=new DC11.contributor();
                    break;
                case "date":
                    e=new DC11.date();
                    break;
                case "description":
                    e=new DC11.description();
                    break;
                case "format":
                    e=new DC11.format();
                    break;
                case "identifier":
                    e=new DC11.identifier();
                    break;
                case "language":
                    e=new DC11.language();
                    break;
                case "modified":
                    e=new DCTerms.modified();
                    break;
                case "publisher":
                    e=new DC11.publisher();
                    break;
                case "relation":
                    e=new DC11.relation();
                    break;
                case "rights":
                    e=new DC11.rights();
                    break;
                case "source":
                    e=new DC11.source();
                    break;
                case "spatial":
                    e=new DCTerms.spatial();
                    break;
                case "subject":
                    e=new DC11.subject();
                    break;
                case "title":
                    e=new DC11.title();
                    break;
                case "type":
                    e=new DC11.type();
                    break;
                case "valid":
                    e=new DCTerms.valid();
                    break;
                }

                if (e!=null)
                {
                    if (navigator.MoveToAttribute("scheme", string.Empty))
                    {
                        object sch=navigator.GetValue(record);
                        if (sch!=null)
                            e.scheme=new Uri(sch.ToString());
                    }

                    e.Untyped.Add(v);
                    ret.Add(e);
                }
            }

            return ret;
        }