private StoreFieldType(PhysicalStoreFieldType storeType, int precision, int scale) { switch (storeType) { case PhysicalStoreFieldType.Decimal: if (precision < 1) { throw new ArgumentException("Precision must be 1 or greater"); } if (precision > NumericPrecisionMaximum) { throw new ArgumentException("Precision may not be greater than " + NumericPrecisionMaximum.ToString()); } if (scale < 0) { throw new ArgumentException("Scale must be 0 or greater"); } if (scale > precision) { throw new ArgumentException("Scale can not be larger than precision"); } this.PhysicalStoreType = storeType; this.NumericPrecision = precision; this.NumericScale = scale; return; } throw new ArgumentException("Specified PhysicalStoreType is not associated with a presision and scale"); }
/// <summary> /// Specifies what physical store type should be used to store this property. /// This overload is intended for int, long, large string, date time, guid and bool. /// For decimal and string, use other overload where you can specify length values also. /// </summary> /// <param name="physicalStoreFieldType">PhysicalStoreFieldType to use</param> public StoreFieldTypeAttribute(PhysicalStoreFieldType physicalStoreFieldType) : this() { switch (physicalStoreFieldType) { case PhysicalStoreFieldType.Integer: this.StoreFieldType = StoreFieldType.Integer; return; case PhysicalStoreFieldType.Long: this.StoreFieldType = StoreFieldType.Long; return; case PhysicalStoreFieldType.LargeString: this.StoreFieldType = StoreFieldType.LargeString; return; case PhysicalStoreFieldType.DateTime: this.StoreFieldType = StoreFieldType.DateTime; return; case PhysicalStoreFieldType.Guid: this.StoreFieldType = StoreFieldType.Guid; return; case PhysicalStoreFieldType.Boolean: this.StoreFieldType = StoreFieldType.Boolean; return; } throw new ArgumentException(string.Format("[{0}] - field type {1}.{2} require some aditional arguments in the attribute constructor.", this.GetType().Name, typeof(PhysicalStoreFieldType).Name, physicalStoreFieldType)); }
private StoreFieldType(PhysicalStoreFieldType storeType) { this.PhysicalStoreType = storeType; if (storeType == PhysicalStoreFieldType.LargeString) { this.MaximumLength = int.MaxValue; } }
/// <exclude /> public static StoreFieldType Deserialize(string serializedData) { using (TimerProfiler timerProfiler = TimerProfilerFacade.CreateTimerProfiler()) { if (string.IsNullOrEmpty(serializedData)) { throw new ArgumentNullException("serializedData"); } Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); if (dic.ContainsKey("PhysicalStoreType") == false) { throw new ArgumentException("Wrong serialized format"); } string physicalStoreFieldTypeString = StringConversionServices.DeserializeValue <string>(dic["PhysicalStoreType"]); PhysicalStoreFieldType physicalStoreFieldType = (PhysicalStoreFieldType)Enum.Parse(typeof(PhysicalStoreFieldType), physicalStoreFieldTypeString); switch (physicalStoreFieldType) { case PhysicalStoreFieldType.String: if (dic.ContainsKey("Length") == false) { throw new ArgumentException("Wrong serialized format"); } int length = StringConversionServices.DeserializeValueInt(dic["Length"]); return(new StoreFieldType(physicalStoreFieldType, length)); case PhysicalStoreFieldType.Decimal: if (dic.ContainsKey("Precision") == false) { throw new ArgumentException("Wrong serialized format"); } if (dic.ContainsKey("Scale") == false) { throw new ArgumentException("Wrong serialized format"); } int precision = StringConversionServices.DeserializeValueInt(dic["Precision"]); int scale = StringConversionServices.DeserializeValueInt(dic["Scale"]); return(new StoreFieldType(physicalStoreFieldType, precision, scale)); case PhysicalStoreFieldType.Boolean: case PhysicalStoreFieldType.DateTime: case PhysicalStoreFieldType.Guid: case PhysicalStoreFieldType.Integer: case PhysicalStoreFieldType.LargeString: case PhysicalStoreFieldType.Long: return(new StoreFieldType(physicalStoreFieldType)); } throw new NotImplementedException(); } }
/// <summary> /// Specifies what physical store type should be used to store this property. /// This overload is intended for decimal. /// </summary> /// <param name="physicalStoreFieldType">PhysicalStoreFieldType to use - PhysicalStoreFieldType.Decimal expected</param> /// <param name="numericPrecision">Numeric precision for decimal</param> /// <param name="numericScale">Numeric scale for decimal</param> public StoreFieldTypeAttribute(PhysicalStoreFieldType physicalStoreFieldType, int numericPrecision, int numericScale) : this() { switch (physicalStoreFieldType) { case PhysicalStoreFieldType.Decimal: this.StoreFieldType = StoreFieldType.Decimal(numericPrecision, numericScale); return; } throw new ArgumentException(string.Format("[{0}] - field type {1}.{2} does not take two 'int' arguments in the attribute constructor.", this.GetType().Name, typeof(PhysicalStoreFieldType).Name, physicalStoreFieldType)); }
/// <summary> /// Specifies what physical store type should be used to store this property. /// This overload is intended for string. /// </summary> /// <param name="physicalStoreFieldType">PhysicalStoreFieldType to use - PhysicalStoreFieldType.String expected</param> /// <param name="maxLength">Number of characters to reserve in physical store</param> public StoreFieldTypeAttribute(PhysicalStoreFieldType physicalStoreFieldType, int maxLength) : this() { switch (physicalStoreFieldType) { case PhysicalStoreFieldType.String: this.StoreFieldType = StoreFieldType.String(maxLength); return; } throw new ArgumentException(string.Format("[{0}] - field type {1}.{2} does not take an int argument in the attribute constructor.", this.GetType().Name, typeof(PhysicalStoreFieldType).Name, physicalStoreFieldType)); }
private StoreFieldType(PhysicalStoreFieldType storeType, int maxLength) { switch (storeType) { case PhysicalStoreFieldType.String: if (maxLength < 1) { throw new ArgumentException("Maximum lenght must be 1 or greater", "maxLength"); } if (maxLength > StringMaximumLength) { throw new ArgumentException("Maximum lenght must be 2048 or less", "maxLength"); } this.PhysicalStoreType = storeType; this.MaximumLength = maxLength; return; } throw new ArgumentException("Specified PhysicalStoreType is not associated with a maximum length"); }
private StoreFieldType(PhysicalStoreFieldType storeType, int maxLength) { switch (storeType) { case PhysicalStoreFieldType.String: if (maxLength < 1) throw new ArgumentException("Maximum lenght must be 1 or greater", "maxLength"); if (maxLength > StringMaximumLength) throw new ArgumentException("Maximum lenght must be 2048 or less", "maxLength"); this.PhysicalStoreType = storeType; this.MaximumLength = maxLength; return; } throw new ArgumentException("Specified PhysicalStoreType is not associated with a maximum length"); }
private StoreFieldType(PhysicalStoreFieldType storeType, int precision, int scale) { switch (storeType) { case PhysicalStoreFieldType.Decimal: if (precision < 1) throw new ArgumentException("Precision must be 1 or greater"); if (precision > NumericPrecisionMaximum) throw new ArgumentException("Precision may not be greater than " + NumericPrecisionMaximum.ToString()); if (scale < 0) throw new ArgumentException("Scale must be 0 or greater"); if (scale > precision) throw new ArgumentException("Scale can not be larger than precision"); this.PhysicalStoreType = storeType; this.NumericPrecision = precision; this.NumericScale = scale; return; } throw new ArgumentException("Specified PhysicalStoreType is not associated with a presision and scale"); }
private StoreFieldType(PhysicalStoreFieldType storeType) { this.PhysicalStoreType = storeType; if (storeType == PhysicalStoreFieldType.LargeString) this.MaximumLength = int.MaxValue; }