|
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Resources;
using System.Text;
using System.Windows;
namespace Ricciolo.StylesExplorer.MarkupReflection
{
/// <summary>
/// Rappresenta un singole file Baml all'interno di un assembly
/// </summary>
public class BamlFile : Component
{
private Uri _uri;
private readonly Stream _stream;
public BamlFile(Uri uri, Stream stream)
{
if (uri == null)
new ArgumentNullException("uri");
if (stream == null)
throw new ArgumentNullException("stream");
_uri = uri;
_stream = stream;
}
/// <summary>
/// Carica il Baml attraverso il motore di WPF con Application.LoadComponent
/// </summary>
/// <returns></returns>
public object LoadContent()
{
try
{
return Application.LoadComponent(this.Uri);
}
catch (Exception e)
{
throw new InvalidOperationException("Invalid baml file.", e);
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
this.Stream.Dispose();
}
public override object InitializeLifetimeService()
{
return null;
}
/// <summary>
/// Restituisce lo stream originale contenente il Baml
/// </summary>
public Stream Stream
{
get { return _stream; }
}
/// <summary>
/// Restituisce l'indirizzo secondo lo schema pack://
/// </summary>
public Uri Uri
{
get { return _uri; }
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.