Beispiel #1
0
        protected virtual void Init(int index, string protocol, string version, string target, string method, IDictionary <string, string> headers, IDictionary <string, string> parameters, ArtifactContent body, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Index    = index;
            Protocol = protocol;
            Version  = version;
            Target   = target;
            Method   = method;
            if (headers != null)
            {
                Headers = new Dictionary <string, string>(headers);
            }

            if (parameters != null)
            {
                Parameters = new Dictionary <string, string>(parameters);
            }

            if (body != null)
            {
                Body = new ArtifactContent(body);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Beispiel #2
0
        private void Init(Message description, ArtifactLocation location, int parentIndex, int offset, int length, ArtifactRoles roles, string mimeType, ArtifactContent contents, string encoding, string sourceLanguage, IDictionary <string, string> hashes, DateTime lastModifiedTimeUtc, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (description != null)
            {
                Description = new Message(description);
            }

            if (location != null)
            {
                Location = new ArtifactLocation(location);
            }

            ParentIndex = parentIndex;
            Offset      = offset;
            Length      = length;
            Roles       = roles;
            MimeType    = mimeType;
            if (contents != null)
            {
                Contents = new ArtifactContent(contents);
            }

            Encoding       = encoding;
            SourceLanguage = sourceLanguage;
            if (hashes != null)
            {
                Hashes = new Dictionary <string, string>(hashes);
            }

            LastModifiedTimeUtc = lastModifiedTimeUtc;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Beispiel #3
0
        protected virtual void Init(int startLine, int startColumn, int endLine, int endColumn, int charOffset, int charLength, int byteOffset, int byteLength, ArtifactContent snippet, Message message, string sourceLanguage, IDictionary <string, SerializedPropertyInfo> properties)
        {
            StartLine   = startLine;
            StartColumn = startColumn;
            EndLine     = endLine;
            EndColumn   = endColumn;
            CharOffset  = charOffset;
            CharLength  = charLength;
            ByteOffset  = byteOffset;
            ByteLength  = byteLength;
            if (snippet != null)
            {
                Snippet = new ArtifactContent(snippet);
            }

            if (message != null)
            {
                Message = new Message(message);
            }

            SourceLanguage = sourceLanguage;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
        public virtual ArtifactContent VisitArtifactContent(ArtifactContent node)
        {
            if (node != null)
            {
            }

            return(node);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ArtifactContent" /> class from the specified instance.
        /// </summary>
        /// <param name="other">
        /// The instance from which the new instance is to be initialized.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="other" /> is null.
        /// </exception>
        public ArtifactContent(ArtifactContent other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.Text, other.Binary, other.Rendered, other.Properties);
        }
Beispiel #6
0
        protected virtual void Init(Region deletedRegion, ArtifactContent insertedContent, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (deletedRegion != null)
            {
                DeletedRegion = new Region(deletedRegion);
            }

            if (insertedContent != null)
            {
                InsertedContent = new ArtifactContent(insertedContent);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Beispiel #7
0
        private static ArtifactContent GetEncodedFileContents(IFileSystem fileSystem, string filePath, string mimeType, Encoding inputFileEncoding)
        {
            var fileContent = new ArtifactContent();

            byte[] fileContents = fileSystem.ReadAllBytes(filePath);

            if (SarifWriters.MimeType.IsBinaryMimeType(mimeType) || inputFileEncoding == null)
            {
                fileContent.Binary = Convert.ToBase64String(fileContents);
            }
            else
            {
                fileContent.Text = inputFileEncoding.GetString(fileContents);
            }

            return(fileContent);
        }
Beispiel #8
0
        private void Init(int index, string protocol, string version, int statusCode, string reasonPhrase, object headers, ArtifactContent body, bool noResponseReceived, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Index        = index;
            Protocol     = protocol;
            Version      = version;
            StatusCode   = statusCode;
            ReasonPhrase = reasonPhrase;
            Headers      = headers;
            if (body != null)
            {
                Body = new ArtifactContent(body);
            }

            NoResponseReceived = noResponseReceived;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Beispiel #9
0
        private void Init(int index, string protocol, string version, string target, string method, object headers, object parameters, ArtifactContent body, IDictionary <string, SerializedPropertyInfo> properties)
        {
            Index      = index;
            Protocol   = protocol;
            Version    = version;
            Target     = target;
            Method     = method;
            Headers    = headers;
            Parameters = parameters;
            if (body != null)
            {
                Body = new ArtifactContent(body);
            }

            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Replacement" /> class from the supplied values.
 /// </summary>
 /// <param name="deletedRegion">
 /// An initialization value for the <see cref="P:DeletedRegion" /> property.
 /// </param>
 /// <param name="insertedContent">
 /// An initialization value for the <see cref="P:InsertedContent" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Replacement(Region deletedRegion, ArtifactContent insertedContent, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(deletedRegion, insertedContent, properties);
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebResponse" /> class from the supplied values.
 /// </summary>
 /// <param name="index">
 /// An initialization value for the <see cref="P:Index" /> property.
 /// </param>
 /// <param name="protocol">
 /// An initialization value for the <see cref="P:Protocol" /> property.
 /// </param>
 /// <param name="version">
 /// An initialization value for the <see cref="P:Version" /> property.
 /// </param>
 /// <param name="statusCode">
 /// An initialization value for the <see cref="P:StatusCode" /> property.
 /// </param>
 /// <param name="reasonPhrase">
 /// An initialization value for the <see cref="P:ReasonPhrase" /> property.
 /// </param>
 /// <param name="headers">
 /// An initialization value for the <see cref="P:Headers" /> property.
 /// </param>
 /// <param name="body">
 /// An initialization value for the <see cref="P:Body" /> property.
 /// </param>
 /// <param name="noResponseReceived">
 /// An initialization value for the <see cref="P:NoResponseReceived" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public WebResponse(int index, string protocol, string version, int statusCode, string reasonPhrase, IDictionary <string, string> headers, ArtifactContent body, bool noResponseReceived, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(index, protocol, version, statusCode, reasonPhrase, headers, body, noResponseReceived, properties);
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebRequest" /> class from the supplied values.
 /// </summary>
 /// <param name="index">
 /// An initialization value for the <see cref="P:Index" /> property.
 /// </param>
 /// <param name="protocol">
 /// An initialization value for the <see cref="P:Protocol" /> property.
 /// </param>
 /// <param name="version">
 /// An initialization value for the <see cref="P:Version" /> property.
 /// </param>
 /// <param name="target">
 /// An initialization value for the <see cref="P:Target" /> property.
 /// </param>
 /// <param name="method">
 /// An initialization value for the <see cref="P:Method" /> property.
 /// </param>
 /// <param name="headers">
 /// An initialization value for the <see cref="P:Headers" /> property.
 /// </param>
 /// <param name="parameters">
 /// An initialization value for the <see cref="P:Parameters" /> property.
 /// </param>
 /// <param name="body">
 /// An initialization value for the <see cref="P:Body" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public WebRequest(int index, string protocol, string version, string target, string method, IDictionary <string, string> headers, IDictionary <string, string> parameters, ArtifactContent body, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(index, protocol, version, target, method, headers, parameters, body, properties);
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Artifact" /> class from the supplied values.
 /// </summary>
 /// <param name="description">
 /// An initialization value for the <see cref="P:Description" /> property.
 /// </param>
 /// <param name="location">
 /// An initialization value for the <see cref="P:Location" /> property.
 /// </param>
 /// <param name="parentIndex">
 /// An initialization value for the <see cref="P:ParentIndex" /> property.
 /// </param>
 /// <param name="offset">
 /// An initialization value for the <see cref="P:Offset" /> property.
 /// </param>
 /// <param name="length">
 /// An initialization value for the <see cref="P:Length" /> property.
 /// </param>
 /// <param name="roles">
 /// An initialization value for the <see cref="P:Roles" /> property.
 /// </param>
 /// <param name="mimeType">
 /// An initialization value for the <see cref="P:MimeType" /> property.
 /// </param>
 /// <param name="contents">
 /// An initialization value for the <see cref="P:Contents" /> property.
 /// </param>
 /// <param name="encoding">
 /// An initialization value for the <see cref="P:Encoding" /> property.
 /// </param>
 /// <param name="sourceLanguage">
 /// An initialization value for the <see cref="P:SourceLanguage" /> property.
 /// </param>
 /// <param name="hashes">
 /// An initialization value for the <see cref="P:Hashes" /> property.
 /// </param>
 /// <param name="lastModifiedTimeUtc">
 /// An initialization value for the <see cref="P:LastModifiedTimeUtc" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Artifact(Message description, ArtifactLocation location, int parentIndex, int offset, int length, ArtifactRoles roles, string mimeType, ArtifactContent contents, string encoding, string sourceLanguage, IDictionary <string, string> hashes, DateTime lastModifiedTimeUtc, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(description, location, parentIndex, offset, length, roles, mimeType, contents, encoding, sourceLanguage, hashes, lastModifiedTimeUtc, properties);
 }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Region" /> class from the supplied values.
 /// </summary>
 /// <param name="startLine">
 /// An initialization value for the <see cref="P:StartLine" /> property.
 /// </param>
 /// <param name="startColumn">
 /// An initialization value for the <see cref="P:StartColumn" /> property.
 /// </param>
 /// <param name="endLine">
 /// An initialization value for the <see cref="P:EndLine" /> property.
 /// </param>
 /// <param name="endColumn">
 /// An initialization value for the <see cref="P:EndColumn" /> property.
 /// </param>
 /// <param name="charOffset">
 /// An initialization value for the <see cref="P:CharOffset" /> property.
 /// </param>
 /// <param name="charLength">
 /// An initialization value for the <see cref="P:CharLength" /> property.
 /// </param>
 /// <param name="byteOffset">
 /// An initialization value for the <see cref="P:ByteOffset" /> property.
 /// </param>
 /// <param name="byteLength">
 /// An initialization value for the <see cref="P:ByteLength" /> property.
 /// </param>
 /// <param name="snippet">
 /// An initialization value for the <see cref="P:Snippet" /> property.
 /// </param>
 /// <param name="message">
 /// An initialization value for the <see cref="P:Message" /> property.
 /// </param>
 /// <param name="sourceLanguage">
 /// An initialization value for the <see cref="P:SourceLanguage" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P:Properties" /> property.
 /// </param>
 public Region(int startLine, int startColumn, int endLine, int endColumn, int charOffset, int charLength, int byteOffset, int byteLength, ArtifactContent snippet, Message message, string sourceLanguage, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(startLine, startColumn, endLine, endColumn, charOffset, charLength, byteOffset, byteLength, snippet, message, sourceLanguage, properties);
 }
 public bool ValueEquals(ArtifactContent other) => ValueComparer.Equals(this, other);