/// <summary>
        /// Gets ServiceIdentification section
        /// </summary>
        /// <returns></returns>
        protected virtual ServiceIdentification GetServiceIdentification()
        {
            if (_serviceIdentification == null)
            {
                //  Get ServiceProvider from XML file
                XmlSerializer         serializer = new XmlSerializer(typeof(ServiceIdentification));
                string                filePath   = string.Format(CultureInfo.InvariantCulture, "{0}{2}{1}{2}GetCapabilities.ServiceIdentification.xml", ConfigurationManager.AppSettings["app:data_path"], this.ServiceName, Path.DirectorySeparatorChar);
                ServiceIdentification si         = (ServiceIdentification)serializer.Deserialize(File.OpenText(filePath));

                lock (_lock)
                {
                    if (_serviceIdentification == null)
                    {
                        _serviceIdentification = si;
                    }
                }
            }

            return(_serviceIdentification);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Deserializes the specified section.
		/// </summary>
		/// <param name="section">The section.</param>
		public void Deserialize(XmlNode section)
		{
			XmlAttribute idAtt = section.Attributes["id"];
			XmlAttribute typeAtt = section.Attributes["type"];
			XmlAttribute interAtt = section.Attributes["interface"];
			
			if (idAtt == null || idAtt.Value == String.Empty)
			{
				String message = "To add a service, please specify the 'id' attribute. " + 
					"Check the documentation for more information";
				throw new ConfigurationErrorsException(message);
			}

			if (typeAtt == null || typeAtt.Value == String.Empty)
			{
				String message = "To add a service, please specify the 'type' attribute. " + 
					"Check the documentation for more information";
				throw new ConfigurationErrorsException(message);
			}
			
			try
			{
				serviceType = (ServiceIdentification) 
					Enum.Parse(typeof(ServiceIdentification), idAtt.Value, true);
			}
			catch(Exception ex)
			{
				String message = "Invalid service id: " + idAtt.Value;
				throw new ConfigurationErrorsException(message, ex);
			}
			
			service = TypeLoadUtil.GetType(typeAtt.Value);
			
			if (interAtt != null)
			{
				_interface = TypeLoadUtil.GetType(interAtt.Value);
			}
		}
Ejemplo n.º 3
0
        private static Type InferServiceFromId(ServiceIdentification id)
        {
            switch (id)
            {
            case ServiceIdentification.ControllerFactory:
                return(typeof(IControllerFactory));

            case ServiceIdentification.ControllerContextFactory:
                return(typeof(IControllerContextFactory));

            case ServiceIdentification.ControllerTree:
                return(typeof(IControllerTree));

            case ServiceIdentification.CacheProvider:
                return(typeof(ICacheProvider));

            case ServiceIdentification.UrlBuilder:
                return(typeof(IUrlBuilder));

            case ServiceIdentification.UrlTokenizer:
                return(typeof(IUrlTokenizer));

            case ServiceIdentification.ServerUtility:
                return(typeof(IServerUtility));

            case ServiceIdentification.FilterFactory:
                return(typeof(IFilterFactory));

            case ServiceIdentification.ControllerDescriptorProvider:
                return(typeof(IControllerDescriptorProvider));

            case ServiceIdentification.ResourceDescriptorProvider:
                return(typeof(IResourceDescriptorProvider));

            case ServiceIdentification.RescueDescriptorProvider:
                return(typeof(IRescueDescriptorProvider));

            case ServiceIdentification.LayoutDescriptorProvider:
                return(typeof(ILayoutDescriptorProvider));

            case ServiceIdentification.HelperDescriptorProvider:
                return(typeof(IHelperDescriptorProvider));

            case ServiceIdentification.FilterDescriptorProvider:
                return(typeof(IFilterDescriptorProvider));

            case ServiceIdentification.ViewSourceLoader:
                return(typeof(IViewSourceLoader));

            case ServiceIdentification.ResourceFactory:
                return(typeof(IResourceFactory));

            case ServiceIdentification.ViewEngineManager:
                return(typeof(IViewEngineManager));

            case ServiceIdentification.TransformFilterDescriptorProvider:
                return(typeof(ITransformFilterDescriptorProvider));

            case ServiceIdentification.ValidatorRegistry:
                return(typeof(IValidatorRegistry));

            case ServiceIdentification.EmailSender:
                return(typeof(IEmailSender));

            case ServiceIdentification.ViewComponentFactory:
                return(typeof(IViewComponentFactory));

            case ServiceIdentification.ScaffoldingSupport:
                return(typeof(IScaffoldingSupport));

            case ServiceIdentification.EmailTemplateService:
                return(typeof(IEmailTemplateService));

            case ServiceIdentification.ReturnBinderDescriptorProvider:
                return(typeof(IReturnBinderDescriptorProvider));

            //				case ServiceIdentification.TransformationFilterFactory:
            //					return typeof(ITransformFilterFactory);
            case ServiceIdentification.AjaxProxyGenerator:
                return(typeof(IAjaxProxyGenerator));

            case ServiceIdentification.ViewComponentDescriptorProvider:
                return(typeof(IViewComponentDescriptorProvider));

            case ServiceIdentification.EngineContextFactory:
                return(typeof(IEngineContextFactory));

            case ServiceIdentification.DynamicActionProviderFactory:
                return(typeof(IDynamicActionProviderFactory));

            case ServiceIdentification.DynamicActionProviderDescriptorProvider:
                return(typeof(IDynamicActionProviderDescriptorProvider));

            case ServiceIdentification.DictionaryAdapterFactory:
                return(typeof(IDictionaryAdapterFactory));

            default:
                throw new NotSupportedException("Id not supported " + id);
            }
        }
Ejemplo n.º 4
0
        public virtual Capabilities CreateCapabilities(string href)
        {
            #region ServiceIdentification
            LanguageStringType[] titles = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "Web Map Tile Service"
                }
            };
            LanguageStringType[] abstracts = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "Service that contrains the map access interface to some TileMatrixSets"
                }
            };
            LanguageStringType[] keyword1 = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "tile"
                }
            };
            KeywordsType keywordsType1 = new KeywordsType()
            {
                Keyword = keyword1
            };
            LanguageStringType[] keyword2 = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "map"
                }
            };
            KeywordsType keywordsType2 = new KeywordsType()
            {
                Keyword = keyword2
            };
            KeywordsType[] keywords = new KeywordsType[]
            {
                keywordsType1, keywordsType2
            };
            CodeType serviceType = new CodeType()
            {
                Value = "OGC WMTS"
            };
            string[] serviceTypeVersion = new string[]
            {
                "1.0.0"
            };
            string   fees = "none";
            string[] accessConstraints = new string[]
            {
                "none"
            };
            ServiceIdentification serviceIdentification = new ServiceIdentification()
            {
                Title              = titles,
                Abstract           = abstracts,
                Keywords           = keywords,
                ServiceType        = serviceType,
                ServiceTypeVersion = serviceTypeVersion,
                Fees = fees,
                AccessConstraints = accessConstraints
            };
            #endregion

            #region ServiceProvider
            string             poroviderName    = "SharpMapServer";
            OnlineResourceType providerSiteType = new OnlineResourceType()
            {
                href = href
            };
            string[]      voices     = new string[] { "0000-00000000" };
            string[]      facsimiles = new string[] { "0001-00000001" };
            TelephoneType phone      = new TelephoneType()
            {
                Voice     = voices,
                Facsimile = facsimiles
            };
            string[]    deliveryPoints        = new string[] { "jinjiang" };
            string      city                  = "chengdu";
            string      administrativeArea    = "sichuan";
            string      country               = "china";
            string[]    electronicMailAddress = new string[] { "*****@*****.**" };
            string      postalCode            = "123456";
            AddressType address               = new AddressType()
            {
                DeliveryPoint         = deliveryPoints,
                City                  = city,
                AdministrativeArea    = administrativeArea,
                Country               = country,
                ElectronicMailAddress = electronicMailAddress,
                PostalCode            = postalCode
            };
            ContactType contactInfo = new ContactType()
            {
                Phone   = phone,
                Address = address
            };
            string individualName = "lc";
            string positionName   = "Senior Software Engineer";
            ResponsiblePartySubsetType serviceContact = new ResponsiblePartySubsetType()
            {
                IndividualName = individualName,
                PositionName   = positionName,
                ContactInfo    = contactInfo
            };
            ServiceProvider serviceProvider = new ServiceProvider()
            {
                ProviderName   = poroviderName,
                ProviderSite   = providerSiteType,
                ServiceContact = serviceContact
            };
            #endregion

            #region OperationsMetadata
            Operation   getCapabilitiesOperation = GetOperation(href, "GetCapabilities");
            Operation   getTileOperation         = GetOperation(href, "GetTile");
            Operation   getFeatureinfoOperation  = GetOperation(href, "GetFeatureinfo");
            Operation[] operations = new Operation[]
            {
                getCapabilitiesOperation,
                getTileOperation,
                getFeatureinfoOperation
            };
            OperationsMetadata operationsMetadata = new OperationsMetadata()
            {
                Operation = operations
            };
            #endregion

            Capabilities capabilities = new Capabilities()
            {
                ServiceIdentification = serviceIdentification,
                ServiceProvider       = serviceProvider,
                OperationsMetadata    = operationsMetadata
            };
            return(capabilities);
        }
Ejemplo n.º 5
0
        static void TestWmts()
        {
            XmlAttributeOverrides attrOverrides = new XmlAttributeOverrides();

            XmlAttributes       ddsAttrs  = new XmlAttributes();
            XmlElementAttribute layerAttr = new XmlElementAttribute
            {
                ElementName = "Layer",
                Type        = typeof(LayerType)
            };

            ddsAttrs.XmlElements.Add(layerAttr);
            attrOverrides.Add(typeof(ContentsBaseType), "DatasetDescriptionSummary", ddsAttrs);

            #region ServiceIdentification
            LanguageStringType[] titles = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "Web Map Tile Service"
                }
            };
            LanguageStringType[] abstracts = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "Service that contrains the map access interface to some TileMatrixSets"
                }
            };
            LanguageStringType[] keyword1 = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "tile"
                }
            };
            KeywordsType keywordsType1 = new KeywordsType()
            {
                Keyword = keyword1
            };
            LanguageStringType[] keyword2 = new LanguageStringType[]
            {
                new LanguageStringType()
                {
                    Value = "map"
                }
            };
            KeywordsType keywordsType2 = new KeywordsType()
            {
                Keyword = keyword2
            };
            KeywordsType[] keywords = new KeywordsType[]
            {
                keywordsType1, keywordsType2
            };
            CodeType serviceType = new CodeType()
            {
                Value = "OGC WMTS"
            };
            string[] serviceTypeVersion = new string[]
            {
                "1.0.0"
            };
            string   fees = "none";
            string[] accessConstraints = new string[]
            {
                "none"
            };
            ServiceIdentification serviceIdentification = new ServiceIdentification()
            {
                Title              = titles,
                Abstract           = abstracts,
                Keywords           = keywords,
                ServiceType        = serviceType,
                ServiceTypeVersion = serviceTypeVersion,
                Fees = fees,
                AccessConstraints = accessConstraints
            };
            #endregion
            string href = "http://123";
            #region ServiceProvider
            string             poroviderName    = "SharpMapServer";
            OnlineResourceType providerSiteType = new OnlineResourceType()
            {
                href = href
            };
            string[]      voices     = new string[] { "0000-00000000" };
            string[]      facsimiles = new string[] { "0001-00000001" };
            TelephoneType phone      = new TelephoneType()
            {
                Voice     = voices,
                Facsimile = facsimiles
            };
            string[]    deliveryPoints        = new string[] { "jinjiang" };
            string      city                  = "chengdu";
            string      administrativeArea    = "sichuan";
            string      country               = "china";
            string[]    electronicMailAddress = new string[] { "*****@*****.**" };
            string      postalCode            = "123456";
            AddressType address               = new AddressType()
            {
                DeliveryPoint         = deliveryPoints,
                City                  = city,
                AdministrativeArea    = administrativeArea,
                Country               = country,
                ElectronicMailAddress = electronicMailAddress,
                PostalCode            = postalCode
            };
            ContactType contactInfo = new ContactType()
            {
                Phone   = phone,
                Address = address
            };
            string individualName = "lc";
            string positionName   = "Senior Software Engineer";
            ResponsiblePartySubsetType serviceContact = new ResponsiblePartySubsetType()
            {
                IndividualName = individualName,
                PositionName   = positionName,
                ContactInfo    = contactInfo
            };
            ServiceProvider serviceProvider = new ServiceProvider()
            {
                ProviderName   = poroviderName,
                ProviderSite   = providerSiteType,
                ServiceContact = serviceContact
            };
            #endregion

            #region OperationsMetadata
            Operation   getCapabilitiesOperation = CapabilitiesHelper.GetOperation(href, "GetCapabilities");
            Operation   getTileOperation         = CapabilitiesHelper.GetOperation(href, "GetTile");
            Operation   getFeatureinfoOperation  = CapabilitiesHelper.GetOperation(href, "GetFeatureinfo");
            Operation[] operations = new Operation[]
            {
                getCapabilitiesOperation,
                getTileOperation,
                getFeatureinfoOperation
            };
            OperationsMetadata operationsMetadata = new OperationsMetadata()
            {
                Operation = operations
            };
            #endregion
            Capabilities capabilities = new Capabilities()
            {
                ServiceIdentification = serviceIdentification,
                ServiceProvider       = serviceProvider,
                OperationsMetadata    = operationsMetadata
            };
            IWmtsService wmts1Service = OgcServiceHelper.GetOgcService("WMTS", "1.0.0") as IWmtsService;
            wmts1Service.AddContent(capabilities, @"E:\LC\数据\双流\2014年遥感影像.img");

            List <object> objs = new List <object>();
            capabilities.Themes = new Themes[]
            {
                new Themes()
                {
                    Theme = new Theme[]
                    {
                        new Theme()
                        {
                            Identifier = new CodeType()
                            {
                                Value = "123"
                            }
                        }
                    }
                }
            };
            objs.Add(capabilities);
            StringBuilder sb = new StringBuilder();
            using (TextWriter tw = new StringWriter(sb))
            {
                foreach (var item in objs)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    var serializer = new XmlSerializer(item.GetType(), attrOverrides);
                    serializer.Serialize(tw, item);
                    var val = sb.ToString();
                    File.WriteAllText("123.xml", val);
                    sb.Clear();
                }
            }
        }
		private static Type InferServiceFromId( ServiceIdentification id )
		{
			switch( id )
			{
				case ServiceIdentification.ControllerFactory:
					return typeof( IControllerFactory );
				case ServiceIdentification.ControllerContextFactory:
					return typeof( IControllerContextFactory );
				case ServiceIdentification.ControllerTree:
					return typeof( IControllerTree );
				case ServiceIdentification.CacheProvider:
					return typeof( ICacheProvider );
				case ServiceIdentification.UrlBuilder:
					return typeof( IUrlBuilder );
				case ServiceIdentification.UrlTokenizer:
					return typeof( IUrlTokenizer );
				case ServiceIdentification.ServerUtility:
					return typeof( IServerUtility );
				case ServiceIdentification.FilterFactory:
					return typeof( IFilterFactory );
				case ServiceIdentification.ControllerDescriptorProvider:
					return typeof( IControllerDescriptorProvider );
				case ServiceIdentification.ResourceDescriptorProvider:
					return typeof( IResourceDescriptorProvider );
				case ServiceIdentification.RescueDescriptorProvider:
					return typeof( IRescueDescriptorProvider );
				case ServiceIdentification.LayoutDescriptorProvider:
					return typeof( ILayoutDescriptorProvider );
				case ServiceIdentification.HelperDescriptorProvider:
					return typeof( IHelperDescriptorProvider );
				case ServiceIdentification.FilterDescriptorProvider:
					return typeof( IFilterDescriptorProvider );
				case ServiceIdentification.ViewSourceLoader:
					return typeof( IViewSourceLoader );
				case ServiceIdentification.ResourceFactory:
					return typeof( IResourceFactory );
				case ServiceIdentification.ViewEngineManager:
					return typeof( IViewEngineManager );
				case ServiceIdentification.TransformFilterDescriptorProvider:
					return typeof( ITransformFilterDescriptorProvider );
				case ServiceIdentification.ValidatorRegistry:
					return typeof( IValidatorRegistry );
				case ServiceIdentification.EmailSender:
					return typeof( IEmailSender );
				case ServiceIdentification.ViewComponentFactory:
					return typeof( IViewComponentFactory );
				case ServiceIdentification.ScaffoldingSupport:
					return typeof( IScaffoldingSupport );
				case ServiceIdentification.EmailTemplateService:
					return typeof( IEmailTemplateService );
				case ServiceIdentification.ReturnBinderDescriptorProvider:
					return typeof( IReturnBinderDescriptorProvider );
				//				case ServiceIdentification.TransformationFilterFactory:
				//					return typeof(ITransformFilterFactory);
				case ServiceIdentification.AjaxProxyGenerator:
					return typeof( IAjaxProxyGenerator );
				case ServiceIdentification.ViewComponentDescriptorProvider:
					return typeof( IViewComponentDescriptorProvider );
				case ServiceIdentification.EngineContextFactory:
					return typeof( IEngineContextFactory );
				case ServiceIdentification.DynamicActionProviderFactory:
					return typeof( IDynamicActionProviderFactory );
				case ServiceIdentification.DynamicActionProviderDescriptorProvider:
					return typeof( IDynamicActionProviderDescriptorProvider );
				case ServiceIdentification.DictionaryAdapterFactory:
					return typeof( IDictionaryAdapterFactory );
				default:
					throw new NotSupportedException( "Id not supported " + id );
			}
		}
		/// <summary>
		/// Registers the service.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="service">The service.</param>
		public void RegisterService(ServiceIdentification id, Type service)
		{
			RegisterService(ToInterface(id), service);
		}
		private Type ToInterface(ServiceIdentification id)
		{
			switch(id)
			{
				case ServiceIdentification.ControllerFactory:
					return typeof(IControllerFactory);
				case ServiceIdentification.ViewComponentFactory:
					return typeof(IViewComponentFactory);
				case ServiceIdentification.FilterFactory:
					return typeof(IFilterFactory);
				case ServiceIdentification.EmailSender:
					return typeof(IEmailSender);
				case ServiceIdentification.ControllerDescriptorProvider:
					return typeof(IControllerDescriptorProvider);
				case ServiceIdentification.ResourceDescriptorProvider:
					return typeof(IResourceDescriptorProvider);
				case ServiceIdentification.RescueDescriptorProvider:
					return typeof(IRescueDescriptorProvider);
				case ServiceIdentification.LayoutDescriptorProvider:
					return typeof(ILayoutDescriptorProvider);
				case ServiceIdentification.HelperDescriptorProvider:
					return typeof(IHelperDescriptorProvider);
				case ServiceIdentification.FilterDescriptorProvider:
					return typeof(IFilterDescriptorProvider);
				case ServiceIdentification.EmailTemplateService:
					return typeof(IEmailTemplateService);
				case ServiceIdentification.ControllerTree:
					return typeof(IControllerTree);
				case ServiceIdentification.CacheProvider:	
					return typeof(ICacheProvider);
				case ServiceIdentification.ViewSourceLoader:
					return typeof(IViewSourceLoader);
				case ServiceIdentification.ScaffoldingSupport:
					return typeof(IScaffoldingSupport);
				case ServiceIdentification.ViewEngineManager:
					return typeof(IViewEngineManager);
				case ServiceIdentification.ResourceFactory:
					return typeof(IResourceFactory);
				case ServiceIdentification.ExecutorFactory:
					return typeof(IControllerLifecycleExecutorFactory);
				case ServiceIdentification.TransformationFilterFactory:
					return typeof(ITransformFilterFactory);
				case ServiceIdentification.TransformFilterDescriptorProvider:
					return typeof(ITransformFilterDescriptorProvider);
				case ServiceIdentification.UrlBuilder:
					return typeof(IUrlBuilder);
				case ServiceIdentification.UrlTokenizer:
					return typeof(IUrlTokenizer);
				case ServiceIdentification.ServerUtility:
					return typeof(IServerUtility);
				case ServiceIdentification.ValidatorRegistry:
					return typeof(IValidatorRegistry);
				case ServiceIdentification.AjaxProxyGenerator:
					return typeof(IAjaxProxyGenerator);
				default:
					throw new NotSupportedException("Id not supported " + id);
			}
		}
		/// <summary>
		/// Determines whether it has service.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <returns>
		/// 	<c>true</c> if the specified id has service; otherwise, <c>false</c>.
		/// </returns>
		public bool HasService(ServiceIdentification id)
		{
			return service2Impl.Contains(ToInterface(id));
		}
		/// <summary>
		/// Gets the service.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <returns></returns>
		public Type GetService(ServiceIdentification id)
		{
			return (Type) service2Impl[ToInterface(id)];
		}
Ejemplo n.º 11
0
        public static ServiceIdentification GetServiceIdentification(string[] titles, string[] abstracts, string[] keyWords, string service, string[] serviceTypeVersions, string fees, string[] accessConstraints, string[] profiles)
        {
            LanguageStringType[] titleTypes = null;
            if (titles != null)
            {
                titleTypes = new LanguageStringType[titles.Length];
                for (int i = 0; i < titles.Length; i++)
                {
                    titleTypes[i] = new LanguageStringType()
                    {
                        Value = titles[i]
                    };
                }
            }
            LanguageStringType[] abstractTypes = null;
            if (abstracts != null)
            {
                abstractTypes = new LanguageStringType[abstracts.Length];
                for (int i = 0; i < abstracts.Length; i++)
                {
                    titleTypes[i] = new LanguageStringType()
                    {
                        Value = abstracts[i]
                    };
                }
            }
            KeywordsType[] keywordsTypes = null;
            if (keyWords != null)
            {
                keywordsTypes = new KeywordsType[keyWords.Length];
                for (int i = 0; i < keyWords.Length; i++)
                {
                    LanguageStringType[] keyword = new LanguageStringType[]
                    {
                        new LanguageStringType()
                        {
                            Value = keyWords[i]
                        }
                    };
                    keywordsTypes[i] = new KeywordsType()
                    {
                        Keyword = keyword
                    };
                }
            }
            CodeType serviceType = null;

            if (!string.IsNullOrWhiteSpace(service))
            {
                serviceType = new CodeType()
                {
                    Value = service
                };
            }
            ServiceIdentification serviceIdentification = new ServiceIdentification()
            {
                Title              = titleTypes,
                Abstract           = abstractTypes,
                Keywords           = keywordsTypes,
                ServiceType        = serviceType,
                ServiceTypeVersion = serviceTypeVersions,
                Fees = fees,
                AccessConstraints = accessConstraints,
                Profile           = profiles
            };

            return(serviceIdentification);
        }