admin
2020-06-22 924bdf1c9fb74babf2438d5545db3594756625d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
 
using System;
 
namespace CefSharp
{
    /// <summary>
    /// Represents a new V8 extension to be registered.
    /// </summary>
    public sealed class V8Extension
    {
        /// <summary>
        /// Gets the name of the extension.
        /// </summary>
        public string Name { get; private set; }
 
        /// <summary>
        /// Gets the javascript extension code
        /// </summary>
        public string JavascriptCode { get; private set; }
 
        /// <summary>
        /// Creates a new CwefExtension instance with a given name.
        /// </summary>
        /// <param name="name">Name of the CefExtension</param>
        /// <param name="javascriptCode">The javascript extension code.</param>
        public V8Extension(string name, string javascriptCode)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
 
            if (string.IsNullOrEmpty(javascriptCode))
            {
                throw new ArgumentNullException("javascriptCode");
            }
 
            Name = name;
            JavascriptCode = javascriptCode;
        }
 
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        /// <param name="obj">The object to compare with the current object.</param>
        /// <returns>
        /// true if the specified object  is equal to the current object; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }
            var ext = (V8Extension)obj;
            return Name.Equals(ext.Name);
        }
 
        /// <summary>
        /// Serves as the default hash function.
        /// </summary>
        /// <returns>
        /// A hash code for the current object.
        /// </returns>
        public override int GetHashCode()
        {
            return Name.GetHashCode();
        }
    }
}