TypeResolvingOptions.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / View / TypeResolvingOptions.cs / 1305376 / TypeResolvingOptions.cs

                            //---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------
namespace System.Activities.Presentation.View
{ 
    using System.Runtime;
    using System.Collections.ObjectModel; 
    using System.Diagnostics.CodeAnalysis; 

    [Fx.Tag.XamlVisible(false)] 
    public class TypeResolvingOptions
    {
        public Func Filter
        { 
            get;
            set; 
        } 

        [SuppressMessage(FxCop.Category.Usage, FxCop.Rule.CollectionPropertiesShouldBeReadOnly, 
            Justification = "Setter is provided to data binding on this property.")]
        internal ObservableCollection MostRecentlyUsedTypes
        {
            get; 
            set;
        } 
 
        public bool BrowseTypeDirectly
        { 
            get;
            set;
        }
 
        internal static TypeResolvingOptions Merge(TypeResolvingOptions lhs, TypeResolvingOptions rhs)
        { 
            if (lhs == null) 
            {
                return rhs; 
            }
            else if (rhs == null)
            {
                return lhs; 
            }
 
            return new TypeResolvingOptions 
            {
                Filter = FuncAnd(lhs.Filter, rhs.Filter), 
                MostRecentlyUsedTypes = Intersect(lhs.MostRecentlyUsedTypes, rhs.MostRecentlyUsedTypes),
                BrowseTypeDirectly = lhs.BrowseTypeDirectly && rhs.BrowseTypeDirectly
            };
        } 

        static Func FuncAnd(Func lhs, Func rhs) 
        { 
            if (lhs == null)
            { 
                return rhs;
            }
            else if (rhs == null)
            { 
                return lhs;
            } 
 
            return new Func((e) => lhs(e) && rhs(e));
        } 

        static ObservableCollection Intersect(ObservableCollection lhs, ObservableCollection rhs)
        {
            if (lhs == null) 
            {
                return rhs; 
            } 
            else if (rhs == null)
            { 
                return lhs;
            }

            ObservableCollection collection = new ObservableCollection(); 
            foreach (T t in lhs)
            { 
                if (rhs.Contains(t)) 
                {
                    collection.Add(t); 
                }
            }

            return collection; 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------
namespace System.Activities.Presentation.View
{ 
    using System.Runtime;
    using System.Collections.ObjectModel; 
    using System.Diagnostics.CodeAnalysis; 

    [Fx.Tag.XamlVisible(false)] 
    public class TypeResolvingOptions
    {
        public Func Filter
        { 
            get;
            set; 
        } 

        [SuppressMessage(FxCop.Category.Usage, FxCop.Rule.CollectionPropertiesShouldBeReadOnly, 
            Justification = "Setter is provided to data binding on this property.")]
        internal ObservableCollection MostRecentlyUsedTypes
        {
            get; 
            set;
        } 
 
        public bool BrowseTypeDirectly
        { 
            get;
            set;
        }
 
        internal static TypeResolvingOptions Merge(TypeResolvingOptions lhs, TypeResolvingOptions rhs)
        { 
            if (lhs == null) 
            {
                return rhs; 
            }
            else if (rhs == null)
            {
                return lhs; 
            }
 
            return new TypeResolvingOptions 
            {
                Filter = FuncAnd(lhs.Filter, rhs.Filter), 
                MostRecentlyUsedTypes = Intersect(lhs.MostRecentlyUsedTypes, rhs.MostRecentlyUsedTypes),
                BrowseTypeDirectly = lhs.BrowseTypeDirectly && rhs.BrowseTypeDirectly
            };
        } 

        static Func FuncAnd(Func lhs, Func rhs) 
        { 
            if (lhs == null)
            { 
                return rhs;
            }
            else if (rhs == null)
            { 
                return lhs;
            } 
 
            return new Func((e) => lhs(e) && rhs(e));
        } 

        static ObservableCollection Intersect(ObservableCollection lhs, ObservableCollection rhs)
        {
            if (lhs == null) 
            {
                return rhs; 
            } 
            else if (rhs == null)
            { 
                return lhs;
            }

            ObservableCollection collection = new ObservableCollection(); 
            foreach (T t in lhs)
            { 
                if (rhs.Contains(t)) 
                {
                    collection.Add(t); 
                }
            }

            return collection; 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK