VisualBasicSettings.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / Microsoft / VisualBasic / Activities / VisualBasicSettings.cs / 1407647 / VisualBasicSettings.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace Microsoft.VisualBasic.Activities 
{
    using Microsoft.VisualBasic.Activities.XamlIntegration; 
    using System; 
    using System.Activities;
    using System.Collections.Generic; 
    using System.Runtime;
    using System.Windows.Markup;
    using System.Xaml;
    using System.ComponentModel; 
    using System.Reflection;
 
    [ValueSerializer(typeof(VisualBasicSettingsValueSerializer))] 
    [TypeConverter(typeof(VisualBasicSettingsConverter))]
    public class VisualBasicSettings 
    {

        static readonly HashSet defaultImportReferences = new HashSet()
        { 
            //"mscorlib"
            new VisualBasicImportReference { Import = "System", Assembly = "mscorlib" }, 
            new VisualBasicImportReference { Import = "System.Collections", Assembly = "mscorlib" }, 
            new VisualBasicImportReference { Import = "System.Collections.Generic", Assembly = "mscorlib" },
            //"system" 
            new VisualBasicImportReference { Import = "System", Assembly = "system" },
            new VisualBasicImportReference { Import = "System.Collections.Generic", Assembly = "system" },
            //"System.Activities"
            new VisualBasicImportReference { Import = "System.Activities", Assembly = "System.Activities" }, 
            new VisualBasicImportReference { Import = "System.Activities.Statements", Assembly = "System.Activities" },
            new VisualBasicImportReference { Import = "System.Activities.Expressions", Assembly = "System.Activities" }, 
        }; 

        static VisualBasicSettings defaultSettings = new VisualBasicSettings(defaultImportReferences); 

        public VisualBasicSettings()
        {
            this.ImportReferences = new HashSet(); 
        }
 
        VisualBasicSettings(HashSet importReferences) 
        {
            Fx.Assert(importReferences != null, "caller must verify"); 
            this.ImportReferences = new HashSet(importReferences);
        }

        public static VisualBasicSettings Default 
        {
            get 
            { 
                return defaultSettings;
            } 
        }

        // hide from XAML since the value serializer can't suppress yet
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 
        public ISet ImportReferences
        { 
            get; 
            private set;
        } 

        internal bool SuppressXamlSerialization
        {
            get; 
            set;
        } 
 
        internal void GenerateXamlReferences(IValueSerializerContext context)
        { 
            // promote settings to xmlns declarations
            INamespacePrefixLookup namespaceLookup = GetService(context);
            foreach (VisualBasicImportReference importReference in this.ImportReferences)
            { 
                importReference.GenerateXamlNamespace(namespaceLookup);
            } 
        } 

        internal static T GetService(ITypeDescriptorContext context) where T : class 
        {
            T service = (T)context.GetService(typeof(T));
            if (service == null)
            { 
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidTypeConverterUsage));
            } 
 
            return service;
        } 
    }
}

// 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