public void Init(ServiceLocator sl, ref PluginSetting setting)
        {
            if (!setting.Enable)
            {
                return;
            }

            IUrlMappingProvider urlMapping = sl.Resolve <IUrlMappingProvider>();

            UrlMappingItem item = UrlMapping.Utility.CreateTemplatedMappingItem("_res.aspx");

            item.Id          = "_res_";
            item.Action      = "proc";
            item.Index       = -1;
            item.SubIndex    = -1;
            item.SubsubIndex = -1;

            urlMapping.AddMapping(item);

            item             = UrlMapping.Utility.CreateTemplatedMappingItem("[]_resc.aspx");
            item.Id          = "_resc_";
            item.Action      = "proc";
            item.Index       = -1;
            item.SubIndex    = -1;
            item.SubsubIndex = -1;

            urlMapping.AddMapping(item);
        }
Beispiel #2
0
        /// <summary>
        /// Instructs the provider associated with this UrlMappingModule
        /// to refresh its internally-cached collection of URL mappings data
        /// </summary>
        public static void RefreshUrlMappings()
        {
            UrlMappingModule mod = UrlMappingModule.Module;

            if (mod != null)
            {
                IUrlMappingProvider prov = mod.GetProvider();
                if (prov != null)
                {
                    prov.RefreshUrlMappings();
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// SharePoint functions class constructor
 /// </summary>
 public SharePointPublishingFunctionsService(ILogger <SharePointFunctionsService> logger,
                                             HtmlTransformator htmlTransformator,
                                             IUrlMappingProvider urlMappingProvider,
                                             IUserMappingProvider userMappingProvider,
                                             IOptions <SharePointTransformationOptions> options,
                                             SharePointFunctionsService sharePointFunctionsService,
                                             IServiceProvider serviceProvider)
 {
     this.logger                     = logger ?? throw new ArgumentNullException(nameof(logger));
     this.htmlTransformator          = htmlTransformator ?? throw new ArgumentNullException(nameof(htmlTransformator));
     this.urlMappingProvider         = urlMappingProvider ?? throw new ArgumentNullException(nameof(urlMappingProvider));
     this.userMappingProvider        = userMappingProvider ?? throw new ArgumentNullException(nameof(userMappingProvider));
     this.options                    = options ?? throw new ArgumentNullException(nameof(options));
     this.sharePointFunctionsService = sharePointFunctionsService ?? throw new ArgumentNullException(nameof(sharePointFunctionsService));
     this.serviceProvider            = serviceProvider;
     this.memoryCache                = this.serviceProvider.GetService <IMemoryCache>();
 }
        private void Initalize()
        {
            UrlMappingConfig config = UrlMappingConfig.Instance;

            _provider = ServiceLocator.Instance.Resolve <IUrlMappingProvider>();

            _noMatchAction                 = config.NoMatchAction;
            _noMatchRedirectPage           = config.NoMatchRedirectUrl;
            _automaticallyUpdateFormAction = config.AutoUpdateFormAction;
            _qsBehavior      = config.IncomingQueryStringBehavior;
            _processingEvent = config.UrlProcessingEvent;

            if (_provider != null)
            {
                _provider.Initialize(config);
            }

            // save to config
            config.Provider = _provider;
        }
        void findRoutes(string siteKey, Dictionary <string, Type> types)
        {
            UrlMappingConfig    config   = UrlMappingConfig.Instance;
            IUrlMappingProvider provider = ServiceLocator.Instance.Resolve <IUrlMappingProvider>();

            foreach (var controller in types)
            {
                foreach (MethodInfo m in controller.Value.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    object[] objs = m.GetCustomAttributes(typeof(UrlRouteAttribute), true);
                    if (objs.Length == 0)
                    {
                        continue;
                    }

                    UrlRouteAttribute attr = objs[0] as UrlRouteAttribute;

                    UrlMappingItem item = UrlMapping.Utility.CreateTemplatedMappingItem(string.Empty,
                                                                                        attr.Template,
                                                                                        UrlMapping.Utility.GetHref(attr.Href),
                                                                                        config.IncomingQueryStringBehavior);

                    item.UrlTemplate = attr.Template;

                    item.Index       = -1;
                    item.SubIndex    = -1;
                    item.SubsubIndex = -1;
                    item.Title       = attr.Title;

                    item.Id     = controller.Key;
                    item.Action = m.Name;

                    provider.AddMapping(siteKey, item);
                }
            }
        }
        private void Initalize()
        {
            UrlMappingConfig config = UrlMappingConfig.Instance;

            _provider = ServiceLocator.Instance.Resolve<IUrlMappingProvider>();

            _noMatchAction = config.NoMatchAction;
            _noMatchRedirectPage = config.NoMatchRedirectUrl;
            _automaticallyUpdateFormAction = config.AutoUpdateFormAction;
            _qsBehavior = config.IncomingQueryStringBehavior;
            _processingEvent = config.UrlProcessingEvent;

            if (_provider != null)
            {
                _provider.Initialize(config);
            }

            // save to config
            config.Provider = _provider;
        }
Beispiel #7
0
        private void Initialize()
        {
            // get the configuration section
            UrlMappingProviderConfiguration config
                = (UrlMappingProviderConfiguration)ConfigurationManager.GetSection(kMAPPINGMODULE);

            if (config == null)
            {
                throw new ProviderException("The configuration section for the UrlMappingModule is missing from Web.config.");
            }

            if (!string.IsNullOrEmpty(config.ProviderTypeString))
            {
                // instantiate a concrete provider given the provider type string through reflection
                Type t = Type.GetType(config.ProviderTypeString);

                // if the type couldn't be retrieved, it could be because the user has it defined in APP_CODE;
                // try the BuildManager
                if (t == null)
                {
                    t = BuildManager.GetType(config.ProviderTypeString, false, true);
                }

                // if we still have an error, throw the exception
                if (t == null)
                {
                    throw new ProviderException("Cannot locate the type '" + config.ProviderTypeString + "' for the UrlMappingModule.  Check your web.config settings.");
                }

                // attempt to instantiate the provider given its type
                _provider = (IUrlMappingProvider)Activator.CreateInstance(t);
            }
            else
            {
                _provider = null;
            }

            if (_provider == null)
            {
                throw new ProviderException("Invalid provider for UrlMappingModule.  This must be a type that implements IUrlMappingProvider.  Check your web.config settings, section 'urlMappingModule', attribute 'providerType'");
            }


            // remember other configuration properties
            _noMatchAction                 = config.NoMatchAction;
            _noMatchRedirectPage           = config.NoMatchRedirectUrl;
            _automaticallyUpdateFormAction = config.AutomaticallyUpdateFormAction;
            _qsBehavior                  = config.IncomingQueryStringBehavior;
            _processingEvent             = config.UrlProcessingEvent;
            _authorizeRedirectionUrl     = config.AuthorizeRedirectionUrl;
            _authorizeFailureRedirectUrl = config.AuthorizeFailureRedirectUrl;

            // test configuration combinations
            if (_authorizeRedirectionUrl == true && _processingEvent != UrlProcessingEventEnum.AuthorizeRequest)
            {
                throw new ConfigurationErrorsException("When the <urlMappingModule> 'authorizeRedirectionUrl' attribute is 'true', the 'processEvent' attribute must be 'AuthorizeEvent'.");
            }



            // remember the list of extensions to ignore
            _ignoreExtensions = config.IgnoreExtensions.Split(new char[] { ' ', ';', ',' });
            for (int i = 0; i < _ignoreExtensions.Length; i++)
            {
                _ignoreExtensions[i] = _ignoreExtensions[i].Trim().ToLower();
            }

            // allow the provider to initialize itself given the configuration section
            if (_provider != null)
            {
                _provider.Initialize(config);
            }
        }