示例#1
0
        public void Read()
        {
            var nested = NestedFactory.Create();

            nested.DoSomething();
            SimpleFile.Read();
        }
        protected virtual View OnCreateViewInternal(string name, Context context, IAttributeSet attrs)
        {
            View view     = null;
            var  fullName = GetFullName(name);

            if (PlatformExtensions.IsApiGreaterThan10 && NestedFactory2 != null)
            {
                if (fullName != null)
                {
                    view = NestedFactory2.OnCreateView(fullName, context, attrs);
                }
                if (view == null)
                {
                    view = NestedFactory2.OnCreateView(name, context, attrs);
                }
            }
            else if (NestedFactory != null)
            {
                if (fullName != null)
                {
                    view = NestedFactory.OnCreateView(fullName, context, attrs);
                }
                if (view == null)
                {
                    view = NestedFactory.OnCreateView(name, context, attrs);
                }
            }
            if (_ignoreViewTypes.Contains(name))
            {
                return(view);
            }

            ViewResult viewResult;

            if (view == null)
            {
                viewResult = _viewFactory.Create(name, Context, attrs);
                view       = viewResult.View;
            }
            else
            {
                var type = TypeCache <View> .Instance.GetTypeByName(name, true, false);

                if (type != null)
                {
                    var clazz = Java.Lang.Class.FromType(type);
                    if (clazz.IsInstance(view) && !type.IsInstanceOfType(view))
                    {
                        view = (View)JavaCastMethod.MakeGenericMethod(type).InvokeEx(null, view);
                    }
                }
                viewResult = _viewFactory.Initialize(view, attrs);
            }
            IList <string> bindings = viewResult.DataContext.GetData(ViewFactoryConstants.Bindings);

            if (bindings != null)
            {
                var manualBindings = view as IManualBindings;
                if (manualBindings == null)
                {
                    foreach (string binding in bindings)
                    {
                        BindingServiceProvider
                        .BindingProvider
                        .CreateBindingsFromString(view, binding);
                    }
                }
                else
                {
                    manualBindings.SetBindings(bindings);
                }
            }
            Func <View, string, Context, IAttributeSet, View> viewCreated = PlatformExtensions.ViewCreated;

            if (viewCreated == null)
            {
                return(view);
            }
            return(viewCreated(view, name, Context, attrs));
        }