public static IEnumerable Enum(TListInt32 AList) { if(AList == null) yield break; Int32 LIndex = 0; foreach(Int32 LKey in AList.FList) { yield return new KeyValuePair<Int32,Int32>(LKey, ++LIndex); } }
public static TListInt32 FromCompressedBinary(SqlBytes AData) { if (AData.IsNull) return TListInt32.Null; TListInt32 LResult = new TListInt32(); System.IO.BinaryReader r = new System.IO.BinaryReader(AData.Stream); int LCount = Sql.Read7BitEncodedInt(r); LResult.FList.Capacity = LCount; for(; LCount > 0; LCount--) LResult.FList.Add(Sql.Read7BitEncodedInt(r)); return LResult; }
/// <summary> /// Возвращает значение параметра типа TListInt32 /// </summary> protected TListInt32 AsTListInt32(String AName) { Object LValue; if (!FData.TryGetValue(AName, out LValue)) return null; try { if(LValue is SqlUdt) LValue = ((SqlUdt)LValue).CreateUdtObject(true); if (LValue is TListInt32) return (TListInt32)LValue; else { TListInt32 LResult = new TListInt32(); if (LValue is SqlString) LResult.FromString(((SqlString)LValue).Value); else if (LValue is SqlChars) LResult.FromString(((SqlChars)LValue).ToString()); //else if (LValue is Sql.SqlAnsiString) return new SqlBinary(((Sql.SqlAnsiString)LValue).Buffer); else { System.IO.BinaryReader r; if (LValue is SqlBytes) r = new System.IO.BinaryReader(((SqlBytes)LValue).Stream); else if (LValue is SqlBinary) r = new System.IO.BinaryReader(new System.IO.MemoryStream(((SqlBinary)LValue).Value)); else throw new Exception(); LResult.Read(r); } return LResult; } } catch { throw new Exception(String.Format("Не удалось сконвертировать значение '{0}' параметра '{1}' в тип TListInt32", Sql.ValueToString(LValue, Sql.ValueDbStyle.Text), AName)); } }
public void AddTListInt32(String AName, TListInt32 AValue) { base.AddParam(AName, new SqlUdt(AValue)); }
public static bool IsEqual(TListInt32 AList1, TListInt32 AList2) { if (AList1 == null && AList2 == null) return true; if (AList1 == null || AList2 == null) return false; return AList1.Equals(AList2); }
public void Read(System.IO.BinaryReader r) { //if (r == null) throw new ArgumentNullException("r"); if(OResult == null) OResult = new TListInt32(); OResult.Read(r); }
public void Init() { OResult = new TListInt32(); }
public bool Equals(TListInt32 AList) { if(AList == null || FList.Count != AList.FList.Count) return false; for(int i = FList.Count - 1; i >= 0; i--) if(FList[i] != AList.FList[i]) return false; return true; }
public Boolean ContainsAll(TListInt32 AValue) { if(AValue == null || AValue.FList.Count == 0) return true; for(int i = AValue.FList.Count - 1; i >= 0; i--) if(!FList.Contains(AValue.FList[i])) return false; return true; }
public static TListInt32 Parse(SqlString AString) { if (AString.IsNull) return null; TListInt32 LResult = new TListInt32(); LResult.FromString(AString.Value); return LResult; }