Exemplo n.º 1
0
        internal static void AddChangeDateProperty(PropertyInfo createDateProperty, PropertyInfo changeDateProperty,
            TypeUsageInfo iintervalfields, EntityInfo entity)
        {
            var getter = string.Format("return {0};", changeDateProperty.Name);
            if(changeDateProperty.Type.IsNullable)
            {
                var createPropertyGetter = createDateProperty.Name;
                if (createDateProperty.Type.IsNullable)
                {
                    createPropertyGetter = createDateProperty.Name + " ?? DateTime.Now";
                }

                getter = string.Format("if({0}.HasValue) return {0}.Value; else return {1};",
                    changeDateProperty.Name, createPropertyGetter);
            }
            var prop = new PropertyInfo(changeDateProperty.Name, (typeof(DateTime)).ToUsageInfo(),
                new PropertyInvokerInfo(getter),
                new PropertyInvokerInfo(string.Format("{0} = value;",
                    changeDateProperty.Name)));
            prop.ExplicitInterface = iintervalfields;
            entity.AddProperty(prop);
        }
Exemplo n.º 2
0
 internal static void AddExplicitProperty(PropertyInfo property, TypeUsageInfo iintervalfields, EntityInfo entity)
 {
     if (property.Type.IsNullable)
     {
         return;
     }
     var prop = new PropertyInfo(property.Name, TypeUsageInfo.CreateNullable(property.Type),
         new PropertyInvokerInfo(string.Format("return {0};", property.Name)),
         new PropertyInvokerInfo(string.Format("if(value.HasValue){0} = value.Value; else throw new ArgumentNullException(\"value\");", property.Name)));
     prop.ExplicitInterface = iintervalfields;
     entity.AddProperty(prop);
 }
Exemplo n.º 3
0
 internal static void AddHasTitleProperty(TypeUsageInfo ihastitle, EntityInfo entity, TableContent tableContent)
 {
     var prop = new PropertyInfo("EntityTitle", new FieldInfo("EntityTitle", (typeof(string)).ToUsageInfo()),
         new PropertyInvokerInfo(string.Format("return {0}.ToString();", tableContent.TitleFieldName)),
         null);
     prop.ExplicitInterface = ihastitle;
     entity.AddProperty(prop);
 }