/// <summary>
        /// Gets a strong typed interface layer for a pattern.
        /// </summary>
        public static TInterface As <TInterface>(this IInstanceBase instance)
        {
            Guard.NotNull(() => instance, instance);

            if (resolvingInstanceBaseAs.Value.GetValueOrDefault())
            {
                throw new InvalidOperationException(String.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.ToolkitInterfaceLayer_InstanceTypeDoesNotHaveInterfaceLayer,
                                                        instance.GetType()));
            }

            dynamic dynInstance = instance;

            resolvingInstanceBaseAs.Value = true;
            try
            {
                return((TInterface)ToolkitInterfaceLayer.As <TInterface>(dynInstance));
            }
            finally
            {
                resolvingInstanceBaseAs.Value = null;
            }
        }
Example #2
0
 public IEnumerable <TExtension> GetExtensions <TExtension>(Expression <Func <IEnumerable <TExtension> > > propertyExpresion, Func <IProduct, TExtension> productProxyFactory)
     where TExtension : class
 {
     return(ToolkitInterfaceLayer.GetExtensions(this.container, propertyExpresion, productProxyFactory));
 }
Example #3
0
 public IEnumerable <TElement> GetElements <TElement>(Expression <Func <IEnumerable <TElement> > > propertyExpresion, Func <IAbstractElement, TElement> elementProxyFactory)
     where TElement : class
 {
     return(ToolkitInterfaceLayer.GetElements(this.container, propertyExpresion, elementProxyFactory));
 }
Example #4
0
 public TExtension CreateExtension <TExtension>(string name, Guid productId, string toolkitId, Action <TExtension> initializer = null, bool raiseInstantiateEvents = true)
     where TExtension : class
 {
     return(ToolkitInterfaceLayer.CreateExtension(this.container, name, productId, toolkitId, initializer, raiseInstantiateEvents));
 }
Example #5
0
 public TCollection CreateCollection <TCollection>(string name, Action <TCollection> initializer = null, bool raiseInstantiateEvents = true)
     where TCollection : class
 {
     return(ToolkitInterfaceLayer.CreateCollection(this.container, name, initializer, raiseInstantiateEvents));
 }
Example #6
0
 public TElement CreateElement <TElement>(string name, Action <TElement> initializer = null, bool raiseInstantiateEvents = true)
     where TElement : class
 {
     return(ToolkitInterfaceLayer.CreateElement(this.container, name, initializer, raiseInstantiateEvents));
 }
 public void SetValue <TProperty>(Expression <Func <TProperty> > propertyExpresion, TProperty value)
 {
     ToolkitInterfaceLayer.SetValue <TInterface, TProperty>(this.element, propertyExpresion, value);
 }
 public TProperty GetValue <TProperty>(Expression <Func <TProperty> > propertyExpresion)
 {
     return(ToolkitInterfaceLayer.GetValue <TInterface, TProperty>(this.element, propertyExpresion));
 }
Example #9
0
 public TView GetView <TView>(Expression <Func <TView> > propertyExpresion, Func <IView, TView> viewProxyFactory)
     where TView : class
 {
     return(ToolkitInterfaceLayer.GetView <TInterface, TView>(this.product, propertyExpresion, viewProxyFactory));
 }