public static OptionRestrictionRegexUnmarshaller GetInstance()
        {
            if (instance == null)
            {
                instance = new OptionRestrictionRegexUnmarshaller();
            }

            return(instance);
        }
        public ConfigurationOptionDescription Unmarshall(UnmarshallerContext context)
        {
            ConfigurationOptionDescription configurationOptionDescription = new ConfigurationOptionDescription();
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Namespace", targetDepth))
                    {
                        configurationOptionDescription.Namespace = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Name", targetDepth))
                    {
                        configurationOptionDescription.Name = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("DefaultValue", targetDepth))
                    {
                        configurationOptionDescription.DefaultValue = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("ChangeSeverity", targetDepth))
                    {
                        configurationOptionDescription.ChangeSeverity = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("UserDefined", targetDepth))
                    {
                        configurationOptionDescription.UserDefined = BoolUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("ValueType", targetDepth))
                    {
                        configurationOptionDescription.ValueType = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("ValueOptions/member", targetDepth))
                    {
                        configurationOptionDescription.ValueOptions.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("MinValue", targetDepth))
                    {
                        configurationOptionDescription.MinValue = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("MaxValue", targetDepth))
                    {
                        configurationOptionDescription.MaxValue = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("MaxLength", targetDepth))
                    {
                        configurationOptionDescription.MaxLength = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Regex", targetDepth))
                    {
                        configurationOptionDescription.Regex = OptionRestrictionRegexUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return(configurationOptionDescription);
                }
            }

            return(configurationOptionDescription);
        }