예제 #1
0
        private void ShowBoundaryElement(BoundarySettings element)
        {
            EditorGUILayout.BeginVertical("box");
            {
                BoundaryType saveKind = element.Type;
                element.Type = (BoundaryType)EditorGUILayout.EnumPopup("Type Boundary:", element.Type);
                if (GUI.changed && saveKind != element.Type)
                {
                    if (UsingType.Contains("bt_" + saveKind.ToString()))
                    {
                        UsingType.Remove("bt_" + saveKind.ToString());
                    }
                    UsingType.Add("bt_" + element.Type.ToString());
                }

                element.Material = (Material)EditorGUILayout.ObjectField("Material", element.Material, typeof(Material));

                if (element.Material == null)
                {
                    DisplayErrorMEssage("Not setting material");
                }
                element.Width = EditorGUILayout.FloatField("Boundary Width", element.Width);
            }
            EditorGUILayout.EndVertical();
        }
예제 #2
0
        /// <summary>Calculates interpolated values using Cubic Spline Interpolation</summary>
        /// <param name="x">X values at which interpolated values are required</param>
        /// <param name="leftBoundaryType">BoundaryType enumeration (Parabolic, FirstDerivative Specified, SecondDerivative Specified)</param>
        /// <param name="leftBoundaryTypeParameter">Parameter required (ignored if Parabolic)</param>
        /// <param name="rightBoundaryType">BoundaryType enumeration (Parabolic, FirstDerivative Specified, SecondDerivative Specified)</param>
        /// <param name="rightBoundaryTypeParameter">Parameter required (ignored if Parabolic)</param>
        /// <returns>Interpolated values </returns>
        /// <remarks><para></para>
        /// </remarks>
        public double[] GetValuesCubicSpline(double[] xi, BoundaryType leftBoundaryType, double leftBoundaryTypeParameter,
                                             BoundaryType rightBoundaryType, double rightBoundaryTypeParameter)
        {
            if (cubicSplineCoefficients == null)
            {
                UpdateCubicSplineCoefficients(leftBoundaryType, leftBoundaryTypeParameter, rightBoundaryType, rightBoundaryTypeParameter);
            }

            double[] interpolatedValues = new double[xi.Length];
            for (int i = 0; i < xi.Length; ++i)
            {
                double xit = xi[i];
                int    p = 0; int r = n - 1; int q = 0;
                while (p != r - 1)
                {
                    q = (p + r) / 2;
                    if (x[q] >= xit)
                    {
                        r = q;
                    }
                    else
                    {
                        p = q;
                    }
                }
                xit = xit - x[p];
                q   = p * 4;
                interpolatedValues[i] = cubicSplineCoefficients[q] + xit * (cubicSplineCoefficients[q + 1]
                                                                            + xit * (cubicSplineCoefficients[q + 2] + xit * cubicSplineCoefficients[q + 3]));
            }
            return(interpolatedValues);
        }
예제 #3
0
 public void Reset()
 {
     if (_responseState >= ResponseState.StartedSending)
     {
         _requestContext.Abort();
         throw new InvalidOperationException("The response has already been sent. Request Aborted.");
     }
     // We haven't started yet, or we're just buffered, we can clear any data, headers, and state so
     // that we can start over (e.g. to write an error message).
     _nativeResponse     = new HttpApi.HTTP_RESPONSE_V2();
     _headers.IsReadOnly = false;
     _headers.Clear();
     _reasonPhrase = null;
     _boundaryType = BoundaryType.None;
     _nativeResponse.Response_V1.StatusCode           = (ushort)HttpStatusCode.OK;
     _nativeResponse.Response_V1.Version.MajorVersion = 1;
     _nativeResponse.Response_V1.Version.MinorVersion = 1;
     _responseState      = ResponseState.Created;
     _onStartingActions  = new List <Tuple <Func <object, Task>, object> >();
     _onCompletedActions = new List <Tuple <Func <object, Task>, object> >();
     _bufferingEnabled   = _requestContext.Server.BufferResponses;
     _expectedBodyLength = 0;
     _nativeStream       = null;
     CacheTtl            = null;
 }
예제 #4
0
        /// <inheritdoc />
        public override Result GetBoundaryGeometry(IntPtr sessionPtr, BoundaryType boundaryType, out Vector3f[] floorPoints)
        {
            int out_FloorPointsCount = 0;

            // In first call we get number of points back (called with floorPointPtr == Zero)
            var result = SafeNativeMethods.ovr_GetBoundaryGeometry(sessionPtr, boundaryType, IntPtr.Zero, ref out_FloorPointsCount);

            if (result != Result.Success || out_FloorPointsCount == 0)
            {
                floorPoints = null;
                return(result);
            }

            floorPoints = new Vector3f[out_FloorPointsCount];

            GCHandle gcHandle = GCHandle.Alloc(floorPoints, GCHandleType.Pinned);

            try
            {
                result = SafeNativeMethods.ovr_GetBoundaryGeometry(sessionPtr, boundaryType, gcHandle.AddrOfPinnedObject(), ref out_FloorPointsCount);
            }
            finally
            {
                gcHandle.Free();
            }

            return(result);
        }
예제 #5
0
 public static bool RemoveBoundary(Moba_Camera_Boundary boundary, BoundaryType type)
 {
     if (type == BoundaryType.cube)
     {
         return(cube_boundaries.Remove(boundary));
     }
     return((type == BoundaryType.sphere) && cube_boundaries.Remove(boundary));
 }
예제 #6
0
        public Property IntervalCreatesValidIntervalsOrThrows(BoundaryType lowerBoundaryType, T lowerBoundaryValue, T upperBoundaryValue, BoundaryType upperBoundaryType)
        {
            var result = Result.From(() => Interval.Create <T, TComparer>(lowerBoundaryType, lowerBoundaryValue, upperBoundaryValue, upperBoundaryType));

            if (lowerBoundaryValue is null || upperBoundaryValue is null)
            {
                return((!result.HasValue && result.Exception is ArgumentNullException).ToProperty());
            }
예제 #7
0
    public void ReplaceBoundaryType(BoundaryType newValue)
    {
        var index     = GameComponentsLookup.BoundaryType;
        var component = (BoundaryTypeComponent)CreateComponent(index, typeof(BoundaryTypeComponent));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
예제 #8
0
 public PLNA ConvertPolygonType(BoundaryType polygonType)
 {
     if (polygonType == BoundaryType.Field)
         return PLNA.Item1;
     if (polygonType == BoundaryType.CropZone)
         return PLNA.Item2;
     return PLNA.Item8; //other
 }
예제 #9
0
파일: Request.cs 프로젝트: jnm2/AspNetCore
        internal Request(RequestContext requestContext, NativeRequestContext nativeRequestContext)
        {
            // TODO: Verbose log
            RequestContext        = requestContext;
            _nativeRequestContext = nativeRequestContext;
            _contentBoundaryType  = BoundaryType.None;

            RequestId     = nativeRequestContext.RequestId;
            UConnectionId = nativeRequestContext.ConnectionId;
            SslStatus     = nativeRequestContext.SslStatus;

            KnownMethod = nativeRequestContext.VerbId;
            Method      = _nativeRequestContext.GetVerb();

            RawUrl = nativeRequestContext.GetRawUrl();

            var cookedUrl = nativeRequestContext.GetCookedUrl();

            QueryString = cookedUrl.GetQueryString() ?? string.Empty;

            var prefix = requestContext.Server.Options.UrlPrefixes.GetPrefix((int)nativeRequestContext.UrlContext);

            var rawUrlInBytes = _nativeRequestContext.GetRawUrlInBytes();
            var originalPath  = RequestUriBuilder.DecodeAndUnescapePath(rawUrlInBytes);

            // 'OPTIONS * HTTP/1.1'
            if (KnownMethod == HttpApiTypes.HTTP_VERB.HttpVerbOPTIONS && string.Equals(RawUrl, "*", StringComparison.Ordinal))
            {
                PathBase = string.Empty;
                Path     = string.Empty;
            }
            // These paths are both unescaped already.
            else if (originalPath.Length == prefix.Path.Length - 1)
            {
                // They matched exactly except for the trailing slash.
                PathBase = originalPath;
                Path     = string.Empty;
            }
            else
            {
                // url: /base/path, prefix: /base/, base: /base, path: /path
                // url: /, prefix: /, base: , path: /
                PathBase = originalPath.Substring(0, prefix.Path.Length - 1);
                Path     = originalPath.Substring(prefix.Path.Length - 1);
            }

            ProtocolVersion = _nativeRequestContext.GetVersion();

            Headers = new RequestHeaders(_nativeRequestContext);

            User = _nativeRequestContext.GetUser();

            // GetTlsTokenBindingInfo(); TODO: https://github.com/aspnet/HttpSysServer/issues/231

            // Finished directly accessing the HTTP_REQUEST structure.
            _nativeRequestContext.ReleasePins();
            // TODO: Verbose log parameters
        }
예제 #10
0
        //显示边界警告
        public void DisplayBoundaryWarn(Vector2 pos, BoundaryType type)
        {
            if (type == BoundaryType.Right)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Right)
                {
                    boundaryWarner.Rotate(boundaryWarner.Rotation);
                    boundaryWarner.Rotate(GameBase.Right);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Left)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Left)
                {
                    boundaryWarner.Rotate(boundaryWarner.Rotation);
                    boundaryWarner.Rotate(GameBase.Left);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Up)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Down)
                {
                    boundaryWarner.Rotate(GameBase.Right);
                    boundaryWarner.Rotate(GameBase.Down);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Down)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Up)
                {
                    boundaryWarner.Rotate(GameBase.Right);
                    boundaryWarner.Rotate(GameBase.Up);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }
        }
예제 #11
0
        internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"httpContext:${httpContext} memoryBlob {((IntPtr)memoryBlob.RequestBlob)}");
                NetEventSource.Associate(this, httpContext);
            }
            _httpContext  = httpContext;
            _memoryBlob   = memoryBlob;
            _boundaryType = BoundaryType.None;

            // Set up some of these now to avoid refcounting on memory blob later.
            _requestId    = memoryBlob.RequestBlob->RequestId;
            _connectionId = memoryBlob.RequestBlob->ConnectionId;
            _sslStatus    = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure :
                            memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert :
                            SslStatus.ClientCert;
            if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0)
            {
                _rawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
            }

            Interop.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
            if (cookedUrl.pHost != null && cookedUrl.HostLength > 0)
            {
                _cookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
            }
            if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0)
            {
                _cookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
            }
            if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0)
            {
                _cookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
            }
            _version         = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion);
            _clientCertState = ListenerClientCertState.NotInitialized;
            _keepAlive       = null;
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"RequestId:{RequestId} ConnectionId:{_connectionId} RawConnectionId:{memoryBlob.RequestBlob->RawConnectionId} UrlContext:{memoryBlob.RequestBlob->UrlContext} RawUrl:{_rawUrl} Version:{_version} Secure:{_sslStatus}");
                NetEventSource.Info(this, $"httpContext:${httpContext} RequestUri:{RequestUri} Content-Length:{ContentLength64} HTTP Method:{HttpMethod}");
            }
            // Log headers
            if (NetEventSource.IsEnabled)
            {
                StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n");
                for (int i = 0; i < Headers.Count; i++)
                {
                    sb.Append("\t");
                    sb.Append(Headers.GetKey(i));
                    sb.Append(" : ");
                    sb.Append(Headers.Get(i));
                    sb.Append("\n");
                }
                NetEventSource.Info(this, sb.ToString());
            }
        }
예제 #12
0
        internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"httpContext:${httpContext} memoryBlob {((IntPtr)memoryBlob.RequestBlob)}");
                NetEventSource.Associate(this, httpContext);
            }
            _httpContext = httpContext;
            _memoryBlob = memoryBlob;
            _boundaryType = BoundaryType.None;

            // Set up some of these now to avoid refcounting on memory blob later.
            _requestId = memoryBlob.RequestBlob->RequestId;
            _connectionId = memoryBlob.RequestBlob->ConnectionId;
            _sslStatus = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure :
                memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert :
                SslStatus.ClientCert;
            if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0)
            {
                _rawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
            }

            Interop.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
            if (cookedUrl.pHost != null && cookedUrl.HostLength > 0)
            {
                _cookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
            }
            if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0)
            {
                _cookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
            }
            if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0)
            {
                _cookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
            }
            _version = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion);
            _clientCertState = ListenerClientCertState.NotInitialized;
            _keepAlive = null;
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"RequestId:{RequestId} ConnectionId:{_connectionId} RawConnectionId:{memoryBlob.RequestBlob->RawConnectionId} UrlContext:{memoryBlob.RequestBlob->UrlContext} RawUrl:{_rawUrl} Version:{_version} Secure:{_sslStatus}");
                NetEventSource.Info(this, $"httpContext:${httpContext} RequestUri:{RequestUri} Content-Length:{ContentLength64} HTTP Method:{HttpMethod}");
            }
            // Log headers
            if (NetEventSource.IsEnabled)
            {
                StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n");
                for (int i = 0; i < Headers.Count; i++)
                {
                    sb.Append("\t");
                    sb.Append(Headers.GetKey(i));
                    sb.Append(" : ");
                    sb.Append(Headers.Get(i));
                    sb.Append("\n");
                }
                NetEventSource.Info(this, sb.ToString());
            }
        }
예제 #13
0
        async Task <ScanContentResults> ScanContentAsync(Stream content, bool trimNewLine, CancellationToken cancellationToken)
        {
            int          atleast      = Math.Max(ReadAheadSize, GetMaxBoundaryLength());
            BoundaryType found        = BoundaryType.None;
            int          contentIndex = inputIndex;
            bool         midline      = false;
            int          nleft;

            do
            {
                if (contentIndex < inputIndex)
                {
                    content.Write(input, contentIndex, inputIndex - contentIndex);
                }

                nleft = inputEnd - inputIndex;
                if (await ReadAheadAsync(atleast, 2, cancellationToken).ConfigureAwait(false) <= 0)
                {
                    contentIndex = inputIndex;
                    found        = BoundaryType.Eos;
                    break;
                }

                unsafe
                {
                    fixed(byte *inbuf = input)
                    {
                        ScanContent(inbuf, ref contentIndex, ref nleft, ref midline, ref found);
                    }
                }
            } while (found == BoundaryType.None);

            if (contentIndex < inputIndex)
            {
                content.Write(input, contentIndex, inputIndex - contentIndex);
            }

            var empty = content.Length == 0;

            if (found != BoundaryType.Eos && trimNewLine)
            {
                // the last \r\n belongs to the boundary
                if (content.Length > 0)
                {
                    if (input[inputIndex - 2] == (byte)'\r')
                    {
                        content.SetLength(content.Length - 2);
                    }
                    else
                    {
                        content.SetLength(content.Length - 1);
                    }
                }
            }

            return(new ScanContentResults(found, empty));
        }
예제 #14
0
        /// <inheritdoc />
        public override Result GetBoundaryDimensions(IntPtr sessionPtr, BoundaryType boundaryType, out Vector3f dimensions)
        {
            var dimensionValues = new float[3];
            var result          = SafeNativeMethods.ovr_GetBoundaryDimensions(sessionPtr, boundaryType, dimensionValues);

            dimensions = new Vector3f(dimensionValues[0], dimensionValues[1], dimensionValues[2]);

            return(result);
        }
예제 #15
0
    protected BoundarySettings createBoundarySettings(BoundaryType type, int width, string material)
    {
        var bs = new BoundarySettings();

        bs.Type     = type;
        bs.Material = (Material)Resources.Load(material, typeof(Material));
        bs.Width    = width;
        return(bs);
    }
        public Property InvalidBoundariesThrowAndValidOnesDoNot(BoundaryType boundaryType, T value)
        {
            var boundary    = CreateBoundary(value, boundaryType);
            var valueResult = Result.From(() => boundary.Value);
            var typeResult  = Result.From(() => boundary.Type);

            return(InvalidBoundaryValue.IsInvalidBoundaryValue <T, TComparer>(value) ?
                   (valueResult.Exception is InvalidOperationException && typeResult.Exception is InvalidOperationException && !boundary.IsValid).ToProperty() :
                   (valueResult.HasValue && typeResult.HasValue && boundary.IsValid).ToProperty());
        }
예제 #17
0
        internal Request(RequestContext requestContext, NativeRequestContext nativeRequestContext)
        {
            // TODO: Verbose log
            RequestContext        = requestContext;
            _nativeRequestContext = nativeRequestContext;
            _contentBoundaryType  = BoundaryType.None;

            RequestId     = nativeRequestContext.RequestId;
            UConnectionId = nativeRequestContext.ConnectionId;
            SslStatus     = nativeRequestContext.SslStatus;

            KnownMethod = nativeRequestContext.VerbId;
            Method      = _nativeRequestContext.GetVerb();

            RawUrl = nativeRequestContext.GetRawUrl();

            var cookedUrl = nativeRequestContext.GetCookedUrl();

            QueryString = cookedUrl.GetQueryString() ?? string.Empty;

            var rawUrlInBytes = _nativeRequestContext.GetRawUrlInBytes();
            var originalPath  = RequestUriBuilder.DecodeAndUnescapePath(rawUrlInBytes);

            // 'OPTIONS * HTTP/1.1'
            if (KnownMethod == HttpApiTypes.HTTP_VERB.HttpVerbOPTIONS && string.Equals(RawUrl, "*", StringComparison.Ordinal))
            {
                PathBase = string.Empty;
                Path     = string.Empty;
            }
            else if (requestContext.Server.RequestQueue.Created)
            {
                var prefix = requestContext.Server.Options.UrlPrefixes.GetPrefix((int)nativeRequestContext.UrlContext);

                if (originalPath.Length == prefix.PathWithoutTrailingSlash.Length)
                {
                    // They matched exactly except for the trailing slash.
                    PathBase = originalPath;
                    Path     = string.Empty;
                }
                else
                {
                    // url: /base/path, prefix: /base/, base: /base, path: /path
                    // url: /, prefix: /, base: , path: /
                    PathBase = originalPath.Substring(0, prefix.PathWithoutTrailingSlash.Length); // Preserve the user input casing
                    Path     = originalPath.Substring(prefix.PathWithoutTrailingSlash.Length);
                }
            }
            else
            {
                // When attaching to an existing queue, the UrlContext hint may not match our configuration. Search manualy.
                if (requestContext.Server.Options.UrlPrefixes.TryMatchLongestPrefix(IsHttps, cookedUrl.GetHost(), originalPath, out var pathBase, out var path))
                {
                    PathBase = pathBase;
                    Path     = path;
                }
 internal unsafe HttpListenerRequest(System.Net.HttpListenerContext httpContext, RequestContextBase memoryBlob)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob));
     }
     if (Logging.On)
     {
         Logging.Associate(Logging.HttpListener, this, httpContext);
     }
     this.m_HttpContext = httpContext;
     this.m_MemoryBlob = memoryBlob;
     this.m_BoundaryType = BoundaryType.None;
     this.m_RequestId = memoryBlob.RequestBlob.RequestId;
     this.m_ConnectionId = memoryBlob.RequestBlob.ConnectionId;
     this.m_SslStatus = (memoryBlob.RequestBlob.pSslInfo == null) ? SslStatus.Insecure : ((memoryBlob.RequestBlob.pSslInfo.SslClientCertNegotiated == 0) ? SslStatus.NoClientCert : SslStatus.ClientCert);
     if ((memoryBlob.RequestBlob.pRawUrl != null) && (memoryBlob.RequestBlob.RawUrlLength > 0))
     {
         this.m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob.pRawUrl, memoryBlob.RequestBlob.RawUrlLength);
     }
     UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob.CookedUrl;
     if ((cookedUrl.pHost != null) && (cookedUrl.HostLength > 0))
     {
         this.m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr) cookedUrl.pHost, cookedUrl.HostLength / 2);
     }
     if ((cookedUrl.pAbsPath != null) && (cookedUrl.AbsPathLength > 0))
     {
         this.m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr) cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
     }
     if ((cookedUrl.pQueryString != null) && (cookedUrl.QueryStringLength > 0))
     {
         this.m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr) cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
     }
     this.m_Version = new Version(memoryBlob.RequestBlob.Version.MajorVersion, memoryBlob.RequestBlob.Version.MinorVersion);
     this.m_ClientCertState = ListenerClientCertState.NotInitialized;
     this.m_KeepAlive = TriState.Unspecified;
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " RequestUri:" + ValidationHelper.ToString(this.RequestUri) + " Content-Length:" + ValidationHelper.ToString(this.ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(this.HttpMethod));
     }
     if (Logging.On)
     {
         StringBuilder builder = new StringBuilder("HttpListenerRequest Headers:\n");
         for (int i = 0; i < this.Headers.Count; i++)
         {
             builder.Append("\t");
             builder.Append(this.Headers.GetKey(i));
             builder.Append(" : ");
             builder.Append(this.Headers.Get(i));
             builder.Append("\n");
         }
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", builder.ToString());
     }
 }
 internal unsafe HttpListenerRequest(System.Net.HttpListenerContext httpContext, RequestContextBase memoryBlob)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr)memoryBlob.RequestBlob));
     }
     if (Logging.On)
     {
         Logging.Associate(Logging.HttpListener, this, httpContext);
     }
     this.m_HttpContext  = httpContext;
     this.m_MemoryBlob   = memoryBlob;
     this.m_BoundaryType = BoundaryType.None;
     this.m_RequestId    = memoryBlob.RequestBlob.RequestId;
     this.m_ConnectionId = memoryBlob.RequestBlob.ConnectionId;
     this.m_SslStatus    = (memoryBlob.RequestBlob.pSslInfo == null) ? SslStatus.Insecure : ((memoryBlob.RequestBlob.pSslInfo.SslClientCertNegotiated == 0) ? SslStatus.NoClientCert : SslStatus.ClientCert);
     if ((memoryBlob.RequestBlob.pRawUrl != null) && (memoryBlob.RequestBlob.RawUrlLength > 0))
     {
         this.m_RawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob.pRawUrl, memoryBlob.RequestBlob.RawUrlLength);
     }
     UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob.CookedUrl;
     if ((cookedUrl.pHost != null) && (cookedUrl.HostLength > 0))
     {
         this.m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
     }
     if ((cookedUrl.pAbsPath != null) && (cookedUrl.AbsPathLength > 0))
     {
         this.m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
     }
     if ((cookedUrl.pQueryString != null) && (cookedUrl.QueryStringLength > 0))
     {
         this.m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
     }
     this.m_Version         = new Version(memoryBlob.RequestBlob.Version.MajorVersion, memoryBlob.RequestBlob.Version.MinorVersion);
     this.m_ClientCertState = ListenerClientCertState.NotInitialized;
     this.m_KeepAlive       = TriState.Unspecified;
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " RequestUri:" + ValidationHelper.ToString(this.RequestUri) + " Content-Length:" + ValidationHelper.ToString(this.ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(this.HttpMethod));
     }
     if (Logging.On)
     {
         StringBuilder builder = new StringBuilder("HttpListenerRequest Headers:\n");
         for (int i = 0; i < this.Headers.Count; i++)
         {
             builder.Append("\t");
             builder.Append(this.Headers.GetKey(i));
             builder.Append(" : ");
             builder.Append(this.Headers.Get(i));
             builder.Append("\n");
         }
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", builder.ToString());
     }
 }
예제 #20
0
 public static BoundaryTestResult TestBoundaryPoint(Vector3f point, BoundaryType boundaryType)
 {
     if (version >= OVRP_1_8_0.version)
     {
         return(OVRP_1_8_0.ovrp_TestBoundaryPoint(point, boundaryType));
     }
     else
     {
         return(new BoundaryTestResult());
     }
 }
예제 #21
0
 public static Vector3f GetBoundaryDimensions(BoundaryType boundaryType)
 {
     if (version >= OVRP_1_8_0.version)
     {
         return(OVRP_1_8_0.ovrp_GetBoundaryDimensions(boundaryType));
     }
     else
     {
         return(new Vector3f());
     }
 }
예제 #22
0
 public static BoundaryTestResult TestBoundaryNode(Node nodeId, BoundaryType boundaryType)
 {
     if (version >= OVRP_1_8_0.version)
     {
         return(OVRP_1_8_0.ovrp_TestBoundaryNode(nodeId, boundaryType));
     }
     else
     {
         return(new BoundaryTestResult());
     }
 }
예제 #23
0
 public static BoundaryGeometry GetBoundaryGeometry(BoundaryType boundaryType)
 {
     if (version >= OVRP_1_8_0.version)
     {
         return(OVRP_1_8_0.ovrp_GetBoundaryGeometry(boundaryType));
     }
     else
     {
         return(new BoundaryGeometry());
     }
 }
 internal HttpListenerResponse()
 {
     if (NetEventSource.IsEnabled) NetEventSource.Info(this);
     _nativeResponse = new Interop.HttpApi.HTTP_RESPONSE();
     _boundaryType = BoundaryType.None;
     _nativeResponse.StatusCode = (ushort)HttpStatusCode.OK;
     _nativeResponse.Version.MajorVersion = 1;
     _nativeResponse.Version.MinorVersion = 1;
     _keepAlive = true;
     _responseState = ResponseState.Created;
 }
 internal HttpListenerResponse() {
     if(Logging.On)Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "");
     m_NativeResponse = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE();
     m_WebHeaders = new WebHeaderCollection(WebHeaderCollectionType.HttpListenerResponse);
     m_BoundaryType = BoundaryType.None;
     m_NativeResponse.StatusCode = (ushort)HttpStatusCode.OK;
     m_NativeResponse.Version.MajorVersion = 1;
     m_NativeResponse.Version.MinorVersion = 1;
     m_KeepAlive = true;
     m_ResponseState = ResponseState.Created;
 }
예제 #26
0
 public PLNA ConvertPolygonType(BoundaryType polygonType)
 {
     if (polygonType == BoundaryType.Field)
     {
         return(PLNA.Item1);
     }
     if (polygonType == BoundaryType.CropZone)
     {
         return(PLNA.Item2);
     }
     return(PLNA.Item8); //other
 }
예제 #27
0
    internal Request(RequestContext requestContext)
    {
        // TODO: Verbose log
        RequestContext       = requestContext;
        _contentBoundaryType = BoundaryType.None;

        RequestId = requestContext.RequestId;
        // For HTTP/2 Http.Sys assigns each request a unique connection id for use with API calls, but the RawConnectionId represents the real connection.
        UConnectionId   = requestContext.ConnectionId;
        RawConnectionId = requestContext.RawConnectionId;
        SslStatus       = requestContext.SslStatus;

        KnownMethod = requestContext.VerbId;
        Method      = requestContext.GetVerb() !;

        RawUrl = requestContext.GetRawUrl() !;

        var cookedUrl = requestContext.GetCookedUrl();

        QueryString = cookedUrl.GetQueryString() ?? string.Empty;

        var rawUrlInBytes = requestContext.GetRawUrlInBytes();
        var originalPath  = RequestUriBuilder.DecodeAndUnescapePath(rawUrlInBytes);

        PathBase = string.Empty;
        Path     = originalPath;

        // 'OPTIONS * HTTP/1.1'
        if (KnownMethod == HttpApiTypes.HTTP_VERB.HttpVerbOPTIONS && string.Equals(RawUrl, "*", StringComparison.Ordinal))
        {
            PathBase = string.Empty;
            Path     = string.Empty;
        }
        else
        {
            var prefix = requestContext.Server.Options.UrlPrefixes.GetPrefix((int)requestContext.UrlContext);
            // Prefix may be null if the requested has been transfered to our queue
            if (!(prefix is null))
            {
                if (originalPath.Length == prefix.PathWithoutTrailingSlash.Length)
                {
                    // They matched exactly except for the trailing slash.
                    PathBase = originalPath;
                    Path     = string.Empty;
                }
                else
                {
                    // url: /base/path, prefix: /base/, base: /base, path: /path
                    // url: /, prefix: /, base: , path: /
                    PathBase = originalPath.Substring(0, prefix.PathWithoutTrailingSlash.Length); // Preserve the user input casing
                    Path     = originalPath.Substring(prefix.PathWithoutTrailingSlash.Length);
                }
            }
예제 #28
0
 internal HttpListenerResponse()
 {
     if (NetEventSource.IsEnabled) NetEventSource.Info(this);
     _nativeResponse = new Interop.HttpApi.HTTP_RESPONSE();
     _webHeaders = new WebHeaderCollection();
     _boundaryType = BoundaryType.None;
     _nativeResponse.StatusCode = (ushort)HttpStatusCode.OK;
     _nativeResponse.Version.MajorVersion = 1;
     _nativeResponse.Version.MinorVersion = 1;
     _keepAlive = true;
     _responseState = ResponseState.Created;
 }
예제 #29
0
        protected override bool IsDirichlet(ref CommonParamsBnd inp) {
            BoundaryType edgeType = m_boundaryCondMap.EdgeTag2Type[inp.EdgeTag];
            switch (edgeType) {
                case BoundaryType.Dirichlet:
                    return true;

                case BoundaryType.Neumann:
                    return false;

                default:
                    throw new NotImplementedException();
            }
        }
예제 #30
0
        public PLN Map(MultiPolygon polygon, BoundaryType type, string name)
        {
            var isoPolygon = new PLN
            {
                A = ConvertPolygonType(type),
                B = name
            };
            var exteriors = polygon.Polygons.Select(p => p.ExteriorRing).SelectMany(x => Map(x, LSGA.Item1));
            var interiors = polygon.Polygons.SelectMany(p => p.InteriorRings).SelectMany(x => Map(x, LSGA.Item2));
            isoPolygon.Items = exteriors.Concat(interiors).ToArray();

            return isoPolygon;
        }
예제 #31
0
    public static bool GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount)
    {
        if (version >= OVRP_1_9_0.version)
        {
            return(OVRP_1_9_0.ovrp_GetBoundaryGeometry2(boundaryType, points, ref pointsCount) == OVRPlugin.Bool.True);
        }
        else
        {
            pointsCount = 0;

            return(false);
        }
    }
예제 #32
0
 public void SetBoundary(int side, BoundaryType boundarytype, double value, double hcoeff = 0)
 {
     boundaryType = boundarytype;
     isboundary = true;
     htranscoeff = hcoeff;
     if (boundaryType == BoundaryType.BND_CONST || boundaryType == BoundaryType.BND_SURROUNDCONVECT)
     {
         bndu = value;
     }
     else if (boundaryType == BoundaryType.BND_FLUX)
     {
         bndflux = value;
     }
 }
예제 #33
0
파일: Face.cs 프로젝트: snytav/FiniteVolume
 public void SetBoundary(int side, BoundaryType boundarytype, double value, double hcoeff = 0)
 {
     boundaryType = boundarytype;
     isboundary   = true;
     htranscoeff  = hcoeff;
     if (boundaryType == BoundaryType.BND_CONST || boundaryType == BoundaryType.BND_SURROUNDCONVECT)
     {
         bndu = value;
     }
     else if (boundaryType == BoundaryType.BND_FLUX)
     {
         bndflux = value;
     }
 }
예제 #34
0
파일: Face.cs 프로젝트: snytav/FiniteVolume
        public void SetBoundary(BoundaryType boundarytype, double value, double hcoeff = 0)
        {
            boundaryType = boundarytype;
            isboundary   = true;
            htranscoeff  = hcoeff;
            if (boundaryType == BoundaryType.BND_CONST)// || boundaryType == BoundaryType.BND_SURROUNDCONVECT)
            {
                bndu = value;
            }
//            else if (boundaryType == BoundaryType.BND_FLUX)
//            {
//                bndflux = value;
//            }
        }
예제 #35
0
 public Manipulator(FrameworkElement element, FrameworkElement pushed, FrameworkElement shadow, FrameworkElement relative)
 {
     this.element            = element;
     this.pushed             = pushed;
     this.relative           = relative;
     this.shadow             = shadow;
     element.RenderTransform = actualTranslation;
     pushed.RenderTransform  = actualTranslation;
     if (shadow != null)
     {
         shadow.RenderTransform = shadowTranslation;
     }
     boundaryType = BoundaryType.CIRCULAR;
 }
예제 #36
0
        public void SetBoundary(BoundaryType boundarytype, double value, double hcoeff = 0)
        {
            boundaryType = boundarytype;
            isboundary = true;
            htranscoeff = hcoeff;
            if (boundaryType == BoundaryType.BND_CONST)// || boundaryType == BoundaryType.BND_SURROUNDCONVECT)
            {
                bndu = value;
            }
//            else if (boundaryType == BoundaryType.BND_FLUX)
//            {
//                bndflux = value;
//            }
        }
예제 #37
0
        public PLN Map(MultiPolygon polygon, BoundaryType type, string name)
        {
            var isoPolygon = new PLN
            {
                A = ConvertPolygonType(type),
                B = name
            };
            var exteriors = polygon.Polygons.Select(p => p.ExteriorRing).SelectMany(x => Map(x, LSGA.Item1));
            var interiors = polygon.Polygons.SelectMany(p => p.InteriorRings).SelectMany(x => Map(x, LSGA.Item2));

            isoPolygon.Items = exteriors.Concat(interiors).ToArray();

            return(isoPolygon);
        }
예제 #38
0
 internal HttpListenerResponse()
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "");
     }
     m_NativeResponse                      = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE();
     m_WebHeaders                          = new WebHeaderCollection(WebHeaderCollectionType.HttpListenerResponse);
     m_BoundaryType                        = BoundaryType.None;
     m_NativeResponse.StatusCode           = (ushort)HttpStatusCode.OK;
     m_NativeResponse.Version.MajorVersion = 1;
     m_NativeResponse.Version.MinorVersion = 1;
     m_KeepAlive     = true;
     m_ResponseState = ResponseState.Created;
 }
        public BlockBoundaryArtifact(CodeBlockInfo blockInfo, BoundaryType type)
            : base(ArtifactTreatAs.Code, type == BoundaryType.Start ? blockInfo.OuterStart : blockInfo.OuterEnd, 0, 0, MarkdownClassificationTypes.MarkdownCode, true)
        {
            BlockInfo = blockInfo;
            Boundary = type;

            // Replace the BlockInfo's TextRanges with our created
            // artifacts so that they will be adjusted as the user
            // edits the text. TextRangeCollection shifts existing
            // artifacts as the user types elsewhere.
            if (type == BoundaryType.Start)
                BlockInfo.OuterStart = this;
            else
                BlockInfo.OuterEnd = this;
        }
    // add boundary to list
    public static bool AddBoundary(Moba_Camera_Boundary boundary, BoundaryType type)
    {
        if(boundary == null) {
            Debug.LogWarning("Name: " + boundary.name + "; Error: AddBoundary() - null boundary passed");
            return false;
        }

        if(type == BoundaryType.cube) {
            cube_boundaries.Add(boundary);
            return true;
        }
        else if(type == BoundaryType.sphere) {
            sphere_boundaries.Add(boundary);
            return true;
        }
        else {
            Debug.LogWarning ("Name: " + boundary.name + "; Error: AddBoundary() - Incorrect BoundaryType, boundary will not be used");
            return false;
        }
    }
예제 #41
0
        //显示边界警告
        public void DisplayBoundaryWarn(Vector2 pos, BoundaryType type)
        {
            if (type == BoundaryType.Right) {
                boundaryWarner.CenterSprite (TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Right) {
                    boundaryWarner.Rotate (boundaryWarner.Rotation);
                    boundaryWarner.Rotate (GameBase.Right);
                } else
                    boundaryWarner.SetPosition (pos);
            }

            if (type == BoundaryType.Left) {
                boundaryWarner.CenterSprite (TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Left) {
                    boundaryWarner.Rotate (boundaryWarner.Rotation);
                    boundaryWarner.Rotate (GameBase.Left);
                } else
                    boundaryWarner.SetPosition (pos);
            }

            if (type == BoundaryType.Up) {
                boundaryWarner.CenterSprite (TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Down) {
                    boundaryWarner.Rotate (GameBase.Right);
                    boundaryWarner.Rotate (GameBase.Down);
                } else
                    boundaryWarner.SetPosition (pos);
            }

            if (type == BoundaryType.Down) {
                boundaryWarner.CenterSprite (TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Up) {
                    boundaryWarner.Rotate (GameBase.Right);
                    boundaryWarner.Rotate (GameBase.Up);
                } else
                    boundaryWarner.SetPosition (pos);
            }
        }
예제 #42
0
 public bool OutsideBoundary(BoundaryType type)
 {
     if (type == BoundaryType.Top)
     {
         float topMost = transform.position.y + boxCollider.size.y * 0.5f + boxCollider.offset.y;
         return topMost > boundary.yMax;
     }
     else if (type == BoundaryType.Bottom)
     {
         float bottomMost = transform.position.y - boxCollider.size.y * 0.5f + boxCollider.offset.y;
         return bottomMost < boundary.yMin;
     }
     else if (type == BoundaryType.Left)
     {
         float leftMost = transform.position.x - boxCollider.size.x * 0.5f + boxCollider.offset.x;
         return leftMost < boundary.xMin;
     }
     else //type == BoundaryType.Right
     {
         float rightMost = transform.position.x + boxCollider.size.x * 0.5f + boxCollider.offset.x;
         return rightMost > boundary.xMax;
     }
 }
 // Remove a boundary from the list
 public static bool RemoveBoundary(Moba_Camera_Boundary boundary, BoundaryType type)
 {
     if(type == BoundaryType.cube) {
         return cube_boundaries.Remove(boundary);
     }
     else if(type == BoundaryType.sphere) {
         return cube_boundaries.Remove(boundary);
     }
     else {
         return false;
     }
 }
예제 #44
0
        internal Interop.HttpApi.HTTP_FLAGS ComputeHeaders()
        {
            Interop.HttpApi.HTTP_FLAGS flags = Interop.HttpApi.HTTP_FLAGS.NONE;
            if (NetEventSource.IsEnabled) NetEventSource.Info(this);
            Debug.Assert(!ComputedHeaders, "ComputedHeaders is true.");
            _responseState = ResponseState.ComputedHeaders;
            
            ComputeCoreHeaders();

            if (NetEventSource.IsEnabled) NetEventSource.Info(this,
                $"flags: {flags} _boundaryType: {_boundaryType} _contentLength: {_contentLength} _keepAlive: {_keepAlive}");
            if (_boundaryType == BoundaryType.None)
            {
                if (HttpListenerRequest.ProtocolVersion.Minor == 0)
                {
                    _keepAlive = false;
                }
                else
                {
                    _boundaryType = BoundaryType.Chunked;
                }
                if (CanSendResponseBody(_httpContext.Response.StatusCode))
                {
                    _contentLength = -1;
                }
                else
                {
                    ContentLength64 = 0;
                }
            }

            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"flags:{flags} _BoundaryType:{_boundaryType} _contentLength:{_contentLength} _keepAlive: {_keepAlive}");
            if (_boundaryType == BoundaryType.ContentLength)
            {
                Headers[HttpResponseHeader.ContentLength] = _contentLength.ToString("D", NumberFormatInfo.InvariantInfo);
                if (_contentLength == 0)
                {
                    flags = Interop.HttpApi.HTTP_FLAGS.NONE;
                }
            }
            else if (_boundaryType == BoundaryType.Chunked)
            {
                Headers[HttpResponseHeader.TransferEncoding] = "chunked";
            }
            else if (_boundaryType == BoundaryType.None)
            {
                flags = Interop.HttpApi.HTTP_FLAGS.NONE; // seems like HTTP_SEND_RESPONSE_FLAG_MORE_DATA but this hangs the app;
            }
            else
            {
                _keepAlive = false;
            }
            if (!_keepAlive)
            {
                Headers.Add(HttpResponseHeader.Connection, "close");
                if (flags == Interop.HttpApi.HTTP_FLAGS.NONE)
                {
                    flags = Interop.HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_DISCONNECT;
                }
            }
            else
            {
                if (HttpListenerRequest.ProtocolVersion.Minor == 0)
                {
                    Headers[HttpResponseHeader.KeepAlive] = "true";
                }
            }
            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"flags:{flags} _BoundaryType:{_boundaryType} _contentLength:{_contentLength} _keepAlive: {_keepAlive}");
            return flags;
        }
예제 #45
0
 /// <summary>Calculates interpolated values using Cubic Spline Interpolation</summary>
 /// <param name="x">X values at which interpolated values are required</param>
 /// <param name="leftBoundaryType">BoundaryType enumeration (Parabolic, FirstDerivative Specified, SecondDerivative Specified)</param>
 /// <param name="leftBoundaryTypeParameter">Parameter required (ignored if Parabolic)</param>
 /// <param name="rightBoundaryType">BoundaryType enumeration (Parabolic, FirstDerivative Specified, SecondDerivative Specified)</param>
 /// <param name="rightBoundaryTypeParameter">Parameter required (ignored if Parabolic)</param>
 /// <returns>Interpolated values </returns>
 /// <remarks><para></para>
 /// </remarks>
 public double[] GetValuesCubicSpline(double[] xi, BoundaryType leftBoundaryType, double leftBoundaryTypeParameter,
     BoundaryType rightBoundaryType, double rightBoundaryTypeParameter)
 {
     if (cubicSplineCoefficients == null) UpdateCubicSplineCoefficients(leftBoundaryType, leftBoundaryTypeParameter, rightBoundaryType, rightBoundaryTypeParameter);
     
     double[] interpolatedValues = new double[xi.Length];
     for (int i = 0; i < xi.Length; ++i)
     {
         double xit = xi[i];
         int p = 0; int r = n - 1; int q = 0;
         while (p != r - 1)
         {
             q = (p + r) / 2;
             if (x[q] >= xit) r = q;
             else p = q;
         }
         xit = xit - x[p];
         q = p * 4;
         interpolatedValues[i] = cubicSplineCoefficients[q] + xit * (cubicSplineCoefficients[q + 1]
             + xit * (cubicSplineCoefficients[q + 2] + xit * cubicSplineCoefficients[q + 3]));
     }
     return interpolatedValues;
 }
예제 #46
0
        /// <summary>Update or create coefficients for cubic spline</summary>
        public void UpdateCubicSplineCoefficients(BoundaryType leftBoundaryType, double leftBoundaryTypeParameter,
            BoundaryType rightBoundaryType, double rightBoundaryTypeParameter)
        {
            // TODO Raise error if < 2 points
            // Sort if points are unsorted?

            double[] a1 = new double[n];
            double[] a2 = new double[n];
            double[] a3 = new double[n];
            double[] b = new double[n];
            double[] deriv = new double[n];

            // If 2 points, apply parabolic end conditions
            if (n == 2)
            {
                leftBoundaryType = BoundaryType.Parabolic;
                rightBoundaryType = BoundaryType.Parabolic;
            }

            #region LeftBoundary
            if (leftBoundaryType == BoundaryType.Parabolic)
            {
                a1[0] = 0;
                a2[0] = 1;
                a3[0] = 1;
                b[0] = 2 * (y[1] - y[0]) / (x[1] - x[0]);
            }
            if (leftBoundaryType == BoundaryType.FirstDerivativeSpecified)
            {
                a1[0] = 0;
                a2[0] = 1;
                a3[0] = 0;
                b[0] = leftBoundaryTypeParameter;
            }
            if (leftBoundaryType == BoundaryType.SecondDerivativeSpecified)
            {
                a1[0] = 0;
                a2[0] = 2;
                a3[0] = 1;
                b[0] = 3 * (y[1] - y[0]) / (x[1] - x[0]) - 0.5 * leftBoundaryTypeParameter * (x[1] - x[0]);
            }
            #endregion

            for (int i = 1; i <= n - 2; i++)
            {
                a1[i] = x[i + 1] - x[i];
                a2[i] = 2 * (x[i + 1] - x[i - 1]);
                a3[i] = x[i] - x[i - 1];
                b[i] = 3 * ((y[i] - y[i - 1]) / a3[i]) * a1[i]
                    + 3 * ((y[i + 1] - y[i]) / a1[i]) * a3[i];
            }

            #region RightBoundary
            if (rightBoundaryType == BoundaryType.Parabolic)
            {
                a1[n - 1] = 1;
                a2[n - 1] = 1;
                a3[n - 1] = 0;
                b[n - 1] = 2 * (y[n - 1] - y[n - 2]) / (x[n - 1] - x[n - 2]);
            }
            if (rightBoundaryType == BoundaryType.FirstDerivativeSpecified)
            {
                a1[n - 1] = 0;
                a2[n - 1] = 1;
                a3[n - 1] = 0;
                b[n - 1] = rightBoundaryTypeParameter;
            }
            if (rightBoundaryType == BoundaryType.SecondDerivativeSpecified)
            {
                a1[n - 1] = 1;
                a2[n - 1] = 2;
                a3[n - 1] = 0;
                b[n - 1] = 3 * (y[n - 1] - y[n - 2]) / (x[n - 1] - x[n - 2]) 
                    + 0.5 * rightBoundaryTypeParameter * (x[n - 1] - x[n - 2]);
            }
            #endregion

            double temp = 0;
            
            a1[0] = 0;
            a3[n - 1] = 0;
            for (int i = 1; i <= n - 1; i++)
            {
                temp = a1[i] / a2[i - 1];
                a2[i] = a2[i] - temp * a3[i - 1];
                b[i] = b[i] - temp * b[i - 1];
            }
            deriv[n - 1] = b[n - 1] / a2[n - 1];
            for (int i = n - 2; i >= 0; i--)
            {
                deriv[i] = (b[i] - a3[i] * deriv[i + 1]) / a2[i];
            }

            cubicSplineCoefficients = GetHermiteSplineCoefficients(deriv);
        }
예제 #47
0
파일: Text.cs 프로젝트: mono/at-spi-sharp
 public string GetTextBeforeOffset(int offset, BoundaryType type, out int startOffset, out int endOffset)
 {
     string text;
     proxy.GetTextBeforeOffset (offset, type, out text, out startOffset, out endOffset);
     return text;
 }
예제 #48
0
        internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob)
        {
            if (Logging.On) Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob));
            if(Logging.On)Logging.Associate(Logging.HttpListener, this, httpContext);
            m_HttpContext = httpContext;
            m_MemoryBlob = memoryBlob;
            m_BoundaryType = BoundaryType.None;

            // Set up some of these now to avoid refcounting on memory blob later.
            m_RequestId = memoryBlob.RequestBlob->RequestId;
            m_ConnectionId = memoryBlob.RequestBlob->ConnectionId;
            m_SslStatus = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure :
                memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert :
                SslStatus.ClientCert;
            if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0) {
                m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
            }
            
            UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
            if (cookedUrl.pHost != null && cookedUrl.HostLength > 0) {
                m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
            }
            if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0) {
                m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
            }
            if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0) {
                m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
            }
            m_Version = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion);
            m_ClientCertState = ListenerClientCertState.NotInitialized;
            m_KeepAlive = TriState.Unspecified;
            GlobalLog.Print("HttpListenerContext#" + ValidationHelper.HashString(this) + "::.ctor() RequestId:" + RequestId + " ConnectionId:" + m_ConnectionId + " RawConnectionId:" + memoryBlob.RequestBlob->RawConnectionId + " UrlContext:" + memoryBlob.RequestBlob->UrlContext + " RawUrl:" + m_RawUrl + " Version:" + m_Version.ToString() + " Secure:" + m_SslStatus.ToString());
            if(Logging.On)Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#"+ ValidationHelper.HashString(httpContext)+ " RequestUri:" + ValidationHelper.ToString(RequestUri) + " Content-Length:" + ValidationHelper.ToString(ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(HttpMethod));
            // Log headers
            if(Logging.On) {
                StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n");
                for (int i=0; i<Headers.Count; i++) {
                    sb.Append("\t");
                    sb.Append(Headers.GetKey(i));
                    sb.Append(" : ");
                    sb.Append(Headers.Get(i));
                    sb.Append("\n");
                }
                Logging.PrintInfo(Logging.HttpListener, this, ".ctor", sb.ToString());
            }
        }
 public void CopyFrom(HttpListenerResponse templateResponse) {
     if(Logging.On)Logging.PrintInfo(Logging.HttpListener, this, "CopyFrom", "templateResponse#"+ValidationHelper.HashString(templateResponse));
     m_NativeResponse = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE();
     m_ResponseState = ResponseState.Created;
     m_WebHeaders = templateResponse.m_WebHeaders;
     m_BoundaryType = templateResponse.m_BoundaryType;
     m_ContentLength = templateResponse.m_ContentLength;
     m_NativeResponse.StatusCode = templateResponse.m_NativeResponse.StatusCode;
     m_NativeResponse.Version.MajorVersion = templateResponse.m_NativeResponse.Version.MajorVersion;
     m_NativeResponse.Version.MinorVersion = templateResponse.m_NativeResponse.Version.MinorVersion;
     m_StatusDescription = templateResponse.m_StatusDescription;
     m_KeepAlive = templateResponse.m_KeepAlive;
 }
예제 #50
0
 public void CopyFrom(HttpListenerResponse templateResponse)
 {
     if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"templateResponse {templateResponse}");
     _nativeResponse = new Interop.HttpApi.HTTP_RESPONSE();
     _responseState = ResponseState.Created;
     _webHeaders = templateResponse._webHeaders;
     _boundaryType = templateResponse._boundaryType;
     _contentLength = templateResponse._contentLength;
     _nativeResponse.StatusCode = templateResponse._nativeResponse.StatusCode;
     _nativeResponse.Version.MajorVersion = templateResponse._nativeResponse.Version.MajorVersion;
     _nativeResponse.Version.MinorVersion = templateResponse._nativeResponse.Version.MinorVersion;
     _statusDescription = templateResponse._statusDescription;
     _keepAlive = templateResponse._keepAlive;
 }
        internal UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS ComputeHeaders() {
            UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
            GlobalLog.Print("HttpListenerResponse#" + ValidationHelper.HashString(this) + "::ComputeHeaders()");
            GlobalLog.Assert(!ComputedHeaders, "HttpListenerResponse#{0}::ComputeHeaders()|ComputedHeaders is true.", ValidationHelper.HashString(this));
            m_ResponseState = ResponseState.ComputedHeaders;
            /*
            // here we would check for BoundaryType.Raw, in this case we wouldn't need to do anything
            if (m_BoundaryType==BoundaryType.Raw) {
                return flags;
            }
            */

            ComputeCoreHeaders();

            GlobalLog.Print("HttpListenerResponse#" + ValidationHelper.HashString(this) + "::ComputeHeaders() flags:" + flags + " m_BoundaryType:" + m_BoundaryType + " m_ContentLength:" + m_ContentLength + " m_KeepAlive:" + m_KeepAlive);
            if (m_BoundaryType==BoundaryType.None)
            {
                if (HttpListenerRequest.ProtocolVersion.Minor==0) {
                    // 
                    m_KeepAlive = false;
                }
                else {
                    m_BoundaryType = BoundaryType.Chunked;
                }
                if (CanSendResponseBody(m_HttpContext.Response.StatusCode)) {
                    m_ContentLength = -1;
                }
                else {
                    ContentLength64 = 0;
                }
            }

            GlobalLog.Print("HttpListenerResponse#" + ValidationHelper.HashString(this) + "::ComputeHeaders() flags:" + flags + " m_BoundaryType:" + m_BoundaryType + " m_ContentLength:" + m_ContentLength + " m_KeepAlive:" + m_KeepAlive);
            if (m_BoundaryType==BoundaryType.ContentLength) {
                Headers.SetInternal(HttpResponseHeader.ContentLength, m_ContentLength.ToString("D", NumberFormatInfo.InvariantInfo));
                if (m_ContentLength==0) {
                    flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
                }
            }
            else if (m_BoundaryType==BoundaryType.Chunked) {
                Headers.SetInternal(HttpResponseHeader.TransferEncoding, HttpWebRequest.ChunkedHeader);
            }
            else if (m_BoundaryType==BoundaryType.None) {
                flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE; // seems like HTTP_SEND_RESPONSE_FLAG_MORE_DATA but this hangs the app;
            }
            else {
                m_KeepAlive = false;
            }
            if (!m_KeepAlive) {
                Headers.Add(HttpResponseHeader.Connection, "close");
                if (flags==UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE) {
                    flags = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_DISCONNECT;
                }
            }
            else
            {
                if (HttpListenerRequest.ProtocolVersion.Minor == 0)
                {
                    Headers.SetInternal(HttpResponseHeader.KeepAlive, "true");
                }
            }
            GlobalLog.Print("HttpListenerResponse#" + ValidationHelper.HashString(this) + "::ComputeHeaders() flags:" + flags + " m_BoundaryType:" + m_BoundaryType + " m_ContentLength:" + m_ContentLength + " m_KeepAlive:" + m_KeepAlive);
            return flags;
        }
예제 #52
0
 /// <summary>
 /// Creates a new instance of BoundingData.
 /// </summary>
 public BoundingData() {
     this.pointField = new List<UtmPoint>();
     this.directionField = Direction.undefined;
     this.typeField = BoundaryType.land;
 }
예제 #53
0
        public void SetBoundary(int side, BoundaryType boundarytype, double value, double hcoeff = 0)
        {
            faces[side].SetBoundary(side, boundarytype, value, hcoeff);

        }