我尝试从Fabric迁移到Firebase,并且想知道如何将我的应用程序用户链接到Firebase?在Fabric中,我使用了Crashlytics.setUserName
在Firebase中是什么等效方法?
答案 0 :(得分:1)
来自Firebase的Mike。与using System;
using System.Globalization;
using System.Web.Mvc;
public class ValueTypeModelBinder<T> : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var modelState = new ModelState { Value = valueResult };
var result = default(T);
try
{
var srcValue = valueResult.AttemptedValue;
var targetType = typeof(T);
//Hp --> Logic: Check whether target type is nullable (or) not?
//If Yes, Take underlying type for value conversion.
if (targetType.IsGenericType &&
targetType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
targetType = Nullable.GetUnderlyingType(targetType);
}
if (targetType.IsValueType && (!string.IsNullOrWhiteSpace(srcValue)))
{
result = (T)Convert.ChangeType(srcValue, targetType, CultureInfo.CurrentUICulture);
}
}
catch (Exception ex)
{
modelState.Errors.Add(ex);
}
bindingContext.ModelState.Add(bindingContext.ModelName, modelState);
return result;
}
}
最接近的方法是using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
ModelBinders.Binders.Add(typeof(decimal?), new ValueTypeModelBinder<decimal?>());
ModelBinders.Binders.Add(typeof(decimal), new ValueTypeModelBinder<decimal>());
ModelBinders.Binders.Add(typeof(int), new ValueTypeModelBinder<int>());
ModelBinders.Binders.Add(typeof(double?), new ValueTypeModelBinder<double?>());
}
}
。