Exemple #1
0
        public virtual object GetValueOf(string attributeName)
        {
            int  attributeId = -1;
            bool isRelation  = attributeName.IndexOf(".") != -1;

            if (!isRelation)
            {
                attributeId = GetClassInfo().GetAttributeId(attributeName);
                return(GetAttributeValueFromId(attributeId).GetObject());
            }
            int    firstDotIndex      = attributeName.IndexOf(".");
            string firstAttributeName = NeoDatis.Tool.Wrappers.OdbString.Substring(attributeName
                                                                                   , 0, firstDotIndex);

            attributeId = GetClassInfo().GetAttributeId(firstAttributeName);
            object @object = attributeValues[attributeId];

            if (@object is NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                 )@object;
                return(nnoi.GetValueOf(NeoDatis.Tool.Wrappers.OdbString.Substring(attributeName,
                                                                                  firstDotIndex + 1, attributeName.Length)));
            }
            throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClassInfoDoNotHaveTheAttribute
                                                       .AddParameter(GetClassInfo().GetFullClassName()).AddParameter(attributeName));
        }
Exemple #2
0
        public virtual bool Match(NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                  aoi)
        {
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                             )aoi;
            object aoiValue = nnoi.GetValueOf(attributeName);

            return(Match(aoiValue));
        }
Exemple #3
0
 public virtual object GetValueOf(string attributeName)
 {
     if (nnoi.IsNull())
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.TriggerCalledOnNullObject
                                                    .AddParameter(nnoi.GetClassInfo().GetFullClassName()).AddParameter(attributeName
                                                                                                                       ));
     }
     return(nnoi.GetValueOf(attributeName));
 }
Exemple #4
0
        /// <summary>Using Object representation instead of real object</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test3()
        {
            int sublistSize = 10000;

            DeleteBase("valuesSubList3");
            NeoDatis.Odb.ODB odb = Open("valuesSubList3");
            NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                                 ();
            for (int i = 0; i < sublistSize; i++)
            {
                handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value "
                                                                                  + i));
            }
            odb.Store(handler);
            odb.Close();
            odb = Open("valuesSubList3");
            long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Sublist("parameters", "sub", 9990
                                                                                                                  , 5, true);
            q.SetReturnInstance(false);
            NeoDatis.Odb.Values values = odb.GetValues(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens from 40000 : " + (end - start));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(5, sublist.Count);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                             )sublist[0];
            AssertEquals("value 9990", nnoi.GetValueOf("value"));
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi2 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                              )sublist[4];
            AssertEquals("value 9994", nnoi2.GetValueOf("value"));
            odb.Close();
        }
Exemple #5
0
        public virtual int CompareField(int fieldIndex, object o1, object o2)
        {
            //Field field2 = getField(o2);
            object oo1 = null;
            object oo2 = null;

            System.Type type = null;
            try
            {
                if (o1 is NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo && o2 is NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)
                {
                    NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi1 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                      )o1;
                    NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi2 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                      )o2;
                    oo1  = nnoi1.GetValueOf(fieldNames[fieldIndex]);
                    oo2  = nnoi2.GetValueOf(fieldNames[fieldIndex]);
                    type = oo1.GetType();
                }
                else
                {
                    System.Reflection.FieldInfo field1 = GetField(fieldIndex, o1);
                    oo1  = field1.GetValue(o1);
                    oo2  = field1.GetValue(o2);
                    type = field1.GetType();
                }
                // if(isNumeric(field1) && isNumeric(field2)){
                if (type == typeof(int))
                {
                    return(way * CompareTo((int)oo1, (int)oo2));
                }
                if (type == typeof(long))
                {
                    return(way * CompareTo((long)oo1, (long)oo2));
                }
                if (type == typeof(short))
                {
                    return(way * CompareTo((short)oo1, (short)oo2));
                }
                if (type == typeof(double))
                {
                    return(way * CompareTo((double)oo1, (double)oo2));
                }
                if (type == typeof(float))
                {
                    return(way * CompareTo((float)oo1, (float)oo2));
                }
                if (type == typeof(byte))
                {
                    return(way * CompareTo((byte)oo1, (byte)oo2));
                }
                if (type == typeof(int))
                {
                    return(way * CompareTo((int)oo1, (int)oo2));
                }
                if (type == typeof(long))
                {
                    return(way * CompareToLong((long)oo1, (long)oo2));
                }
                if (type == typeof(System.DateTime))
                {
                    return(way * CompareTo((System.DateTime)oo1, (System.DateTime)oo2));
                }
                return(way * CompareTo(oo1, oo2));
            }
            catch (System.Exception e)
            {
                throw new System.Exception(e.Message);
            }
        }