void InitGenericConverter(MethodInfo method) { if (method.GetCustomAttribute <DtoConvertAttribute>() == null) { return; } if (!method.IsGenericMethod) { return; } if (method.ReturnType != typeof(void)) { throw InvalidSignatureExceptionFactory.Create(method); } var parameters = method.GetParameters(); if (parameters.Length < 2 || parameters.Length > 3) { throw InvalidSignatureExceptionFactory.Create(method); } if (parameters[0].ParameterType.GUID != parameters[1].ParameterType.GUID) { throw InvalidSignatureExceptionFactory.Create(method); } var convertMethod = new GenericConvertMethodInfo() { Method = method, TemplateType = parameters[0].ParameterType }; //var parameterTypeUId = convertMethod.TemplateType.GUID; if (parameters.Length == 3) { convertMethod.HasContext = true; } var methodPars = method.GetParameters(); var converterName = GetGenericConverterName(convertMethod.TemplateType.GUID, methodPars[0].ParameterType, methodPars[1].ParameterType); if (!GenericConverters.TryGetValue(converterName, out List <GenericConvertMethodInfo> tList)) { GenericConverters[converterName] = new List <GenericConvertMethodInfo>(); } GenericConverters[converterName].Add(convertMethod); }
/// <summary> /// .en Navigate method to go to view a record with his id. /// </summary> /// <param name="navigationContext">.en Id of the record to go to.</param> public override void OnNavigatedTo(Microsoft.Practices.Prism.Regions.NavigationContext navigationContext) { string id = navigationContext.Parameters["Id"]; if (string.IsNullOrWhiteSpace(id) || id == default(TIdentifier).ToString()) { return; } TIdentifier tid = GenericConverters.ChangeType<TIdentifier>(id); this.ObjectElement = GetById(tid); this.Rebind(); }