Ejemplo n.º 1
0
        public void ByteProperty()
        {
            byte bpv = 123;
            MgByteProperty bp = new MgByteProperty("BytePropName", bpv);

            Assert.AreEqual("BytePropName", bp.Name);
            Assert.AreEqual(bpv, bp.Value);
            Assert.AreEqual(MgPropertyType.Byte, bp.PropertyType);
        }
Ejemplo n.º 2
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            byte           bpv = 123;
            MgByteProperty bp  = new MgByteProperty("BytePropName", bpv);

            Assert.AreEqual("BytePropName", bp.Name);
            Assert.AreEqual(bpv, bp.Value);
            Assert.AreEqual(MgPropertyType.Byte, bp.PropertyType);
        }
Ejemplo n.º 3
0
        internal static void Populate(MgPropertyCollection props, IMutableRecord record)
        {
            for (int i = 0; i < record.FieldCount; i++)
            {
                var    pt   = record.GetPropertyType(i);
                string name = record.GetName(i);
                if (record.IsNull(i))
                {
                    switch (pt)
                    {
                    case PropertyValueType.Blob:
                    {
                        var propVal = new MgBlobProperty(name, null);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Boolean:
                    {
                        var propVal = new MgBooleanProperty(name, false);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Byte:
                    {
                        var propVal = new MgByteProperty(name, 0);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Clob:
                    {
                        var propVal = new MgClobProperty(name, null);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.DateTime:
                    {
                        var propVal = new MgDateTimeProperty(name, null);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Double:
                    {
                        var propVal = new MgDoubleProperty(name, 0.0);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Geometry:
                    {
                        var propVal = new MgGeometryProperty(name, null);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Int16:
                    {
                        var propVal = new MgInt16Property(name, 0);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Int32:
                    {
                        var propVal = new MgInt32Property(name, 0);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Int64:
                    {
                        var propVal = new MgInt64Property(name, 0L);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.Single:
                    {
                        var propVal = new MgSingleProperty(name, 0.0f);
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    case PropertyValueType.String:
                    {
                        var propVal = new MgStringProperty(name, "");
                        propVal.SetNull(true);
                        props.Add(propVal);
                    }
                    break;

                    default:
                        throw new NotSupportedException();
                    }
                }
                else
                {
                    switch (pt)
                    {
                    case PropertyValueType.Blob:
                    {
                        var bytes = record.GetBlob(i);
                        var br    = new MgByteSource(bytes, bytes.Length);
                        var bv    = new MgBlobProperty(name, br.GetReader());
                        props.Add(bv);
                    }
                    break;

                    case PropertyValueType.Boolean:
                    {
                        props.Add(new MgBooleanProperty(name, record.GetBoolean(i)));
                    }
                    break;

                    case PropertyValueType.Byte:
                    {
                        props.Add(new MgByteProperty(name, record.GetByte(i)));
                    }
                    break;

                    case PropertyValueType.Clob:
                    {
                        var bytes = record.GetBlob(i);
                        var br    = new MgByteSource(bytes, bytes.Length);
                        var bv    = new MgClobProperty(name, br.GetReader());
                        props.Add(bv);
                    }
                    break;

                    case PropertyValueType.DateTime:
                    {
                        var dt  = record.GetDateTime(i);
                        var mdt = new MgDateTime((short)dt.Year, (short)dt.Month, (short)dt.Day, (short)dt.Hour, (short)dt.Minute, (short)dt.Second, dt.Millisecond * 1000);
                        props.Add(new MgDateTimeProperty(name, mdt));
                    }
                    break;

                    case PropertyValueType.Double:
                    {
                        props.Add(new MgDoubleProperty(name, record.GetDouble(i)));
                    }
                    break;

                    case PropertyValueType.Geometry:
                    {
                        MgByteReader agf = GeomConverter.GetAgf(record.GetGeometry(i));
                        props.Add(new MgGeometryProperty(name, agf));
                    }
                    break;

                    case PropertyValueType.Int16:
                    {
                        props.Add(new MgInt16Property(name, record.GetInt16(i)));
                    }
                    break;

                    case PropertyValueType.Int32:
                    {
                        props.Add(new MgInt32Property(name, record.GetInt32(i)));
                    }
                    break;

                    case PropertyValueType.Int64:
                    {
                        props.Add(new MgInt64Property(name, record.GetInt64(i)));
                    }
                    break;

                    case PropertyValueType.Single:
                    {
                        props.Add(new MgSingleProperty(name, record.GetSingle(i)));
                    }
                    break;

                    case PropertyValueType.String:
                    {
                        props.Add(new MgStringProperty(name, record.GetString(i)));
                    }
                    break;

                    default:
                        throw new NotSupportedException();
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public MgProperty GenerateProperty()
 {
     MgProperty prop = null;
     if (IsReadOnly || IsIdentity || !IsUpdated) return null;
     switch (PropertyType)
     {
         case MgPropertyType.Boolean:
             bool val = new bool();
             if (!bool.TryParse(Value.ToString(), out val))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> - נתון אינו תקין", Alias)); }
             prop = new MgBooleanProperty(Name, val);
             break;
         case MgPropertyType.Byte:
             byte val2 = new byte();
             if (!byte.TryParse(Value.ToString(), out val2))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> - נתון אינו תקין", Alias)); }
             prop = new MgByteProperty(Name, val2);
             break;
         case MgPropertyType.Double:
             double val3 = new double();
             if (!double.TryParse(Value.ToString(), out val3))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); }
             prop = new MgDoubleProperty(Name, val3);
             break;
         case MgPropertyType.Int16:
             short val4 = new short();
             if (!short.TryParse(Value.ToString(), out val4))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); }
             prop = new MgInt16Property(Name, val4);
             break;
         case MgPropertyType.Int32:
             int val5 = new int();
             if (!int.TryParse(Value.ToString(), out val5))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); }
             prop = new MgInt32Property(Name, val5);
             break;
         case MgPropertyType.Int64:
             long val6 = new long();
             if (!long.TryParse(Value.ToString(), out val6))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); }
             prop = new MgInt64Property(Name, val6);
             break;
         case MgPropertyType.DateTime:
             MgDateTime dt = new MgDateTime();
             short day, month, year;
             if (Alias == "תאריך עדכון" || Alias == "עדכון אחרון")
             {
                 Value = DateTime.Now.ToString("dd/MM/yyyy");
             }
             string[] arrDT = Value.ToString().Split('/');
             if (!short.TryParse(arrDT[0], out day) || !short.TryParse(arrDT[1], out month) || !short.TryParse(arrDT[2], out year))
             { throw new InvalidOperationException(string.Format("<b>{0}</b> פורמת תאריך שגוי", Alias)); }
             dt.Day = day;
             dt.Month = month;
             dt.Year = year;
             prop = new MgDateTimeProperty(Name, dt);
             break;
         case MgPropertyType.String:
             string val7 = "";
             val7 = Value.ToString();
             prop = new MgStringProperty(Name, val7);
             break;
         default:
             break;
     }
     return prop;
 }