コード例 #1
0
        public static void SetFactory(LayoutInflater inflater, IViewFactory factory)
        {
            LayoutInflaterFactoryWrapper factoryWrapper = null;

            if (!HasFactory(inflater))
            {
                factoryWrapper = GetWrapper(inflater, factory);
                if (FactoryField == null)
                {
                    inflater.Factory = factoryWrapper;
                }
                else
                {
                    FactoryField.Set(inflater, factoryWrapper);
                }
            }
            if (AndroidToolkitExtensions.IsApiGreaterThan10 && !HasFactory2(inflater))
            {
                if (factoryWrapper == null)
                {
                    factoryWrapper = GetWrapper(inflater, factory);
                }
                if (Factory2Field == null)
                {
                    inflater.Factory2 = factoryWrapper;
                }
                else
                {
                    Factory2Field.Set(inflater, factoryWrapper);
                }
            }
        }
コード例 #2
0
 public static void SetFactory(LayoutInflater inflater, IViewFactory factory)
 {
     if (PlatformExtensions.IsApiGreaterThan10)
     {
         if (inflater.Factory is LayoutInflaterFactoryWrapper && inflater.Factory2 is LayoutInflaterFactoryWrapper)
             return;
     }
     else
     {
         if (inflater.Factory is LayoutInflaterFactoryWrapper)
             return;
     }
     if (factory == null && !ServiceProvider.TryGet(out factory))
         factory = new ViewFactory();
     var factoryWrapper = new LayoutInflaterFactoryWrapper(inflater, factory);
     FactoryField.Set(inflater, factoryWrapper);
     if (Factory2Field != null)
         Factory2Field.Set(inflater, factoryWrapper);
 }