Format:
Recent snippets for: Glenn Block
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; namespace DynamicObjectContracts { public class Program
177 Views
no comments
public class ViewModelInitializer<TViewModel,TModel> where TViewModel : IViewModel<TModel> { private Func<TViewModel> _viewModelFactory; public ViewModelInitializer(Func<TViewModel> viewModelFactory) { _viewModelFactory = viewModelFactory; } public void Initialize(FrameworkElement view, TModel model)
197 Views
no comments
// Below RecentlyUsedTrackerConfiguration provides configuration information through property exports. MEF pulls on the property getters and exports that info. // If the part needs to be data drvien, you can still access a service behind the scenes in the getter (or the constructor) to get the info. public class RecentlyUsedTrackerConfiguration { public RecentlyUsedTrackerConfiguration() { //set values here }
144 Views
no comments
public static class AsyncTestExtensions { public static void EnqueueUntilLoaded(this SilverlightTest test, FrameworkElement element, params Action[] actions) { var isLoaded = false; element.Loaded += (s, e) => isLoaded = true; test.EnqueueConditional(() => isLoaded); test.EnqueueCallback(actions); test.EnqueueTestComplete(); }
133 Views
no comments
namespace System.ComponentModel.Composition.Hosting { public class DeploymentCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged { public DeploymentCatalog(); public DeploymentCatalog(string uri); public DeploymentCatalog(Uri uri); public override IQueryable<ComposablePartDefinition> Parts { get; } public Uri Uri { get; }
76 Views
no comments
using System.ComponentModel.Composition; using Microsoft.Practices.Composite.Events; //this version uses a static backing field so that the instance is automatically shared across all containers. public class EventAggregatorPart { private static IEventAggregator _eventAggregator; static EventAggregatorPart() {
246 Views
no comments
var catalog = new DirectoryCatalog(@".\"); var rootCatalog = new FilteredCatalog(catalog, cpd=>!cpd.Metadata.ContainsKey("Scope") || (cpd.Metadata.ContainsKey("Scope") && cpd.Metadata["Scope"].Equals("Root")); var childCatalog = new FilteredCatalog(catalog, cpd=>cpd.Metadata.ContainsKey("Scope") && cpd.Metadata["Scope"].Equals("Child")); var rootContainer = new CompositionContainer(rootCatalog); var childContainer = new CompositionContainer(childCatalog, rootContainer);
46 Views
no comments
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes;
337 Views
no comments
Imports System.ComponentModel.Composition Imports System.ComponentModel.Composition.Hosting Imports System.ComponentModel.Composition.Deployment Namespace DeploymentCatalogDesignVB Namespace Setting_up_the_host_to_download_catalogs Public Class App Inherits Application Public Sub Initialize()
182 Views
no comments
/* Sample below illustates export inheritance where the base export provides metadata that is overriden by the inheritor using a custom metadata attribute. In this case OverridingExtension implements IExtension but then explicitly overrides the base and provides new metadata. The result is a single export rather than two exports. Notice the inheritor is using an InheritedExport attribute + a custom metadata attribute to override rather than using a custom InheritedExport.
247 Views
no comments
/* Sample below illustatres export inheritance where the base export provides metadata that is overriden by the inheritor using an InheritedExport and ExportMetadata attributes. In this case OverridingExtension implements IExtension but then explicitly overrides the base and provides new metadata. The result is a single export rather than two exports. */
661 Views
no comments
//Design time VM [Export] public ContactVM GetViewModel() { var contact = new Contact() { FirstName = "John", LastName = "Doe", City = "Design time",
313 Views
no comments
namespace Microsoft.ComponentModel.Composition.Packaging { public static class ContainerBuilder { private static PackageCatalog _packageCatalog; private static CompositionContainer _container; private static object _lock = new Object(); public static CompositionContainer GetContainer() {
117 Views
no comments
using System; using System.ComponentModel.Composition.Primitives; using System.Collections.Generic; using System.ComponentModel.Composition.ReflectionModel; using System.ComponentModel.Composition; using System.Reflection; using System.Linq; using System.ComponentModel.Composition.Hosting; using System.Collections;
660 Views
no comments
namespace ExtensibleGrid.GridLibrary { public class ExtensibleDataGrid : DataGrid { private ConfigDialog dialog { get; set; } private IEnumerable<ExtensionItem> extensionItems; public override void OnApplyTemplate() { dialog = new ConfigDialog();
92 Views
no comments
Binder = ViewBinder.For(this, vm). Value(p => p.FirstName). Value(p => p.Address). AddBinder(new ValueBinder<ContactViewModel>(this.OnMailingList, vm)). List(p => p.Cities). Action(p => vm.Save()). Template<City>("City", t => t.Value(p => p.CityName));
187 Views
no comments
public class StringHelper { public static string ToString(object instance) { var properties = TypeDescriptor.GetProperties(instance); StringBuilder output = new StringBuilder(); foreach (PropertyDescriptor property in properties) { output.Append(string.Format("{0} - {1}\r\n", property.Name, property.GetValue(instance))); }
185 Views
2 comments
public class CSLExportProvider : ExportProvider { private IServiceLocator serviceLocator; private IDictionary<string, Type> contractMapping; public CSLExportProvider(IServiceLocator serviceLocator) { this.contractMapping = new Dictionary<string, Type>();
421 Views
1 comments
/// <summary> /// Summary description for MvvmLightExtensionsFixture /// </summary> [TestClass] public class When_Subscribe_is_called_on_SingleSubscriber : MessengerContext { [TestMethod] public void then_message1_is_registered() { _mock.Verify(c =>c.Register<Message1>(_singleSubscriber, _singleSubscriber.Subscribe));
124 Views
no comments
[TestClass] public class MefEventAggregatorTestFixture { [TestMethod] public void Subscriber_is_invoked_when_publisher_raises_event() { var catalog = new InterceptingCatalog( new TypeCatalog(typeof(EventAggregator), typeof (FakePublisher), typeof (MockSubscriber)) ); var container = new CompositionContainer(catalog);
160 Views
no comments
//See Wes Haggard's updated implementation here: http://codepaste.net/ktdgoh //Adapting collection is a generic collection that allows you to adapt the contents using your own custom logic. public abstract class AdaptingCollection<T> : ICollection<T> { private readonly List<T> _innerCollection = new List<T>(); private List<T> _adaptedCollection; private bool _changed=true;
170 Views
no comments
public class GenericCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged
{
private ComposablePartCatalog _decoratedCatalog;
private AggregateCatalog _catalog = new AggregateCatalog();
private IDictionary<string, Type> _closedTypes = new Dictionary<string, Type>();
private IDictionary<string, Type> _genericTypes = new Dictionary<string, Type>();
public GenericCatalog(ComposablePartCatalog catalog)
{
_decoratedCatalog = catalog;
303 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
