1 //------------------------------------------------------------------------------
2 // <copyright file="EarlyBoundInfo.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 using System.Diagnostics;
10 using System.Reflection;
12 namespace System.Xml.Xsl.Runtime {
15 /// This class contains information about early bound function objects.
17 internal sealed class EarlyBoundInfo {
18 private string namespaceUri; // Namespace Uri mapped to these early bound functions
19 private ConstructorInfo constrInfo; // Constructor for the early bound function object
21 public EarlyBoundInfo(string namespaceUri, Type ebType) {
22 Debug.Assert(namespaceUri != null && ebType != null);
24 // Get the default constructor
25 this.namespaceUri = namespaceUri;
26 this.constrInfo = ebType.GetConstructor(Type.EmptyTypes);
27 Debug.Assert(this.constrInfo != null, "The early bound object type " + ebType.FullName + " must have a public default constructor");
31 /// Get the Namespace Uri mapped to these early bound functions.
33 public string NamespaceUri { get { return this.namespaceUri; } }
36 /// Return the Clr Type of the early bound object.
38 public Type EarlyBoundType { get { return this.constrInfo.DeclaringType; } }
41 /// Create an instance of the early bound object.
43 public object CreateObject() { return this.constrInfo.Invoke(new object[] {}); }
46 /// Override Equals method so that EarlyBoundInfo to implement value comparison.
48 public override bool Equals(object obj) {
49 EarlyBoundInfo info = obj as EarlyBoundInfo;
53 return this.namespaceUri == info.namespaceUri && this.constrInfo == info.constrInfo;
57 /// Override GetHashCode since Equals is overriden.
59 public override int GetHashCode() {
60 return this.namespaceUri.GetHashCode();