Example #1
0
		public string CastedValueOrNullConstant(object value, string name, string className)
		{
			IType type = new FieldDetails(className, name).GetFieldType();
			if (type == null)
				return null;
			return value != null && value.ToString() != "null" ? type.Cast(value).ToString()  : "null";
		}
Example #2
0
	    public object CheckIfObjectCanBeCasted(string classname, string fieldname, object data)
		{
			if (null == data && "null" == data.ToString())
				return false;
			IType objectType = new FieldDetails(classname, fieldname).GetFieldType();
			if (objectType == null)
				return null;
			return objectType.Cast(data);
		}
Example #3
0
		public bool ValidateDataType(string classname, string fieldname, object data)
		{
			if (null == data && "null" == data.ToString())
				return false;
            IType objectType = new FieldDetails(classname, fieldname).GetFieldType();
		    if (objectType == null)
				return false;
			objectType.Cast(data);
			return true;
		}
Example #4
0
        public static void SaveValues(long id, string attribName, object newValue, int offset)
        {
            try
            {
                object targetObject = Db4oClient.Client.Ext().GetByID(id);
                Db4oClient.Client.Ext().Activate(targetObject, 2);
                IReflectClass rclass = DataLayerCommon.ReflectClassFor(targetObject);
                IReflectField rfield = DataLayerCommon.GetDeclaredFieldInHeirarchy(rclass, attribName);
                IType type = new FieldDetails(rclass.GetName(), attribName).GetFieldType();
                object obj = rfield.Get(targetObject);

                if (obj is IDictionary)
                {
                    SaveDictionary(targetObject, attribName, newValue, KeyAtIndex((IDictionary)obj, offset/2));
                }
                else
                {

                    if (rfield != null && !(rfield is GenericVirtualField || rfield.IsStatic()))
                    {
                        if (type.IsArray || type.IsCollection)
                        {
                            IList list = obj as IList;
                            if (null != list)
                            {
                                list[offset] = newValue;
                                rfield.Set(targetObject, list);
                            }
                        }

                    }
                }
            }
            catch (Exception oEx)
            {
                Db4oClient.Client.Rollback();
                LoggingHelper.HandleException(oEx);
            }
        }
Example #5
0
 public static bool CheckForCollection(string className, string fieldname)
 {
    IType type = new FieldDetails(className, fieldname).GetFieldType();
     return CheckIsCollection(type);
 }
Example #6
0
    	private static FieldProperties FieldPropertiesFor(string className, IReflectField field)
    	{
    		FieldProperties fp = new FieldProperties(field.GetName(), field.GetFieldType().GetName());
    		FieldDetails fd = new FieldDetails(className, fp.Field);
    		fp.m_isPublic = fd.GetModifier();
    		fp.m_isIndexed = fd.IsIndexed();
    		
			return fp;
    	}