// constructor used for a section
 internal FactoryRecord(
         string configKey,
         string group,
         string name,
         string factoryTypeName,
         bool allowLocation,
         ConfigurationAllowDefinition allowDefinition,
         ConfigurationAllowExeDefinition allowExeDefinition,
         OverrideModeSetting             overrideModeDefault,
         bool restartOnExternalChanges,
         bool requirePermission,
         bool isFromTrustedConfigRecord,
         bool isUndeclared,
         string filename,
         int lineNumber)
 {
     _configKey                  = configKey;
     _group                      = group;
     _name                       = name;
     _factoryTypeName            = factoryTypeName;
     _allowDefinition            = allowDefinition;
     _allowExeDefinition         = allowExeDefinition;
     _overrideModeDefault        = overrideModeDefault;
     AllowLocation               = allowLocation;
     RestartOnExternalChanges    = restartOnExternalChanges;
     RequirePermission           = requirePermission;
     IsFromTrustedConfigRecord   = isFromTrustedConfigRecord;
     IsUndeclared                = isUndeclared;
     _filename                   = filename;
     _lineNumber                 = lineNumber;
 }
 static OverrideModeSetting()
 {
     SectionDefault = new OverrideModeSetting();
     SectionDefault._mode = 1;
     LocationDefault = new OverrideModeSetting();
     LocationDefault._mode = 0;
 }
 static OverrideModeSetting()
 {
     SectionDefault        = new OverrideModeSetting();
     SectionDefault._mode  = 1;
     LocationDefault       = new OverrideModeSetting();
     LocationDefault._mode = 0;
 }
 internal static OverrideModeSetting CreateFromXmlReadValue(System.Configuration.OverrideMode mode)
 {
     OverrideModeSetting setting = new OverrideModeSetting();
     setting.SetMode(mode);
     setting._mode = (byte) (setting._mode | 0x80);
     return setting;
 }
Esempio n. 5
0
        private List<ConfigurationException>    _errors;                // errors

        // constructor used for Clone()
        FactoryRecord(
                string              configKey,
                string              group,
                string              name,
                object              factory,
                string              factoryTypeName,
                SimpleBitVector32   flags,
                ConfigurationAllowDefinition    allowDefinition,
                ConfigurationAllowExeDefinition allowExeDefinition,
                OverrideModeSetting             overrideModeDefault,
                string              filename,
                int                 lineNumber,
                ICollection<ConfigurationException> errors) {

            _configKey              = configKey;
            _group                  = group;
            _name                   = name;
            _factory                = factory;
            _factoryTypeName        = factoryTypeName;
            _flags                  = flags;
            _allowDefinition        = allowDefinition;
            _allowExeDefinition     = allowExeDefinition;
            _overrideModeDefault    = overrideModeDefault;
            _filename               = filename;
            _lineNumber             = lineNumber;

            AddErrors(errors);
        }
Esempio n. 6
0
        // constructor used for a section
        internal FactoryRecord(
                string configKey,
                string group,
                string name,
                string factoryTypeName,
                bool allowLocation,
                ConfigurationAllowDefinition allowDefinition,
                ConfigurationAllowExeDefinition allowExeDefinition,
                OverrideModeSetting             overrideModeDefault,
                bool restartOnExternalChanges,
                bool requirePermission,
                bool isFromTrustedConfigRecord,
                bool isUndeclared,
                string filename,
                int lineNumber) {

            _configKey                  = configKey;
            _group                      = group;
            _name                       = name;
            _factoryTypeName            = factoryTypeName;
            _allowDefinition            = allowDefinition;
            _allowExeDefinition         = allowExeDefinition;
            _overrideModeDefault        = overrideModeDefault;
            AllowLocation               = allowLocation;
            RestartOnExternalChanges    = restartOnExternalChanges;
            RequirePermission           = requirePermission;
            IsFromTrustedConfigRecord   = isFromTrustedConfigRecord;
            IsUndeclared                = isUndeclared;
            _filename                   = filename;
            _lineNumber                 = lineNumber;
        }
Esempio n. 7
0
        private static bool IsMatchingApiChangedLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            // x must be a changed through the API setting
            // Returns true if x and y can share the same location tag

            Debug.Assert((x._mode & ApiDefinedAny) != 0);

            bool result = false;

            if ((y._mode & ApiDefinedAny) != 0)
            {
                // If "y" was modified through the API as well - the modified setting must be the same ( i.e. allowOvverride or overrideMode must be modified in both settings )
                result = (x._mode & ApiDefinedAny) == (y._mode & ApiDefinedAny);
            }
            else
            {
                // "y" was not API modified  - they are still a match if "y" was a XML setting from the same mode
                if ((y._mode & XmlDefinedAny) != 0)
                {
                    // "x" was API changed in Legacy and "y" was XML defined in Legacy
                    result = (((x._mode & ApiDefinedLegacy) != 0) && ((y._mode & XmlDefinedLegacy) != 0)) ||
                             // "x" was API changed in New and "y" was XML defined in New
                             (((x._mode & ApiDefinedNewMode) != 0) && ((y._mode & XmlDefinedNewMode) != 0));
                }
                // "y" was not API or XML modified - since "x" was API modified - they are not a match ( i.e. "y" should go to an <location> with no explicit mode written out )
            }

            return(result);
        }
 internal static OverrideModeSetting CreateFromXmlReadValue(bool allowOverride)
 {
     OverrideModeSetting setting = new OverrideModeSetting();
     setting.SetMode(allowOverride ? System.Configuration.OverrideMode.Inherit : System.Configuration.OverrideMode.Deny);
     setting._mode = (byte) (setting._mode | 0x40);
     return setting;
 }
        internal static OverrideModeSetting CreateFromXmlReadValue(System.Configuration.OverrideMode mode)
        {
            OverrideModeSetting setting = new OverrideModeSetting();

            setting.SetMode(mode);
            setting._mode = (byte)(setting._mode | 0x80);
            return(setting);
        }
        internal static OverrideModeSetting CreateFromXmlReadValue(bool allowOverride)
        {
            OverrideModeSetting setting = new OverrideModeSetting();

            setting.SetMode(allowOverride ? System.Configuration.OverrideMode.Inherit : System.Configuration.OverrideMode.Deny);
            setting._mode = (byte)(setting._mode | 0x40);
            return(setting);
        }
Esempio n. 11
0
        static OverrideModeSetting()
        {
            // Default for section is ALLOW
            s_sectionDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Allow };

            // Default for location tags is INHERIT. Note that we do not make the value as existant in the XML or specified by the API
            s_locationDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Inherit };
        }
Esempio n. 12
0
        internal void SetRuntimeConfigurationInformation(BaseConfigurationRecord configRecord,
                                                         FactoryRecord factoryRecord, SectionRecord sectionRecord)
        {
            _flags[FlagAttached] = true;

            // factory info
            ConfigKey                            = factoryRecord.ConfigKey;
            Name                                 = factoryRecord.Name;
            _typeName                            = factoryRecord.FactoryTypeName;
            _allowDefinition                     = factoryRecord.AllowDefinition;
            _allowExeDefinition                  = factoryRecord.AllowExeDefinition;
            _flags[FlagAllowLocation]            = factoryRecord.AllowLocation;
            _flags[FlagRestartOnExternalChanges] = factoryRecord.RestartOnExternalChanges;
            _flags[FlagRequirePermission]        = factoryRecord.RequirePermission;
            _overrideModeDefault                 = factoryRecord.OverrideModeDefault;

            if (factoryRecord.IsUndeclared)
            {
                _flags[FlagIsUndeclared]        = true;
                _flags[FlagDeclared]            = false;
                _flags[FlagDeclarationRequired] = false;
            }
            else
            {
                _flags[FlagIsUndeclared]        = false;
                _flags[FlagDeclared]            = configRecord.GetFactoryRecord(factoryRecord.ConfigKey, false) != null;
                _flags[FlagDeclarationRequired] = configRecord.IsRootDeclaration(factoryRecord.ConfigKey, false);
            }

            // section info
            _flags[FlagLocationLocked] = sectionRecord.Locked;
            _flags[FlagChildrenLocked] = sectionRecord.LockChildren;
            _flags[FlagChildrenLockWithoutFileInput] = sectionRecord.LockChildrenWithoutFileInput;

            if (sectionRecord.HasFileInput)
            {
                SectionInput fileInput = sectionRecord.FileInput;

                _flags[FlagProtectionProviderDetermined] = fileInput.IsProtectionProviderDetermined;
                _protectionProvider = fileInput.ProtectionProvider;

                SectionXmlInfo sectionXmlInfo = fileInput.SectionXmlInfo;

                _configSource                  = sectionXmlInfo.ConfigSource;
                ConfigSourceStreamName         = sectionXmlInfo.ConfigSourceStreamName;
                _overrideMode                  = sectionXmlInfo.OverrideModeSetting;
                _flags[FlagInheritInChildApps] = !sectionXmlInfo.SkipInChildApps;
                ProtectionProviderName         = sectionXmlInfo.ProtectionProviderName;
            }
            else
            {
                _flags[FlagProtectionProviderDetermined] = false;
                _protectionProvider = null;
            }

            // element context information
            _configurationSection.AssociateContext(configRecord);
        }
Esempio n. 13
0
        internal static OverrideModeSetting CreateFromXmlReadValue(OverrideMode mode)
        {
            OverrideModeSetting result = new OverrideModeSetting();

            result.SetMode(mode);
            result._mode |= XmlDefinedNewMode;

            return(result);
        }
Esempio n. 14
0
        // Find the location update with a certain set of location attributes.
        internal LocationUpdates FindLocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps)
        {
            foreach (LocationUpdates locationUpdates in LocationUpdatesList)
                if (OverrideModeSetting.CanUseSameLocationTag(locationUpdates.OverrideMode, overrideMode) &&
                    (locationUpdates.InheritInChildApps == inheritInChildApps))
                    return locationUpdates;

            return null;
        }
Esempio n. 15
0
        internal static OverrideModeSetting CreateFromXmlReadValue(OverrideMode mode)
        {
            OverrideModeSetting result = new OverrideModeSetting();

            result.SetMode(mode);
            result._mode |= XmlDefinedNewMode;

            return result;
        }
        static OverrideModeSetting()
        {
            SectionDefault = new OverrideModeSetting();
            // Default for section is ALLOW ( to be consistent with Whidbey )
            SectionDefault._mode = (byte)OverrideMode.Allow;

            LocationDefault = new OverrideModeSetting();
            // Default for location tags is INHERIT. Note that we do not make the value as existant in the XML or specified by the API
            LocationDefault._mode = (byte)OverrideMode.Inherit;
        }
 internal LocationUpdates FindLocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps)
 {
     foreach (LocationUpdates updates in this._locationUpdatesList)
     {
         if (OverrideModeSetting.CanUseSameLocationTag(updates.OverrideMode, overrideMode) && (updates.InheritInChildApps == inheritInChildApps))
         {
             return updates;
         }
     }
     return null;
 }
        //
        // Add a section definition update to the correct location update.
        //
        internal DefinitionUpdate AddUpdate(OverrideModeSetting overrideMode, bool inheritInChildApps, bool moved, string updatedXml, SectionRecord sectionRecord) {
            LocationUpdates locationUpdates = FindLocationUpdates(overrideMode, inheritInChildApps);
            if (locationUpdates == null) {
                locationUpdates = new LocationUpdates(overrideMode, inheritInChildApps);
                _locationUpdatesList.Add(locationUpdates);
            }

            DefinitionUpdate definitionUpdate = new DefinitionUpdate(sectionRecord.ConfigKey, moved, updatedXml, sectionRecord);
            locationUpdates.SectionUpdates.AddSection(definitionUpdate);
            return definitionUpdate;
        }
Esempio n. 19
0
        static OverrideModeSetting()
        {
            SectionDefault = new OverrideModeSetting();
            // Default for section is ALLOW ( to be consistent with Whidbey )
            SectionDefault._mode = (byte)OverrideMode.Allow;


            LocationDefault = new OverrideModeSetting();
            // Default for location tags is INHERIT. Note that we do not make the value as existant in the XML or specified by the API
            LocationDefault._mode = (byte)OverrideMode.Inherit;
        }
Esempio n. 20
0
 internal LocationUpdates FindLocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps)
 {
     foreach (LocationUpdates updates in this._locationUpdatesList)
     {
         if (OverrideModeSetting.CanUseSameLocationTag(updates.OverrideMode, overrideMode) && (updates.InheritInChildApps == inheritInChildApps))
         {
             return(updates);
         }
     }
     return(null);
 }
Esempio n. 21
0
        static OverrideModeSetting()
        {
            // Default for section is ALLOW
            s_sectionDefault = new OverrideModeSetting {
                _mode = (byte)OverrideMode.Allow
            };

            // Default for location tags is INHERIT. Note that we do not make the value as existent in the XML or specified by the API
            s_locationDefault = new OverrideModeSetting {
                _mode = (byte)OverrideMode.Inherit
            };
        }
Esempio n. 22
0
        static internal OverrideModeSetting CreateFromXmlReadValue(bool allowOverride) {
            // Create a mode from the old "allowOverride" attribute in the xml

            // The conversion is true -> OverrideMode.Inherit
            // The conversion is false -> OverrideMode.Deny
            // This is consistent with Whidbey where true means true unless there is a false somewhere above
            OverrideModeSetting result = new OverrideModeSetting();

            result.SetMode(allowOverride ? OverrideMode.Inherit : OverrideMode.Deny);
            result._mode |= XmlDefinedLegacy;

            return result;
        }
 private static bool IsMatchingApiChangedLocationTag(OverrideModeSetting x, OverrideModeSetting y)
 {
     bool flag = false;
     if ((y._mode & 0x30) != 0)
     {
         return ((x._mode & 0x30) == (y._mode & 0x30));
     }
     if ((y._mode & 0xc0) != 0)
     {
         flag = (((x._mode & 0x10) != 0) && ((y._mode & 0x40) != 0)) || (((x._mode & 0x20) != 0) && ((y._mode & 0x80) != 0));
     }
     return flag;
 }
Esempio n. 24
0
        internal static bool CanUseSameLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            // This function tells if the two OverrideModeSettings are compatible enough to be used in only one location tag
            // or each of them should go to a separate one

            // The rules here are ( in order of importance )
            // 1. The effective mode is the same ( we will use only the new OverrideMode to compare )
            // 2. When the mode was changed( i.e. API change ) - both must be changed the same way ( i.e. using either allowOverride or OverrideMode )
            // 3. When mode was not changed the XML - they must've been the same in the xml ( i.e. allowOverride specified on both, or overrideMode or neither of them )

            bool result = false;

            result = (x.OverrideMode == y.OverrideMode);

            if (result == true)
            {
                result = false;

                // Check for an API change for each setting first
                // If one mode was set through the API - the other mode has to be set in the same way through the API or has to be using the same type in the xml

                // Handle case where "x" was API modified
                if ((x._mode & ApiDefinedAny) != 0)
                {
                    result = IsMatchingApiChangedLocationTag(x, y);
                }
                // Handle case where "y" was API modified
                else if ((y._mode & ApiDefinedAny) != 0)
                {
                    result = IsMatchingApiChangedLocationTag(y, x);
                }
                // Handle case where neither "x" nor "y" was API modified
                else
                {
                    // If one of the settings was XML defined - they are a match only if both were XML defined in the same way
                    if (((x._mode & XmlDefinedAny) != 0) ||
                        ((y._mode & XmlDefinedAny) != 0))
                    {
                        result = (x._mode & XmlDefinedAny) == (y._mode & XmlDefinedAny);
                    }
                    // Neither "x" nor "y" was XML defined - they are a match since they can both go
                    // to a default <location> with no explicit mode setting written out
                    else
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Esempio n. 25
0
        internal DefinitionUpdate AddUpdate(OverrideModeSetting overrideMode, bool inheritInChildApps, bool moved, string updatedXml, SectionRecord sectionRecord)
        {
            LocationUpdates updates = this.FindLocationUpdates(overrideMode, inheritInChildApps);

            if (updates == null)
            {
                updates = new LocationUpdates(overrideMode, inheritInChildApps);
                this._locationUpdatesList.Add(updates);
            }
            DefinitionUpdate update = new DefinitionUpdate(sectionRecord.ConfigKey, moved, updatedXml, sectionRecord);

            updates.SectionUpdates.AddSection(update);
            return(update);
        }
        private static bool IsMatchingApiChangedLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            bool flag = false;

            if ((y._mode & 0x30) != 0)
            {
                return((x._mode & 0x30) == (y._mode & 0x30));
            }
            if ((y._mode & 0xc0) != 0)
            {
                flag = (((x._mode & 0x10) != 0) && ((y._mode & 0x40) != 0)) || (((x._mode & 0x20) != 0) && ((y._mode & 0x80) != 0));
            }
            return(flag);
        }
Esempio n. 27
0
        internal static OverrideModeSetting CreateFromXmlReadValue(bool allowOverride)
        {
            // Create a mode from the old "allowOverride" attribute in the xml

            // The conversion is true -> OverrideMode.Inherit
            // The conversion is false -> OverrideMode.Deny
            // This is consistent with Whidbey where true means true unless there is a false somewhere above
            OverrideModeSetting result = new OverrideModeSetting();

            result.SetMode(allowOverride ? OverrideMode.Inherit : OverrideMode.Deny);
            result._mode |= XmlDefinedLegacy;

            return(result);
        }
Esempio n. 28
0
        internal SectionInformation(ConfigurationSection associatedConfigurationSection)
        {
            ConfigKey = string.Empty;
            Name      = string.Empty;

            _configurationSection = associatedConfigurationSection;
            _allowDefinition      = ConfigurationAllowDefinition.Everywhere;
            _allowExeDefinition   = ConfigurationAllowExeDefinition.MachineToApplication;
            _overrideModeDefault  = OverrideModeSetting.s_sectionDefault;
            _overrideMode         = OverrideModeSetting.s_locationDefault;

            _flags[FlagAllowLocation]            = true;
            _flags[FlagRestartOnExternalChanges] = true;
            _flags[FlagRequirePermission]        = true;
            _flags[FlagInheritInChildApps]       = true;
            _flags[FlagForceSave] = false;

            _modifiedFlags = new SimpleBitVector32();
        }
        private OverrideModeSetting             _overrideMode;              // The override mode at the current config path

        //
        // Constructor
        //
        internal SectionInformation(ConfigurationSection associatedConfigurationSection) {
            _configKey = String.Empty;
            _group = String.Empty;
            _name = String.Empty;

            _configurationSection   = associatedConfigurationSection;
            _allowDefinition        = ConfigurationAllowDefinition.Everywhere;
            _allowExeDefinition     = ConfigurationAllowExeDefinition.MachineToApplication;
            _overrideModeDefault    = OverrideModeSetting.SectionDefault;
            _overrideMode           = OverrideModeSetting.LocationDefault;

            _flags[ Flag_AllowLocation            ] = true;
            _flags[ Flag_RestartOnExternalChanges ] = true;
            _flags[ Flag_RequirePermission        ] = true;
            _flags[ Flag_InheritInChildApps       ] = true;
            _flags[ Flag_ForceSave                ] = false;

            _modifiedFlags = new SimpleBitVector32();
        }
Esempio n. 30
0
        // the config path of the configuration record where this directive was defined

        internal SectionXmlInfo(
            string configKey, string definitionConfigPath, string targetConfigPath, string subPath,
            string filename, int lineNumber, object streamVersion,
            string rawXml, string configSource, string configSourceStreamName, object configSourceStreamVersion,
            string protectionProviderName, OverrideModeSetting overrideMode, bool skipInChildApps)
        {
            ConfigKey = configKey;
            DefinitionConfigPath = definitionConfigPath;
            TargetConfigPath = targetConfigPath;
            SubPath = subPath;
            Filename = filename;
            LineNumber = lineNumber;
            StreamVersion = streamVersion;
            RawXml = rawXml;
            ConfigSource = configSource;
            ConfigSourceStreamName = configSourceStreamName;
            ProtectionProviderName = protectionProviderName;
            OverrideModeSetting = overrideMode;
            SkipInChildApps = skipInChildApps;
        }
Esempio n. 31
0
        // the config path of the configuration record where this directive was defined

        internal SectionXmlInfo(
            string configKey, string definitionConfigPath, string targetConfigPath, string subPath,
            string filename, int lineNumber, object streamVersion,
            string rawXml, string configSource, string configSourceStreamName, object configSourceStreamVersion,
            string protectionProviderName, OverrideModeSetting overrideMode, bool skipInChildApps)
        {
            ConfigKey            = configKey;
            DefinitionConfigPath = definitionConfigPath;
            TargetConfigPath     = targetConfigPath;
            SubPath                = subPath;
            Filename               = filename;
            LineNumber             = lineNumber;
            StreamVersion          = streamVersion;
            RawXml                 = rawXml;
            ConfigSource           = configSource;
            ConfigSourceStreamName = configSourceStreamName;
            ProtectionProviderName = protectionProviderName;
            OverrideModeSetting    = overrideMode;
            SkipInChildApps        = skipInChildApps;
        }
        private OverrideModeSetting _overrideMode;  // override mode for child config paths

        internal SectionXmlInfo(
            string configKey, string definitionConfigPath, string targetConfigPath, string subPath,
            string filename, int lineNumber, object streamVersion,
            string rawXml, string configSource, string configSourceStreamName, object configSourceStreamVersion,
            string protectionProviderName, OverrideModeSetting overrideMode, bool skipInChildApps)
        {
            _configKey            = configKey;
            _definitionConfigPath = definitionConfigPath;
            _targetConfigPath     = targetConfigPath;
            _subPath                   = subPath;
            _filename                  = filename;
            _lineNumber                = lineNumber;
            _streamVersion             = streamVersion;
            _rawXml                    = rawXml;
            _configSource              = configSource;
            _configSourceStreamName    = configSourceStreamName;
            _configSourceStreamVersion = configSourceStreamVersion;
            _protectionProviderName    = protectionProviderName;
            _overrideMode              = overrideMode;
            _skipInChildApps           = skipInChildApps;
        }
        private OverrideModeSetting _overrideMode;  // override mode for child config paths

        internal SectionXmlInfo(
                string configKey, string definitionConfigPath, string targetConfigPath, string subPath,
                string filename, int lineNumber, object streamVersion, 
                string rawXml, string configSource, string configSourceStreamName, object configSourceStreamVersion,
                string protectionProviderName, OverrideModeSetting overrideMode, bool skipInChildApps) {

            _configKey = configKey;
            _definitionConfigPath = definitionConfigPath;
            _targetConfigPath = targetConfigPath;
            _subPath = subPath;
            _filename = filename;
            _lineNumber = lineNumber;
            _streamVersion  = streamVersion;
            _rawXml = rawXml;
            _configSource = configSource;
            _configSourceStreamName = configSourceStreamName;
            _configSourceStreamVersion = configSourceStreamVersion;
            _protectionProviderName = protectionProviderName;
            _overrideMode = overrideMode;
            _skipInChildApps = skipInChildApps;
        }
 internal static bool CanUseSameLocationTag(OverrideModeSetting x, OverrideModeSetting y)
 {
     bool flag = false;
     flag = x.OverrideMode == y.OverrideMode;
     if (!flag)
     {
         return flag;
     }
     flag = false;
     if ((x._mode & 0x30) != 0)
     {
         return IsMatchingApiChangedLocationTag(x, y);
     }
     if ((y._mode & 0x30) != 0)
     {
         return IsMatchingApiChangedLocationTag(y, x);
     }
     if (((x._mode & 0xc0) != 0) || ((y._mode & 0xc0) != 0))
     {
         return ((x._mode & 0xc0) == (y._mode & 0xc0));
     }
     return true;
 }
        internal static bool CanUseSameLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            bool flag = false;

            flag = x.OverrideMode == y.OverrideMode;
            if (!flag)
            {
                return(flag);
            }
            flag = false;
            if ((x._mode & 0x30) != 0)
            {
                return(IsMatchingApiChangedLocationTag(x, y));
            }
            if ((y._mode & 0x30) != 0)
            {
                return(IsMatchingApiChangedLocationTag(y, x));
            }
            if (((x._mode & 0xc0) != 0) || ((y._mode & 0xc0) != 0))
            {
                return((x._mode & 0xc0) == (y._mode & 0xc0));
            }
            return(true);
        }
Esempio n. 36
0
        private static bool IsMatchingApiChangedLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            // x must be a changed through the API setting
            // Returns true if x and y can share the same location tag

            Debug.Assert((x._mode & ApiDefinedAny) != 0);

            bool result = false;

            if ((y._mode & ApiDefinedAny) != 0)
            {
                // If "y" was modified through the API as well - the modified setting must be the same ( i.e. allowOvverride or overrideMode must be modified in both settings )
                result = (x._mode & ApiDefinedAny) == (y._mode & ApiDefinedAny);
            }
            else
            {
                // "y" was not API modified  - they are still a match if "y" was a XML setting from the same mode
                if ((y._mode & XmlDefinedAny) != 0)
                {
                    // "x" was API changed in Legacy and "y" was XML defined in Legacy
                    result = (((x._mode & ApiDefinedLegacy) != 0) && ((y._mode & XmlDefinedLegacy) != 0)) ||
                    // "x" was API changed in New and "y" was XML defined in New
                        (((x._mode & ApiDefinedNewMode) != 0) && ((y._mode & XmlDefinedNewMode) != 0));
                }
                // "y" was not API or XML modified - since "x" was API modified - they are not a match ( i.e. "y" should go to an <location> with no explicit mode written out )
            }

            return result;
        }
Esempio n. 37
0
 internal LocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps)
 {
     this._overrideMode       = overrideMode;
     this._inheritInChildApps = inheritInChildApps;
     this._sectionUpdates     = new System.Configuration.SectionUpdates(string.Empty);
 }
 internal LocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps)
 {
     this._overrideMode = overrideMode;
     this._inheritInChildApps = inheritInChildApps;
     this._sectionUpdates = new System.Configuration.SectionUpdates(string.Empty);
 }
        internal void SetRuntimeConfigurationInformation(BaseConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord)
        {
            _flags[ Flag_Attached ] = true;

            // factory info
            _configKey          = factoryRecord.ConfigKey;
            _group              = factoryRecord.Group;
            _name               = factoryRecord.Name;
            _typeName           = factoryRecord.FactoryTypeName;
            _allowDefinition    = factoryRecord.AllowDefinition;
            _allowExeDefinition = factoryRecord.AllowExeDefinition;
            _flags[ Flag_AllowLocation            ] = factoryRecord.AllowLocation;
            _flags[ Flag_RestartOnExternalChanges ] = factoryRecord.RestartOnExternalChanges;
            _flags[ Flag_RequirePermission        ] = factoryRecord.RequirePermission;
            _overrideModeDefault                    = factoryRecord.OverrideModeDefault;

            if (factoryRecord.IsUndeclared) {
                _flags[ Flag_IsUndeclared             ] = true;
                _flags[ Flag_Declared                 ] = false;
                _flags[ Flag_DeclarationRequired      ] = false;
            }
            else {
                _flags[ Flag_IsUndeclared             ] = false;
                _flags[ Flag_Declared                 ] = configRecord.GetFactoryRecord(factoryRecord.ConfigKey, false) != null;
                _flags[ Flag_DeclarationRequired      ] = configRecord.IsRootDeclaration(factoryRecord.ConfigKey, false);
            }

            // section info
            _flags[ Flag_LocationLocked ]               = sectionRecord.Locked;
            _flags[ Flag_ChildrenLocked ]               = sectionRecord.LockChildren;
            _flags[ Flag_ChildrenLockWithoutFileInput]  = sectionRecord.LockChildrenWithoutFileInput;

            if (sectionRecord.HasFileInput) {
                SectionInput fileInput = sectionRecord.FileInput;

                _flags[ Flag_ProtectionProviderDetermined ] = fileInput.IsProtectionProviderDetermined;
                _protectionProvider                         = fileInput.ProtectionProvider;

                SectionXmlInfo sectionXmlInfo = fileInput.SectionXmlInfo;

                _configSource                       = sectionXmlInfo.ConfigSource;
                _configSourceStreamName             = sectionXmlInfo.ConfigSourceStreamName;
                _overrideMode                       = sectionXmlInfo.OverrideModeSetting;
                _flags[ Flag_InheritInChildApps ]   = !sectionXmlInfo.SkipInChildApps;
                _protectionProviderName             = sectionXmlInfo.ProtectionProviderName;
            }
            else {
                _flags[ Flag_ProtectionProviderDetermined ] = false;
                _protectionProvider = null;
            }

            // element context information
            _configurationSection.AssociateContext( configRecord );
        }
Esempio n. 40
0
        internal static bool CanUseSameLocationTag(OverrideModeSetting x, OverrideModeSetting y)
        {
            // This function tells if the two OverrideModeSettings are compatible enough to be used in only one location tag
            // or each of them should go to a separate one

            // The rules here are ( in order of importance )
            // 1. The effective mode is the same ( we will use only the new OverrideMode to compare )
            // 2. When the mode was changed( i.e. API change ) - both must be changed the same way ( i.e. using either allowOverride or OverrideMode )
            // 3. When mode was not changed the XML - they must've been the same in the xml ( i.e. allowOverride specified on both, or overrideMode or neither of them )

            bool result = x.OverrideMode == y.OverrideMode;
            if (!result) return false;

            // Check for an API change for each setting first
            // If one mode was set through the API - the other mode has to be set in the same way through the API or has to be using the same type in the xml

            // Handle case where "x" was API modified
            if ((x._mode & ApiDefinedAny) != 0) result = IsMatchingApiChangedLocationTag(x, y);
            // Handle case where "y" was API modified
            else
            {
                if ((y._mode & ApiDefinedAny) != 0) result = IsMatchingApiChangedLocationTag(y, x);
                // Handle case where neither "x" nor "y" was API modified
                else
                {
                    // If one of the settings was XML defined - they are a match only if both were XML defined in the same way
                    if (((x._mode & XmlDefinedAny) != 0) ||
                        ((y._mode & XmlDefinedAny) != 0))
                        result = (x._mode & XmlDefinedAny) == (y._mode & XmlDefinedAny);

                    // Neither "x" nor "y" was XML defined - they are a match since they can both go 
                    // to a default <location> with no explicit mode setting written out
                }
            }

            return result;
        }