コード例 #1
0
ファイル: LdbHelper.cs プロジェクト: merkt/Huxley
 public static AccessToken GetDarwinAccessToken(Guid accessToken, HuxleySettings huxleySettings)
 {
     // If ClientAccessToken is an empty GUID then no token is required in the Huxley URL.
     // If ClientAccessToken matches the token in the URL then the DarwinAccessToken will be used instead in the SOAP call.
     // Otherwise the URL token is passed straight through
     if (huxleySettings.ClientAccessToken == accessToken)
     {
         accessToken = huxleySettings.DarwinAccessToken;
     }
     return(new AccessToken {
         TokenValue = accessToken.ToString()
     });
 }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: sjcole/Huxley
        protected void Application_Start() {
            // Makes the JSON easier to read in a browser without installing an extension like JSONview
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            // Stops the backing field names being used instead of the public property names (*Field & PropertyChanged etc.)
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            // Returns JSON to the browser without needing to add application/json to the accept request header - remove to use XML (becomes the default)
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            // Pass Register into Configure to support attribute routing in the future
            GlobalConfiguration.Configure(WebApiConfig.Register);

            // Load settings
            dynamic config = new Configuration();
            Settings = config.Bind<HuxleySettings>();

            // Set the CRS dictionary passing in embedded CRS path
            CrsCodes = GetCrsCodes(Server.MapPath("~/RailReferences.csv")).Result;

            // https://en.wikipedia.org/wiki/London_station_group 
            // Farringdon [ZFD] is not a London Terminal but it probably should be (maybe when Crossrail opens it will be)
            LondonTerminals = new List<CrsRecord> {
                new CrsRecord {CrsCode = "BFR", StationName = "London Blackfriars",},
                new CrsRecord {CrsCode = "CST", StationName = "London Cannon Street",},
                new CrsRecord {CrsCode = "CHX", StationName = "London Charing Cross",},
                new CrsRecord {CrsCode = "CTK", StationName = "City Thameslink",},
                new CrsRecord {CrsCode = "EUS", StationName = "London Euston",},
                new CrsRecord {CrsCode = "FST", StationName = "London Fenchurch Street",},
                new CrsRecord {CrsCode = "KGX", StationName = "London Kings Cross",},
                new CrsRecord {CrsCode = "LST", StationName = "London Liverpool Street",},
                new CrsRecord {CrsCode = "LBG", StationName = "London Bridge",},
                new CrsRecord {CrsCode = "MYB", StationName = "London Marylebone",},
                new CrsRecord {CrsCode = "MOG", StationName = "Moorgate",},
                new CrsRecord {CrsCode = "OLD", StationName = "Old Street",},
                new CrsRecord {CrsCode = "PAD", StationName = "London Paddington",},
                new CrsRecord {CrsCode = "STP", StationName = "London St Pancras International",},
                new CrsRecord {CrsCode = "VXH", StationName = "Vauxhall",},
                new CrsRecord {CrsCode = "VIC", StationName = "London Victoria",},
                new CrsRecord {CrsCode = "WAT", StationName = "London Waterloo",},
                new CrsRecord {CrsCode = "WAE", StationName = "London Waterloo East",},
            };
        }
コード例 #3
0
        protected void Application_Start()
        {
            // Makes the JSON easier to read in a browser without installing an extension like JSONview
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            // Stops the backing field names being used instead of the public property names (*Field & PropertyChanged etc.)
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            // Returns JSON to the browser without needing to add application/json to the accept request header - remove to use XML (becomes the default)
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            // Pass Register into Configure to support attribute routing in the future
            GlobalConfiguration.Configure(WebApiConfig.Register);

            // Load settings
            dynamic config = new Configuration();

            Settings = config.Bind <HuxleySettings>();

            // Set the CRS dictionary passing in embedded CRS path
            CrsCodes = GetCrsCodes(Server.MapPath("~/RailReferences.csv")).Result;
        }
コード例 #4
0
        protected void Application_Start()
        {
            // Makes the JSON easier to read in a browser without installing an extension like JSONview
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            // Stops the backing field names being used instead of the public property names (*Field & PropertyChanged etc.)
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            // Returns JSON to the browser without needing to add application/json to the accept request header - remove to use XML (becomes the default)
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            // Pass Register into Configure to support attribute routing in the future
            GlobalConfiguration.Configure(WebApiConfig.Register);

            // Load settings
            var config = new Configuration();

            Settings = config.Bind <HuxleySettings>();

            // Set the CRS dictionary passing in embedded CRS path
            CrsCodes = GetCrsCodes(Server.MapPath("~/RailReferences.csv")).Result;

            // https://en.wikipedia.org/wiki/London_station_group
            // Farringdon [ZFD] is not a London Terminal but it probably should be (maybe when Crossrail opens it will be)
            LondonTerminals = new List <CrsRecord> {
                new CrsRecord {
                    CrsCode = "BFR", StationName = "London Blackfriars",
                },
                new CrsRecord {
                    CrsCode = "CST", StationName = "London Cannon Street",
                },
                new CrsRecord {
                    CrsCode = "CHX", StationName = "London Charing Cross",
                },
                new CrsRecord {
                    CrsCode = "CTK", StationName = "City Thameslink",
                },
                new CrsRecord {
                    CrsCode = "EUS", StationName = "London Euston",
                },
                new CrsRecord {
                    CrsCode = "FST", StationName = "London Fenchurch Street",
                },
                new CrsRecord {
                    CrsCode = "KGX", StationName = "London Kings Cross",
                },
                new CrsRecord {
                    CrsCode = "LST", StationName = "London Liverpool Street",
                },
                new CrsRecord {
                    CrsCode = "LBG", StationName = "London Bridge",
                },
                new CrsRecord {
                    CrsCode = "MYB", StationName = "London Marylebone",
                },
                new CrsRecord {
                    CrsCode = "MOG", StationName = "Moorgate",
                },
                new CrsRecord {
                    CrsCode = "OLD", StationName = "Old Street",
                },
                new CrsRecord {
                    CrsCode = "PAD", StationName = "London Paddington",
                },
                new CrsRecord {
                    CrsCode = "STP", StationName = "London St Pancras International",
                },
                new CrsRecord {
                    CrsCode = "VXH", StationName = "Vauxhall",
                },
                new CrsRecord {
                    CrsCode = "VIC", StationName = "London Victoria",
                },
                new CrsRecord {
                    CrsCode = "WAT", StationName = "London Waterloo",
                },
                new CrsRecord {
                    CrsCode = "WAE", StationName = "London Waterloo East",
                },
            };
        }