private static object ComputeConfigDelegateResult(this IDynamicPanelDefinition definition, string delegatePropertyName, object view, object viewModel) { definition.AssertNotNull(nameof(definition)); view.AssertParameterNotNull(nameof(view)); viewModel.AssertParameterNotNull(nameof(viewModel)); var config = definition.GetConfig(); var configType = config.GetType().GetGenericArguments().Single(); var del = config.GetType().GetProperty(delegatePropertyName).GetValue(config).SafeCast <Delegate>(); if (configType == definition.View || configType == definition.IView) { return(del.DynamicInvoke(view)); } else if (configType == definition.ViewModel || configType == definition.IViewModel) { return(del.DynamicInvoke(viewModel)); } else { throw new Exception($"Internal Error : DynamicPanelDefinition<{definition.IView.Name}, {definition.View.Name}, {definition.IViewModel.Name}, {definition.ViewModel.Name}> : \n " + $"DynamicPanelConfiguration Generic Type is not valid and has not been correctly asserted."); } }
internal static PanelPlacement GetPlacement(this IDynamicPanelDefinition definition) { definition.AssertNotNull(nameof(definition)); var config = definition.GetConfig(); return(config.GetType().GetProperty("Placement").GetValue(config).SafeCast <PanelPlacement>()); }