Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
93 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
...ode/App_Config/Include/Feature/FormsExtensions/Feature.FormsExtensions.ApiServices.config
This file was deleted.
Oops, something went wrong.
33 changes: 23 additions & 10 deletions
33
src/Feature/FormsExtensions/code/Business/FieldBindings/FieldBindingMapFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
using Feature.FormsExtensions.Business.FieldBindings.xDbBindingHandlers.ContactAddress; | ||
using Feature.FormsExtensions.Business.FieldBindings.xDbBindingHandlers.ContactPersonalInfo; | ||
using Feature.FormsExtensions.XDb; | ||
using Feature.FormsExtensions.XDb.Repository; | ||
using System.Collections.Concurrent; | ||
using Sitecore; | ||
using Sitecore.Data; | ||
using Sitecore.Data.Items; | ||
using Sitecore.ExperienceForms.Mvc.Models; | ||
using Sitecore.Reflection; | ||
|
||
namespace Feature.FormsExtensions.Business.FieldBindings | ||
{ | ||
public class FieldBindingMapFactory : IFieldBindingMapFactory | ||
{ | ||
private static readonly ConcurrentDictionary<string, IBindingHandler> BindingHandlers = new ConcurrentDictionary<string, IBindingHandler>(); | ||
|
||
public IBindingHandler GetBindingHandler(ValueProviderSettings valueProviderSettings) | ||
{ | ||
string str = valueProviderSettings?.ValueProviderItemId; | ||
var str = valueProviderSettings?.ValueProviderItemId; | ||
if (!ID.IsID(str)) | ||
return null; | ||
Item obj1 = Sitecore.Context.Database.GetItem(str); | ||
string modelType = obj1?["Model Type"]; | ||
if (string.IsNullOrEmpty(modelType)) | ||
var valueProviderItem = Context.Database.GetItem(str); | ||
var modelType = valueProviderItem?["Model Type"]; | ||
return string.IsNullOrEmpty(modelType) ? null : CreateBindingHandler(modelType); | ||
} | ||
|
||
public IBindingHandler CreateBindingHandler(string modelType) | ||
{ | ||
if (BindingHandlers.TryGetValue(modelType, out var bindingHandler)) | ||
{ | ||
return bindingHandler; | ||
} | ||
var typeInfo = ReflectionUtil.GetTypeInfo(modelType); | ||
if (typeInfo == null) | ||
return null; | ||
return new XDbFirstNameBindingHandler(); | ||
bindingHandler = ReflectionUtil.CreateObject(typeInfo) as IBindingHandler; | ||
if (bindingHandler != null) | ||
BindingHandlers.TryAdd(modelType, bindingHandler); | ||
return bindingHandler; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters