public Server(string name, IUri uri, IRestConsumer restConsumer) { this.UniqueId = Guid.NewGuid(); this.Name = name; this.Uri = uri; this.RestConsumer = restConsumer; }
/// <summary> /// Konstruktor /// </summary> /// <param name="uri">Die Uri des Servers</param> /// <param name="port">Der Port</param> /// <param name="assetBaseFolder">Daten-Basisverzeichnis</param> /// <param name="configBaseFolder">Konfigurationserzeichnis</param> /// <param name="contextPath">Der Basispfad des Servers</param> /// <param name="culture">Die Kultur</param> /// <param name="log">Log</param> public HttpServerContext ( IUri uri, int port, string assetBaseFolder, string configBaseFolder, IUri contextPath, CultureInfo culture, Log log ) { var assembly = typeof(HttpServer).Assembly; Version = assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion; Uri = uri ?? new UriAbsolute(UriScheme.Http, new UriAuthority() { Host = Environment.MachineName, Port = port != 80 ? port : null }, null); Port = port; AssetPath = assetBaseFolder; ConfigPath = configBaseFolder; ContextPath = contextPath; Culture = culture; Log = log; }
/////////////////////////////////////////////////////////////////////////////// // Description: Gets the target part of a relationship with the 'Internal' target mode. /////////////////////////////////////////////////////////////////////////////// private static void GetRelationshipTargetPart(IOpcPartSet partSet, // Set of the parts in the package. IOpcRelationship relationship, // Relationship that targets the required part. string expectedContentType, // Content type expected for the target part. out IOpcPart targetPart // Recieves pointer to target part. Method may return a valid // pointer even on failure, and the caller must always release if a non-default value is returned. ) { targetPart = null; OPC_URI_TARGET_MODE targetMode = relationship.GetTargetMode(); if (targetMode != OPC_URI_TARGET_MODE.OPC_URI_TARGET_MODE_INTERNAL) { // The relationship's target is not a part. var relationshipType = relationship.GetRelationshipType(); Console.Error.Write("Invalid music bundle package: relationship with type {0} must have Internal target mode.\n", relationshipType); // Set the return code to an error. throw new InvalidOperationException(); } // Relationship's target is a part; the target mode is 'Internal'. // Get the URI of the relationship source. IOpcUri sourceUri = relationship.GetSourceUri(); // Get the URI of the relationship target. IUri targetUri = relationship.GetTargetUri(); // Resolve the target URI to the part name of the target part. IOpcPartUri targetPartUri = sourceUri.CombinePartUri(targetUri); // Check that a part with the resolved part name exists in the part set. var partExists = partSet.PartExists(targetPartUri); if (!partExists) { // The part does not exist in the part set. Console.Error.Write("Invalid music bundle package: the target part of relationship does not exist.\n"); // Set the return code to an error. throw new InvalidOperationException(); } // Get the part. targetPart = partSet.GetPart(targetPartUri); // Get the content type of the part. var contentType = targetPart.GetContentType(); if (contentType != expectedContentType) { // Content type of the part did not match the expected content type. Console.Error.Write("Invalid music bundle package: the target part does not have correct content type.\n"); // Set the return code to an error. throw new InvalidOperationException(); } }
public DataService() { this.appSetting = InstanceProvider.GetAppSetting(); this.fileIOService = InstanceProvider.GetTextFromFile(); this.uri = InstanceProvider.GetLocalPath(); this.helloWorldWrapper = InstanceProvider.GetHelloWorld(); }
public void SetUp() { this.mockUri = A.Fake <IUri>(); this.mockRestConsumer = A.Fake <IRestConsumer>(); this.testee = new Server("servername", this.mockUri, mockRestConsumer); }
public void SetUp() { this.mockUri = A.Fake<IUri>(); this.mockRestConsumer = A.Fake<IRestConsumer>(); this.testee = new Server("servername", this.mockUri, mockRestConsumer); }
public virtual IUriBuilder Create(IUri uri) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } return(new UriBuilderWrapper(uri)); }
protected HttpWebRequest GetRequest(IUri service) { var request = (HttpWebRequest)WebRequest.Create(service.Build()); request.ClientCertificates.Add(certificate); request.Method = "GET"; request.ContentType = "application/xml"; request.Headers.Add("x-ms-version", "2012-08-01"); return request; }
int IInternetProtocolEx.StartEx(IUri uri, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { string szUrl; if (uri.GetAbsoluteUri(out szUrl) != NativeConstants.S_OK) { return(NativeConstants.INET_E_INVALID_URL); } return(Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved)); }
/// <summary> /// Verknüft die angegebenen uris zu einer relaiven Uri /// </summary> /// <param name="uri">Eine Uri</param> /// <param name="uris">Die zu verknüpfenden Uris</param> /// <returns>Eine kombinierte Uri</returns> public static UriRelative Combine(IUri uri, params string[] uris) { var copy = new UriRelative(uri as UriRelative); (copy.Path as List <IUriPathSegment>).AddRange(uris.Where(x => !string.IsNullOrWhiteSpace(x)) .SelectMany(x => x.Split('/', StringSplitOptions.RemoveEmptyEntries)) .Select(x => new UriPathSegment(x) as IUriPathSegment)); return(copy); }
private object Get(Type baseType, IUri uri) { var asyncTask = this.httpClient.GetStringAsync(uri); var serializer = wrapperFactory.CreateXmlSerializer(baseType); var result = asyncTask.Result; using (var reader = wrapperFactory.CreateStringReader(result)) { return(serializer.Deserialize(reader)); } }
/// <summary> /// Konstruktor /// </summary> /// <param name="scheme"></param> /// <param name="authority">Die Zuständigkeit (z.B. [email protected]:8080)</param> /// <param name="uri">Die Uri</param> public UriAbsolute(UriScheme scheme, UriAuthority authority, IUri uri) { Scheme = scheme; Authority = authority; if (uri != null) { (Path as List <IUriPathSegment>).AddRange(uri.Path.Select(x => new UriPathSegment(x.Value, x.Tag) as IUriPathSegment)); (Query as List <UriQuerry>).AddRange(uri.Query.Select(x => new UriQuerry(x.Key, x.Value))); Fragment = uri.Fragment; } }
/// <summary> /// Fügt ein Element ein /// </summary> /// <param name="uri">Der Pfad zu der Ressource</param> /// <param name="id">Die RessourcenID</param> public SitemapNode Insert(IUri uri, string id) { // Echter Eintrag if (uri == null || uri.Path.Count < 1) { if (Children.Where(x => x.ID.Equals(id)).FirstOrDefault() is SitemapNode existingChild) { // Ressource bereits vorhanden if (existingChild.Dummy) { existingChild.Dummy = false; return(existingChild); } return(null); } var child = new SitemapNode() { Parent = this, ID = id, Dummy = false }; Children.Add(child); return(child); } var first = uri.Take(1).Path.FirstOrDefault(); var children = Children.Where(x => x.ID.Equals(first.Value, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (children == null) { // Dummy anlegen var dummy = new SitemapNode() { Parent = this, ID = first.Value, PathSegment = new PathSegmentConstant(first.Value?.ToLower(), string.Empty), Title = string.Empty, Dummy = true }; Children.Add(dummy); return(dummy.Insert(uri.Skip(1), id)); } return(children.Insert(uri.Skip(1), id)); }
/// <summary> /// Initializes a new instance of the <see cref="HelloWorldWebService" /> class. /// </summary> /// <param name="restClient">The rest client</param> /// <param name="restRequest">The rest request</param> /// <param name="appSettings">The application settings</param> /// <param name="uriService">The uri service</param> /// <param name="logger">The logger</param> public HelloWorldWebService( IRestClient restClient, IRestRequest restRequest, IAppSettings appSettings, IUri uriService, ILogger logger) { this.restClient = restClient; this.restRequest = restRequest; this.appSettings = appSettings; this.uriService = uriService; this.logger = logger; }
public void SetUp() { var fakeTask = new Task <string>(() => FakeSerializedObjecString); this.fakeUri = A.Fake <IUri>(); A.CallTo(() => fakeUri.ToUri()).Returns(new Uri(BaseUrl)); this.fakeFactory = A.Fake <IWrapperFactory>(); this.fakeHttpClient = A.Fake <IHttpClient>(); A.CallTo(() => this.fakeHttpClient.GetStringAsync(A <IUri> .Ignored)).Returns(fakeTask); this.fakeHttpClient.GetStringAsync(fakeUri).Start(); this.testee = new RestConsumer(fakeUri, this.fakeHttpClient, fakeFactory); }
protected internal virtual Uri AsConcreteUri(IUri uri) { Uri concreteUri = null; // ReSharper disable All if (uri != null) { concreteUri = (uri as IWrapper)?.WrappedInstance as Uri; if (concreteUri == null) { concreteUri = new Uri(uri.OriginalString, UriKind.RelativeOrAbsolute); } } // ReSharper restore All return(concreteUri); }
/// <summary> /// Creates a new IUri object from a url /// </summary> /// <param name="url">Url of a web object</param> /// <returns>IUri object for the given url</returns> public static IUri Create(string url) { // // Create a new null IUri object // IUri uri = null; // // Let the system create a new IUri for the // passed url and set uri to its value // int createUriResult = CreateUri(url, 0, 0, out uri); // // Return the new IUri instance // return(uri); }
void CalculateCurrentDomain() { // Use IUri to parse the current domain into parts IUri uri = ParseUri.Create(Browser.LocationURL); string domain; string host; // Get the current domain and host values uri.GetDomain(out domain); uri.GetHost(out host); int domainPosition = host.LastIndexOf(domain); int hostPosition = Browser.LocationURL.IndexOf(host); if (domainPosition != -1 && domainPosition != -1) { AddressBox.Select(hostPosition + domainPosition, domain.Length); TrueDomain.Text = "Current Domain: " + domain; } else { TrueDomain.Text = "Current Domain: (error)"; } }
/// <summary> /// Konstruktor /// </summary> /// <param name="url">Die URL</param> /// <param name="mediatype">Den Mediatyp</param> public Favicon(IUri url, TypeFavicon mediatype) { Url = url.ToString(); Mediatype = mediatype; }
public IRestConsumer CreateRestConsumer(IUri baseUri, IHttpClient httpClientHandler, IWrapperFactory wrapperFactory) { return new RestConsumer(baseUri, httpClientHandler, wrapperFactory); }
public IUri MakeRelativeUri(IUri uri) => new Uri(Inner.MakeRelativeUri(((Uri)uri).Inner));
/// <summary> /// Konstruktor /// </summary> /// <param name="contextPath">Der Kontextpfad</param> /// <param name="uri">Die eigentliche Uri</param> public UriResource(IUri contextPath, string uri) { ContextPath = contextPath; Uri = string.IsNullOrWhiteSpace(uri) ? new UriRelative() : new UriRelative(uri); }
public WebService(IRestClient restClient, IRestRequest restRequest, IAppSettings appSettings, IUri uriService, ILogger logger) { restClient = _restClient; restRequest = _restRequest; appSettings = _appSettings; uriService = _uriService; logger = _logger; }
/// <summary> /// Prüft, ob eine gegebene Uri Teil dieser Uri ist /// </summary> /// <param name="uri">Die zu prüfende Uri</param> /// <returns>true, wenn Teil der Uri</returns> public bool StartsWith(IUri uri) { return(ToString().StartsWith(uri.ToString())); }
/// <summary> /// Weiterleitung an eine andere Seite /// Die Funktion löst die RedirectException aus /// </summary> /// <param name="uri">Die URL zu der weitergeleitet werden soll</param> public void Redirecting(IUri uri) { throw new RedirectException(uri?.ToString()); }
public Task<string> GetStringAsync(IUri uri) { return httpClient.GetStringAsync(uri.ToUri()); }
public virtual bool IsBaseOf(IUri uri) { return(this.WrappedInstance.IsBaseOf(this.AsConcreteUri(uri))); }
public int CompareTo(IUri other) { return(string.Compare(normalisedName, other.toNormalisedString())); }
public IUri CreateUri(IUri baseUri, string relativeUri) { return new UriWrapper(new Uri(baseUri.ToUri(), relativeUri)); }
public IUri Create3(IUri baseUri, string relativeUri) { return(new Uri(new System.Uri(((Uri)baseUri).Inner, relativeUri))); }
public IUri Create4(IUri baseUri, IUri relativeUri) { return(new Uri(new System.Uri(((Uri)baseUri).Inner, ((Uri)relativeUri).Inner))); }
public void SetUp() { var fakeTask = new Task<string>(() => FakeSerializedObjecString); this.fakeUri = A.Fake<IUri>(); A.CallTo(() => fakeUri.ToUri()).Returns(new Uri(BaseUrl)); this.fakeFactory = A.Fake<IWrapperFactory>(); this.fakeHttpClient = A.Fake<IHttpClient>(); A.CallTo(() => this.fakeHttpClient.GetStringAsync(A<IUri>.Ignored)).Returns(fakeTask); this.fakeHttpClient.GetStringAsync(fakeUri).Start(); this.testee = new RestConsumer(fakeUri, this.fakeHttpClient, fakeFactory); }
public bool IsBaseOf(IUri uri) => Inner.IsBaseOf(((Uri)uri).Inner);
public bool Equals(IUri other) { return(CompareTo(other) == 0); }
/// <summary> /// Konstruktor /// </summary> /// <param name="contextPath">Der Kontextpfad</param> /// <param name="uri">Die eigentliche Uri</param> public UriResource(IUri contextPath, IUri uri = null) { ContextPath = contextPath; Uri = uri ?? new UriRelative(); }
int IInternetProtocolEx.StartEx(IUri uri, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { string szUrl; if (uri.GetAbsoluteUri(out szUrl) != NativeConstants.S_OK) return NativeConstants.INET_E_INVALID_URL; return Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved); }
public IUri CreateUri(IUri baseUri, string relativeUri) { return(new UriWrapper(new Uri(baseUri.ToUri(), relativeUri))); }