コード例 #1
0
 protected override void DetachInnerBindings()
 {
     if (Bindings.Any())
     {
         Container.SetOnClickListener(null);
     }
 }
コード例 #2
0
        public IISSiteWrapper(Site site)
        {
            var ftpSsl = !string.IsNullOrWhiteSpace(site.
                                                    GetChildElement("ftpServer")?.
                                                    GetChildElement("security")?.
                                                    GetChildElement("ssl")?.
                                                    GetAttributeValue("serverCertHash")?.
                                                    ToString());

            Site     = site;
            Bindings = site.Bindings.Select(x =>
            {
                var secure = x.Protocol == "https" || ((x.Protocol == "ftp") && ftpSsl);
                return(new IISBindingWrapper(x, secure));
            }).ToList();

            if (Bindings.All(b => b.Protocol == "ftp" || b.Protocol == "ftps"))
            {
                Type = IISSiteType.Ftp;
            }
            else if (Bindings.Any(b => b.Protocol == "http" || b.Protocol == "https"))
            {
                Type = IISSiteType.Web;
            }
        }
コード例 #3
0
ファイル: KeyBindingService.cs プロジェクト: codecopy/core-1
 void KeybindingPressed(string keystring, IntPtr user_data)
 {
     if (Bindings.Any(k => k.KeyString == keystring))
     {
         Bindings.First(k => k.KeyString == keystring).Callback(null);
     }
 }
コード例 #4
0
ファイル: KeyBindingService.cs プロジェクト: codecopy/core-1
 public override bool UnRegisterOSKey(string keyString)
 {
     if (Bindings.Any(k => k.KeyString == keyString))
     {
         return(gnomedo_keybinder_unbind(keyString, key_handler));
     }
     return(false);
 }
コード例 #5
0
 public bool Process(Key key, ModifierKeys modifiers)
 {
     if (Bindings.Any(binding => binding != null &&
                      binding.Key == key &&
                      binding.Modifiers == modifiers))
     {
         onPressed();
         return(true);
     }
     return(false);
 }
コード例 #6
0
 public override void ViewDidUnload()
 {
     base.ViewDidUnload();
     if (Bindings.Any())
     {
         foreach (var b in Bindings)
         {
             b.Detach();
         }
         Bindings.Clear();
     }
 }
コード例 #7
0
        public async Task <bool> ProcessAsync(Key key, ModifierKeys modifiers)
        {
            if (Bindings.Any(binding => binding != null &&
                             binding.Key == key &&
                             binding.Modifiers == modifiers))
            {
                await onPressed();

                return(true);
            }
            return(false);
        }
コード例 #8
0
        protected override void DetachInnerBindings()
        {
            if (Bindings.Any())
            {
                AnimeGridItemMoreButton.SetOnClickListener(null);
                Container.SetOnClickListener(null);
            }

            _bindingsInitialized        = false;
            _oneTimeBindingsInitialized = false;
            _swipeLayoutInitialized     = false;
        }
コード例 #9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (RootView == null)
            {
                RootView = inflater.Inflate(LayoutResourceId, container, false);
            }
            if (!_initialized || (!Bindings.Any() && !_hasNonTrackableBindings)) // if bindings are present for this view we won't generate new ones, if it's first creation we have to do this anyway
            {
                InitBindings();
            }

            _initialized = true;

            return(RootView);
        }
コード例 #10
0
        /// <inheritdoc />
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (RootView == null)
            {
                RootView = inflater.Inflate(LayoutResourceId, container, false);

                if (CustomDialogConfig != null)
                {
                    Cancelable = CustomDialogConfig.IsCancellable;
                    Dialog.Window.SetGravity(GetGravityFromConfig(CustomDialogConfig.Gravity));
                }
            }

            // if bindings are present for this view we won't generate new ones, if it's first creation we have to do this anyway
            if (!_initialized || !Bindings.Any())
            {
                InitBindings();
            }

            _initialized = true;

            return(RootView);
        }
コード例 #11
0
        public override void InfoPanelText(InfoPanelContent content, PrettyPrintFormat format)
        {
            SummaryInfo(content);
            content.Append("Highlighted terms are ");
            if (bindingInfo.IsPatternMatch())
            {
                content.switchFormat(PrintConstants.DefaultFont, PrintConstants.patternMatchColor);
                content.Append("matched");
                content.switchToDefaultFormat();
                content.Append(" or ");
                content.switchFormat(PrintConstants.DefaultFont, PrintConstants.equalityColor);
                content.Append(PrintConstants.LargeTextMode ? "matched using\nequality" : "matched using equality");
                content.switchToDefaultFormat();
                content.Append(" or ");
            }
            content.switchFormat(PrintConstants.DefaultFont, PrintConstants.blameColor);
            content.Append("blamed");
            content.switchToDefaultFormat();
            content.Append(" or ");
            content.switchFormat(PrintConstants.DefaultFont, PrintConstants.bindColor);
            content.Append("bound");
            content.switchToDefaultFormat();
            content.Append(".\n\n");

            tempHighlightBlameBindTerms(format);

            if (!bindingInfo.IsPatternMatch())
            {
                content.switchFormat(PrintConstants.BoldFont, PrintConstants.instantiationTitleColor);
                if (InstantiationMethod == "theory-solving")
                {
                    content.Append($"Instantiated by the {Quant.Namespace} theory solver.\n\n");
                }
                else
                {
                    content.Append($"Instantiated using {InstantiationMethod}.\n\n");
                }
                content.switchToDefaultFormat();

                if (bindingInfo.explicitlyBlamedTerms.Any())
                {
                    content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
                    content.Append("Blamed Terms:\n");
                    content.switchToDefaultFormat();
                }

                var termNumbering = 1;

                foreach (var t in bindingInfo.explicitlyBlamedTerms)
                {
                    if (!format.termNumbers.TryGetValue(t, out var termNumber))
                    {
                        termNumber = termNumbering;
                        ++termNumbering;
                        format.termNumbers[t] = termNumber;
                    }
                    var numberingString = $"({termNumber}) ";
                    content.Append($"\n{numberingString}");
                    t.PrettyPrint(content, format, numberingString.Length);
                    content.switchToDefaultFormat();
                    content.Append("\n\n");
                }
            }

            if (bindingInfo.IsPatternMatch())
            {
                content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
                content.Append("Blamed Terms:\n\n");
                content.switchToDefaultFormat();

                var termNumbering = 1;

                var blameTerms         = bindingInfo.getDistinctBlameTerms();
                var distinctBlameTerms = blameTerms.Where(req => bindingInfo.TopLevelTerms.Contains(req) ||
                                                          (!bindingInfo.equalities.SelectMany(eq => eq.Value).Any(t => t.Item2.id == req.id) &&
                                                           !bindingInfo.equalities.Keys.Any(k => bindingInfo.bindings[k].Item2 == req)));

                foreach (var t in distinctBlameTerms)
                {
                    if (!format.termNumbers.TryGetValue(t, out var termNumber))
                    {
                        termNumber = termNumbering;
                        ++termNumbering;
                        format.termNumbers[t] = termNumber;
                    }
                    var numberingString = $"({termNumber}) ";
                    content.Append($"\n{numberingString}");
                    t.PrettyPrint(content, format, numberingString.Length);
                    content.switchToDefaultFormat();
                    content.Append("\n\n");
                }

                if (bindingInfo.equalities.Count > 0)
                {
                    var numberOfTopLevelTerms = bindingInfo.getDistinctBlameTerms().Count;

                    content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
                    content.Append("\nRelevant equalities:\n\n");
                    content.switchToDefaultFormat();

                    format.printContextSensitive = false;
                    foreach (var equality in bindingInfo.equalities)
                    {
                        var effectiveTerm = bindingInfo.bindings[equality.Key].Item2;
                        foreach (var term in equality.Value.Select(t => t.Item2).Distinct(Term.semanticTermComparer))
                        {
                            EqualityExplanation explanation;
#if !DEBUG
                            try
                            {
#endif
                            explanation = bindingInfo.EqualityExplanations.First(ee => ee.source.id == term.id && ee.target.id == effectiveTerm.id);
#if !DEBUG
                        }
                        catch (Exception)
                        {
                            explanation = new TransitiveEqualityExplanation(term, effectiveTerm, new EqualityExplanation[0]);
                        }
#endif
                            if (!format.equalityNumbers.TryGetValue(explanation, out var termNumber))
                            {
                                termNumber = termNumbering;
                                ++termNumbering;
                                format.equalityNumbers[explanation] = termNumber;
                            }

                            if (format.ShowEqualityExplanations)
                            {
                                explanation.PrettyPrint(content, format, termNumber);
                            }
                            else
                            {
                                var numberingString = $"({termNumber}) ";
                                content.switchToDefaultFormat();
                                content.Append(numberingString);
                                var indentString = $"¦{String.Join("", Enumerable.Repeat(" ", numberingString.Length - 1))}";
                                term.PrettyPrint(content, format, numberingString.Length);
                                content.switchToDefaultFormat();
                                content.Append($"\n{indentString}= (explanation omitted)\n{indentString}");
                                effectiveTerm.PrettyPrint(content, format, numberingString.Length);
                            }
                            content.Append("\n\n");
                        }
                    }
                    format.printContextSensitive = true;

                    bindingInfo.PrintEqualitySubstitution(content, format);
                }
            }

            if (Bindings.Any())
            {
                content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
                content.Append("Binding information:");
                content.switchToDefaultFormat();

                foreach (var bindings in bindingInfo.getBindingsToFreeVars())
                {
                    content.Append("\n\n");
                    content.Append(bindings.Key.PrettyName).Append(" was bound to:\n");
                    bindings.Value.PrettyPrint(content, format);
                    content.switchToDefaultFormat();
                }
            }

            if (Quant.BodyTerm != null)
            {
                content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
                content.Append("\n\n\nThe quantifier body:\n\n");
                content.switchToDefaultFormat();
                Quant.BodyTerm.PrettyPrint(content, format);
                content.Append("\n\n");
            }
            format.restoreAllOriginalRules();

            content.switchToDefaultFormat();
            content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor);
            content.Append("The resulting term:\n\n");
            content.switchToDefaultFormat();
            concreteBody.PrettyPrint(content, format);

            format.restoreAllOriginalRules();
        }
コード例 #12
0
        public void NavigatedTo()
        {
            if (Bindings.Any())
            {
                return;
            }

            (RootView as FrameLayout).AddView(
                Activity.LayoutInflater.Inflate(Resource.Layout.ProfilePageStatsTabContent, null));


            Bindings.Add(this.SetBinding(() => ViewModel.MangaChartValues)
                         .WhenSourceChanges(() =>
            {
                if (ViewModel.AnimeChartValues == null || ViewModel.MangaChartValues == null)
                {
                    return;
                }

                var all      = ViewModel.AnimeChartValues.Sum();
                var allManga = ViewModel.MangaChartValues.Sum();


                LinearLayout.LayoutParams param;
                if (all > 0)
                {
                    /////////
                    //ANIME//
                    /////////
                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentWatchingAnimeBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.AnimeWatching * 100.0f / all;
                    ProfilePageStatsFragmentWatchingAnimeBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentWatchingAnimeBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentWatchingAnimeBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentCompletedAnimeBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.AnimeCompleted * 100.0f / all;
                    ProfilePageStatsFragmentCompletedAnimeBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentCompletedAnimeBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentCompletedAnimeBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentOnHoldAnimeBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.AnimeOnHold * 100.0f / all;
                    ProfilePageStatsFragmentOnHoldAnimeBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentOnHoldAnimeBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentOnHoldAnimeBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentDroppedAnimeBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.AnimeDropped * 100.0f / all;
                    ProfilePageStatsFragmentDroppedAnimeBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentDroppedAnimeBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentDroppedAnimeBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentPlannedAnimeBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.AnimePlanned * 100.0f / all;
                    ProfilePageStatsFragmentPlannedAnimeBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentPlannedAnimeBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentPlannedAnimeBarLabel.Text = "";
                    }
                }
                else
                {
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentWatchingAnimeBar.LayoutParameters).Weight  = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentCompletedAnimeBar.LayoutParameters).Weight = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentOnHoldAnimeBar.LayoutParameters).Weight    = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentDroppedAnimeBar.LayoutParameters).Weight   = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentPlannedAnimeBar.LayoutParameters).Weight   = 0;

                    ProfilePageStatsFragmentWatchingAnimeBarLabel.Text  = "";
                    ProfilePageStatsFragmentCompletedAnimeBarLabel.Text = "";
                    ProfilePageStatsFragmentOnHoldAnimeBarLabel.Text    = "";
                    ProfilePageStatsFragmentDroppedAnimeBarLabel.Text   = "";
                    ProfilePageStatsFragmentPlannedAnimeBarLabel.Text   = "";
                }

                if (allManga > 0)
                {
                    /////////
                    //MANGA//
                    /////////
                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentWatchingMangaBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.MangaReading * 100.0f / allManga;
                    ProfilePageStatsFragmentWatchingMangaBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentWatchingMangaBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentWatchingMangaBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentCompletedMangaBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.MangaCompleted * 100.0f / allManga;
                    ProfilePageStatsFragmentCompletedMangaBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentCompletedMangaBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentCompletedMangaBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentOnHoldMangaBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.MangaOnHold * 100.0f / allManga;
                    ProfilePageStatsFragmentOnHoldMangaBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentOnHoldMangaBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentOnHoldMangaBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentDroppedMangaBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.MangaDropped * 100.0f / allManga;
                    ProfilePageStatsFragmentDroppedMangaBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentDroppedMangaBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentDroppedMangaBarLabel.Text = "";
                    }

                    param        = (LinearLayout.LayoutParams)ProfilePageStatsFragmentPlannedMangaBar.LayoutParameters;
                    param.Weight = ViewModel.CurrentData.MangaPlanned * 100.0f / allManga;
                    ProfilePageStatsFragmentPlannedMangaBar.LayoutParameters = param;
                    if (param.Weight > 7)
                    {
                        ProfilePageStatsFragmentPlannedMangaBarLabel.Text = $"{param.Weight:N0}%";
                    }
                    else
                    {
                        ProfilePageStatsFragmentPlannedMangaBarLabel.Text = "";
                    }
                }
                else
                {
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentWatchingMangaBar.LayoutParameters).Weight  = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentCompletedMangaBar.LayoutParameters).Weight = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentOnHoldMangaBar.LayoutParameters).Weight    = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentDroppedMangaBar.LayoutParameters).Weight   = 0;
                    ((LinearLayout.LayoutParams)ProfilePageStatsFragmentPlannedMangaBar.LayoutParameters).Weight   = 0;

                    ProfilePageStatsFragmentWatchingMangaBarLabel.Text  = "";
                    ProfilePageStatsFragmentCompletedMangaBarLabel.Text = "";
                    ProfilePageStatsFragmentOnHoldMangaBarLabel.Text    = "";
                    ProfilePageStatsFragmentDroppedMangaBarLabel.Text   = "";
                    ProfilePageStatsFragmentPlannedMangaBarLabel.Text   = "";
                }


                ////ANIME BOTTOM

                WatchingAnimeCount.Text  = ViewModel.CurrentData.AnimeWatching.ToString();
                CompletedAnimeCount.Text = ViewModel.CurrentData.AnimeCompleted.ToString();
                OnHoldAnimeCount.Text    = ViewModel.CurrentData.AnimeOnHold.ToString();
                DroppedAnimeCount.Text   = ViewModel.CurrentData.AnimeDropped.ToString();
                PlannedAnimeCount.Text   = ViewModel.CurrentData.AnimePlanned.ToString();

                TotalAnimeCount.Text     = ViewModel.CurrentData.AnimeTotal.ToString();
                RewatchedAnimeCount.Text = ViewModel.CurrentData.AnimeRewatched.ToString();
                EpisodesAnimeCount.Text  = ViewModel.CurrentData.AnimeEpisodes.ToString();

                //AnimeDaysLabel.Text = $"Days: {ViewModel.CurrentData.AnimeDays:N1}";
                AnimeMeanLabel.Text = $"Mean: {ViewModel.CurrentData.AnimeMean:N2}";

                ////MANGA BOTTOM

                WatchingMangaCount.Text  = ViewModel.CurrentData.MangaReading.ToString();
                CompletedMangaCount.Text = ViewModel.CurrentData.MangaCompleted.ToString();
                OnHoldMangaCount.Text    = ViewModel.CurrentData.MangaOnHold.ToString();
                DroppedMangaCount.Text   = ViewModel.CurrentData.MangaDropped.ToString();
                PlannedMangaCount.Text   = ViewModel.CurrentData.MangaPlanned.ToString();

                TotalMangaCount.Text    = ViewModel.CurrentData.MangaTotal.ToString();
                RereadMangaCount.Text   = ViewModel.CurrentData.MangaReread.ToString();
                ChaptersMangaCount.Text = ViewModel.CurrentData.MangaChapters.ToString();
                VolumesMangaCount.Text  = ViewModel.CurrentData.MangaVolumes.ToString();

                MangaDaysLabel.Text = $"Days: {ViewModel.CurrentData.MangaDays:N1}";
                MangaMeanLabel.Text = $"Mean: {ViewModel.CurrentData.MangaMean:N2}";

                StatsApproxTimeSpentAnime.Text  = ViewModel.ApproxTimeSpentOnAnime;
                StatsApproxTimeSpentMovies.Text = ViewModel.ApproxTimeSpentOnMovies;
                StatsApproxTimeSpentBoth.Text   = ViewModel.ApproxTimeSpentOnAnimeAndMovies;
            }));
        }
コード例 #13
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (MultiBinding != null)
            {
                if (Bindings.Any())
                {
                    throw new ArgumentException($"{nameof(Bindings)} should be an empty");
                }
                if (Converter != null)
                {
                    throw new ArgumentException($"{nameof(Converter)} should be a null");
                }
            }
            else
            {
                if (!Bindings.Any())
                {
                    throw new ArgumentNullException(nameof(Bindings));
                }
                if (Converter == null)
                {
                    throw new ArgumentNullException(nameof(Converter));
                }
            }

            var target = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));

            if (target.TargetObject.GetType().FullName == "System.Windows.SharedDp")
            {
                return(this);
            }

            if (MultiBinding != null)
            {
                Converter          = MultiBinding.Converter;
                ConverterParameter = MultiBinding.ConverterParameter;
                ConverterCulture   = MultiBinding.ConverterCulture;
                foreach (var bindingBase in MultiBinding.Bindings)
                {
                    Bindings.Add(bindingBase);
                }
            }

            if (target.TargetObject is NestedBindingCollection)
            {
                var binding = new Binding
                {
                    Source = this
                };
                return(binding);
            }

            var multiBinding = new MultiBinding
            {
                Mode = BindingMode.OneWay
            };
            var tree      = GetNestedBindingsTree(this, multiBinding);
            var converter = new NestedBindingConverter(tree);

            multiBinding.Converter = converter;

            return(multiBinding.ProvideValue(serviceProvider));
        }
コード例 #14
0
        public void CreateDefaultBindings()
        {
            var sourceProperties = typeof(TSource).GetProperties();

            foreach (var targetProperty in typeof(TTarget).GetProperties())
            {
                if (!Bindings.Any(b => b.TargetMember.Name == targetProperty.Name))
                {
                    PropertyInfo sourceProperty = null;

                    if (sourceProperties.Any(p => p.Name == targetProperty.Name))
                    {
                        sourceProperty = sourceProperties.First(p => p.Name == targetProperty.Name);
                    }
                    else
                    {
                        var attribute = targetProperty.GetCustomAttributes(typeof(MapPropertyAttribute), false).FirstOrDefault();
                        if (attribute != null)
                        {
                            sourceProperty = sourceProperties.FirstOrDefault(p => p.Name == (attribute as MapPropertyAttribute).PropertyName);

                            if (sourceProperty == null)
                            {
                                throw new InvalidPropertyNameException("Cannot find property: " + (attribute as MapPropertyAttribute).PropertyName);
                            }
                        }
                    }

                    if (sourceProperty != null)
                    {
                        if (sourceProperty.PropertyType == targetProperty.PropertyType)
                        {
                            Bindings.Add(new MemberBinding
                            {
                                SourceExpression = Expression.Property(SourceParameter, sourceProperty),
                                TargetMember     = targetProperty
                            });
                        }
                        else if (sourceProperty.PropertyType.IsClass && sourceProperty.PropertyType != typeof(string))
                        {
                            AddDependency(sourceProperty.PropertyType, targetProperty.PropertyType);

                            Bindings.Add(new DependentComplexMemberBinding
                            {
                                SourceType       = sourceProperty.PropertyType,
                                TargetType       = targetProperty.PropertyType,
                                SourceExpression = null,
                                SourceMember     = sourceProperty,
                                TargetMember     = targetProperty
                            });
                        }
                        else if (sourceProperty.PropertyType.IsGenericType && typeof(ICollection <>).IsAssignableFrom(sourceProperty.PropertyType.GetGenericTypeDefinition()))
                        {
                            var sourceType = sourceProperty.PropertyType.GenericTypeArguments[0];
                            var targetType = targetProperty.PropertyType.GenericTypeArguments[0];

                            if (sourceType == targetType)
                            {
                                DefaultListMemberBinding(Expression.Property(SourceParameter, sourceProperty), targetProperty, targetType);
                            }
                            else
                            {
                                AddDependency(sourceType, targetType);

                                Bindings.Add(new DependentListMemberBinding
                                {
                                    SourceType       = sourceType,
                                    TargetType       = targetType,
                                    SourceExpression = null,
                                    SourceMember     = sourceProperty,
                                    TargetMember     = targetProperty
                                });
                            }

                            // TODO what if the type argument is another list?....
                        }
                        else if (Nullable.GetUnderlyingType(sourceProperty.PropertyType) != null)
                        {
                            Bindings.Add(new MemberBinding
                            {
                                SourceExpression = Expression.Coalesce(Expression.Property(SourceParameter, sourceProperty), Expression.Default(targetProperty.PropertyType)),
                                TargetMember     = targetProperty
                            });
                        }
                        else if (Nullable.GetUnderlyingType(targetProperty.PropertyType) != null)
                        {
                            Bindings.Add(new MemberBinding
                            {
                                SourceExpression = Expression.Convert(Expression.Property(SourceParameter, sourceProperty), targetProperty.PropertyType),
                                TargetMember     = targetProperty
                            });
                        }
                    }
                    else
                    {
                        // If flattened properties exist, map them (e.g. ChildName -> Child.Name)
                        CheckPropertyFlattening(sourceProperties, targetProperty);
                    }
                }
            }

            if (ValidationMode == ValidationMode.Source)
            {
                if (typeof(TSource).GetProperties().Any(p => !Bindings.Any(b => b.TargetMember.Name == p.Name)))
                {
                    throw new MappingValidationException("Not all source properties are mapped!");
                }
            }
            else if (ValidationMode == ValidationMode.Destination)
            {
                if (typeof(TTarget).GetProperties().Any(p => !Bindings.Any(b => b.TargetMember.Name == p.Name)))
                {
                    throw new MappingValidationException("Not all destination properties are mapped!");
                }
            }
        }