Example #1
0
        public void AddMapping(ViewMapping mapping)
        {
            if (Mappings.Keys.Contains(mapping.GetHashCode()))
            {
                var sb = new System.Text.StringBuilder("ViewMapping Key already exists for type [");
                sb.Append(mapping.ViewModel);
                sb.Append("] with '");
                sb.Append(mapping.ViewType);
                sb.Append("' viewType");
                throw new InvalidOperationException(sb.ToString());
            }

            Mappings.Add(mapping.GetHashCode(), mapping);
        }
Example #2
0
        private ViewMapping GetMapping(Type viewModel, ViewType viewType = ViewType.Display)
        {
            var viewModelMapping = new ViewMapping(viewModel, null, viewType);

            if (Mappings.Keys.Contains(viewModelMapping.GetHashCode()))
            {
                return(Mappings[viewModelMapping.GetHashCode()]);
            }
            var sb = new System.Text.StringBuilder("ViewModel [");

            sb.Append(viewModelMapping.ViewModel);
            sb.Append("] was not found for ViewType ");
            sb.Append(viewModelMapping.ViewType);

            throw new KeyNotFoundException(sb.ToString());
        }
Example #3
0
 private bool Equals(ViewMapping other)
 {
     return(ViewModel.Equals(other.ViewModel) &&
            ViewType.Equals(other.ViewType));
 }