コード例 #1
0
        // Token: 0x06000690 RID: 1680 RVA: 0x00014744 File Offset: 0x00012944
        private void Seal()
        {
            if (this._type == null && this._text == null)
            {
                throw new InvalidOperationException(SR.Get("NullTypeIllegal"));
            }
            if (this._firstChild != null && !typeof(IAddChild).IsAssignableFrom(this._type))
            {
                throw new InvalidOperationException(SR.Get("TypeMustImplementIAddChild", new object[]
                {
                    this._type.Name
                }));
            }
            this.ApplyAutoAliasRules();
            if (this._childName != null && this._childName != string.Empty)
            {
                if (!this.IsChildNameValid(this._childName))
                {
                    throw new InvalidOperationException(SR.Get("ChildNameNamePatternReserved", new object[]
                    {
                        this._childName
                    }));
                }
                this._childName = string.Intern(this._childName);
            }
            else
            {
                this._childName = this.GenerateChildName();
            }
            object synchronized = this._synchronized;

            lock (synchronized)
            {
                for (int i = 0; i < this.PropertyValues.Count; i++)
                {
                    PropertyValue propertyValue = this.PropertyValues[i];
                    propertyValue.ChildName = this._childName;
                    StyleHelper.SealIfSealable(propertyValue.ValueInternal);
                    this.PropertyValues[i] = propertyValue;
                }
            }
            this._sealed = true;
            if (this._childName != null && this._childName != string.Empty && this._frameworkTemplate != null)
            {
                this._childIndex = StyleHelper.CreateChildIndexFromChildName(this._childName, this._frameworkTemplate);
            }
            for (FrameworkElementFactory frameworkElementFactory = this._firstChild; frameworkElementFactory != null; frameworkElementFactory = frameworkElementFactory._nextSibling)
            {
                if (this._frameworkTemplate != null)
                {
                    frameworkElementFactory.Seal(this._frameworkTemplate);
                }
            }
        }