Beispiel #1
0
 public FeatureSwitchScriptResource()
 {
     Name = InternalName;
     GlimpseClientEmbeddedResourceInfo = new EmbeddedResourceInfo(GetType().Assembly,
                                                                  "FeatureSwitch.Glimpse.FeatureSwitchConfigScript.min.js",
                                                                  "application/x-javascript");
 }
 public FeatureSwitchScriptResource()
 {
     Name = InternalName;
     GlimpseClientEmbeddedResourceInfo = new EmbeddedResourceInfo(GetType().Assembly,
                                                                  "FeatureSwitch.Glimpse.FeatureSwitchConfigScript.min.js",
                                                                  "application/x-javascript");
 }
Beispiel #3
0
		public ScriptResource()
		{
			Name = InternalName;
			GlimpseClientEmbeddedResourceInfo = new EmbeddedResourceInfo(
				this.GetType().Assembly,
				"Navigation.Glimpse.navigation.glimpse.js",
				"application/x-javascript");
		}
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientResource" /> class.
        /// </summary>
        public PluginClientResource()
        {
            Name = InternalName;

            GlimpseSignalREmbeddedResourceInfo = new EmbeddedResourceInfo(
                GetType().Assembly,
                "Glimpse.SignalR.Invocations.plugin.js",
                "application/x-javascript");
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientResource" /> class.
        /// </summary>
        public ClientResource()
        {
            Name = InternalName;

            GlimpseClientEmbeddedResourceInfo = new EmbeddedResourceInfo(
                this.GetType().Assembly,
                "Glimpse.Core.glimpse.js",
                "application/x-javascript");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientResource" /> class.
        /// </summary>
        public PluginClientResource()
        {
            Name = InternalName;

            GlimpseSignalREmbeddedResourceInfo = new EmbeddedResourceInfo(
                GetType().Assembly,
                "Glimpse.SignalR.Invocations.plugin.js",
                "application/x-javascript");
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientResource" /> class.
        /// </summary>
        public InsightResource()
        {
            Name = InternalName;

            ResourceInfo = new EmbeddedResourceInfo(GetType().Assembly, "Glimpse.Core.glimpseInsight.js", "application/x-javascript");
        }
Beispiel #8
0
    /// <summary>
    /// Retrieve specific loaded DLL/assembly from memory
    /// </summary>
    /// <param name="assemblyFullName"></param>
    /// <returns></returns>
    public static Assembly GetAssembly(string assemblyFullName)
    {
        if (knownAssemblies == null || knownAssemblies.Count == 0)
        {
            return(null);
        }

        if (!knownAssemblies.ContainsKey(assemblyFullName))
        {
            // Don't throw Exception if the dictionary does not contain the requested assembly.
            // This is because the event of AssemblyResolve will be raised for every
            // Embedded Resources (such as pictures) of the projects.
            // Those resources will not be loaded by this class and will not exist in dictionary.

            return(null);
        }

        EmbeddedResourceInfo resourceInfo = knownAssemblies[assemblyFullName];
        string embeddedResourceName       = resourceInfo.ResourceName;
        string assemblyName = resourceInfo.FileName;

        byte[] ba = null;

        using (Stream mrs = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedResourceName))
        {
            // Either the file is not existed or it is not mark as embedded resource
            if (mrs == null)
            {
                throw new Exception(embeddedResourceName + " is not found in Embedded Resources.");
            }

            // Get byte[] from the file from embedded resource
            ba = new byte[(int)mrs.Length];
            mrs.Read(ba, 0, (int)mrs.Length);
            try
            {
                return(Assembly.Load(ba));
            }
            catch
            {
                // Purposely do nothing
                // Unmanaged dll or assembly cannot be loaded directly from byte[]
                // Let the process fall through for next part
            }
        }

        bool   fileOk       = false;
        string tempFilePath = string.Empty;

        using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
        {
            // Get the hash value from embedded DLL/assembly
            string fileHash = BitConverter.ToString(sha1.ComputeHash(ba)).Replace("-", string.Empty);

            // Define the storage location of the DLL/assembly
            tempFilePath = Path.Combine(Path.GetTempPath(), assemblyName);

            // Determines whether the DLL/assembly is existed or not
            if (File.Exists(tempFilePath))
            {
                // Get the hash value of the existed file
                byte[] bb        = File.ReadAllBytes(tempFilePath);
                string fileHash2 = BitConverter.ToString(sha1.ComputeHash(bb)).Replace("-", string.Empty);

                // Compare the existed DLL/assembly with the Embedded DLL/assembly
                if (fileHash == fileHash2)
                {
                    // Same file
                    fileOk = true;
                }
                else
                {
                    // Not same
                    fileOk = false;
                }
            }
            else
            {
                // The DLL/assembly is not existed yet
                fileOk = false;
            }
        }

        // Create the file on disk
        if (!fileOk)
        {
            File.WriteAllBytes(tempFilePath, ba);
        }

        // Load it into memory
        return(Assembly.LoadFile(tempFilePath));
    }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogoResource" /> class.
 /// </summary>
 public LogoResource()
 {
     Name = InternalName;
     GlimpseTextLogoEmbeddedResourceInfo = new EmbeddedResourceInfo(this.GetType().Assembly, "Glimpse.Core.EmbeddedResources.glimpse_text_logo.png", "image/png");
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogoResource" /> class.
 /// </summary>
 public LogoResource()
 {
     Name = InternalName;
     GlimpseTextLogoEmbeddedResourceInfo = new EmbeddedResourceInfo(this.GetType().Assembly, "Glimpse.Core.EmbeddedResources.glimpse_text_logo.png", "image/png");
 }
 protected bool Equals(EmbeddedResourceInfo e)
 {
     return string.Equals(FileName, e.FileName) && string.Equals(FileType, e.FileType) && Size == e.Size;
 }