internal SessionStateCapacityVariable(string name, int defaultCapacity, int maxCapacity, int minCapacity, ScopedItemOptions options) : base(name, defaultCapacity, options) { this.maxCapacity = 0x7fffffff; ValidateRangeAttribute item = new ValidateRangeAttribute(minCapacity, maxCapacity); this.minCapacity = minCapacity; this.maxCapacity = maxCapacity; base.Attributes.Add(item); this._fastValue = defaultCapacity; }
public SessionStateCapacityVariable(string name, SessionStateCapacityVariable sharedCapacityVariable, ScopedItemOptions options) : base(name, sharedCapacityVariable.Value, options) { this.maxCapacity = 0x7fffffff; ValidateRangeAttribute item = new ValidateRangeAttribute(0, 0x7fffffff); base.Attributes.Add(item); this.sharedCapacityVariable = sharedCapacityVariable; this.Description = sharedCapacityVariable.Description; this._fastValue = (int) sharedCapacityVariable.Value; }
public SessionStateCapacityVariable(string name, SessionStateCapacityVariable sharedCapacityVariable, ScopedItemOptions options) : base(name, sharedCapacityVariable.Value, options) { this.maxCapacity = 0x7fffffff; ValidateRangeAttribute item = new ValidateRangeAttribute(0, 0x7fffffff); base.Attributes.Add(item); this.sharedCapacityVariable = sharedCapacityVariable; this.Description = sharedCapacityVariable.Description; this._fastValue = (int)sharedCapacityVariable.Value; }
internal SessionStateCapacityVariable( string name, int defaultCapacity, int maxCapacity, int minCapacity, ScopedItemOptions options) : base(name, (object)defaultCapacity, options) { ValidateRangeAttribute validateRangeAttribute = new ValidateRangeAttribute((object)minCapacity, (object)maxCapacity); this.minCapacity = minCapacity; this.maxCapacity = maxCapacity; this.Attributes.Add((Attribute)validateRangeAttribute); this._fastValue = defaultCapacity; }
/// <summary> /// Constructs an instance of the variable with the specified name and /// initial capacity. /// </summary> /// /// <param name="name"> /// The name of the variable. /// </param> /// /// <param name="defaultCapacity"> /// The initial capacity /// </param> /// /// <param name="maxCapacity"> /// The maximum capacity for the scope. /// </param> /// /// <param name="minCapacity"> /// The minimum capacity for the scope. /// </param> /// /// <param name="options">Scoped item options for this variable</param> internal SessionStateCapacityVariable( string name, int defaultCapacity, int maxCapacity, int minCapacity, ScopedItemOptions options) : base(name, defaultCapacity, options) { // Now add a range constraint to the variable so that // it is discoverable... ValidateRangeAttribute validateRange = new ValidateRangeAttribute(minCapacity, maxCapacity); _minCapacity = minCapacity; _maxCapacity = maxCapacity; base.Attributes.Add(validateRange); _fastValue = defaultCapacity; }
public SessionStateCapacityVariable( string name, SessionStateCapacityVariable sharedCapacityVariable, ScopedItemOptions options) : base(name, sharedCapacityVariable.Value, options) { // Now add range constraints to the variable. ValidateRangeAttribute validateRange = new ValidateRangeAttribute(0, int.MaxValue); base.Attributes.Add(validateRange); _sharedCapacityVariable = sharedCapacityVariable; // Also propagate the description to prevent re-fetching them from the // resource manager. That causes a measurable performance degradation. this.Description = sharedCapacityVariable.Description; // Initialize the fast value... _fastValue = (int)sharedCapacityVariable.Value; }
private string GetProxyAttributeData(Attribute attrib, string prefix) { ValidateLengthAttribute attribute = attrib as ValidateLengthAttribute; if (attribute != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateLength({1}, {2})]", new object[] { prefix, attribute.MinLength, attribute.MaxLength })); } ValidateRangeAttribute attribute2 = attrib as ValidateRangeAttribute; if (attribute2 != null) { string str2; Type type = attribute2.MinRange.GetType(); if ((type == typeof(float)) || (type == typeof(double))) { str2 = "{0}[ValidateRange({1:R}, {2:R})]"; } else { str2 = "{0}[ValidateRange({1}, {2})]"; } return(string.Format(CultureInfo.InvariantCulture, str2, new object[] { prefix, attribute2.MinRange, attribute2.MaxRange })); } if (attrib is AllowNullAttribute) { return(string.Format(CultureInfo.InvariantCulture, "{0}[AllowNull()]", new object[] { prefix })); } if (attrib is AllowEmptyStringAttribute) { return(string.Format(CultureInfo.InvariantCulture, "{0}[AllowEmptyString()]", new object[] { prefix })); } if (attrib is AllowEmptyCollectionAttribute) { return(string.Format(CultureInfo.InvariantCulture, "{0}[AllowEmptyCollection()]", new object[] { prefix })); } ValidatePatternAttribute attribute6 = attrib as ValidatePatternAttribute; if (attribute6 != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidatePattern('{1}')]", new object[] { prefix, CommandMetadata.EscapeSingleQuotedString(attribute6.RegexPattern) })); } ValidateCountAttribute attribute7 = attrib as ValidateCountAttribute; if (attribute7 != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateCount({1}, {2})]", new object[] { prefix, attribute7.MinLength, attribute7.MaxLength })); } if (attrib is ValidateNotNullAttribute) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateNotNull()]", new object[] { prefix })); } if (attrib is ValidateNotNullOrEmptyAttribute) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateNotNullOrEmpty()]", new object[] { prefix })); } ValidateSetAttribute attribute10 = attrib as ValidateSetAttribute; if (attribute10 != null) { StringBuilder builder = new StringBuilder(); string str3 = ""; foreach (string str4 in attribute10.ValidValues) { builder.AppendFormat(CultureInfo.InvariantCulture, "{0}'{1}'", new object[] { str3, CommandMetadata.EscapeSingleQuotedString(str4) }); str3 = ","; } return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateSet({1})]", new object[] { prefix, builder.ToString() })); } ValidateScriptAttribute attribute11 = attrib as ValidateScriptAttribute; if (attribute11 != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}[ValidateScript({{ {1} }})]", new object[] { prefix, attribute11.ScriptBlock.ToString() })); } PSTypeNameAttribute attribute12 = attrib as PSTypeNameAttribute; if (attribute12 != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}[PSTypeName('{1}')]", new object[] { prefix, CommandMetadata.EscapeSingleQuotedString(attribute12.PSTypeName) })); } return(null); }