本文整理汇总了C#中DomainObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DomainObject.GetType方法的具体用法?C# DomainObject.GetType怎么用?C# DomainObject.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomainObject
的用法示例。
在下文中一共展示了DomainObject.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: unregisterDomainObject
public void unregisterDomainObject(DomainObject domainObject)
{
Hashtable typeMap = (Hashtable)m_typeMaps[domainObject.GetType().BaseType];
if(typeMap == null)
Debug.Assert(false);
Debug.Assert(typeMap.Contains(domainObject.Id));
typeMap.Remove(domainObject.Id);
}
示例2: IsPersistent
public static bool IsPersistent(DomainObject entity)
{
var keyAttributedProps =
entity.GetType()
.GetProperties()
.FirstOrDefault(p => p.GetCustomAttributes(typeof (KeyAttribute), true).Length == 1);
return (keyAttributedProps != null) && !keyAttributedProps.GetValue(entity, null).ToString().Equals("0");
}
示例3: Remove
public void Remove(DomainObject item)
{
if(item == Person.None) return;
if (_domainObjects.Contains(item) == false) return; // Already exists
IList bindingList = _bindingLists[item.GetType()];
bindingList.Remove(item);
_domainObjects.Remove(item);
}
示例4: registerDomainObject
public void registerDomainObject(DomainObject domainObject)
{
Type type = domainObject.GetType().BaseType;
Hashtable typeMap = (Hashtable)m_typeMaps[type];
if(typeMap == null)
{
typeMap = new Hashtable();
m_typeMaps[type] = typeMap;
}
Debug.Assert(typeMap.Contains(domainObject) == false);
typeMap.Add(domainObject.Id, domainObject);
}
示例5: Add
public void Add(DomainObject item)
{
if(item == null) return;
if (_domainObjects.Contains(item)) return; // Already exists
IList bindingList = _bindingLists[item.GetType()];
Movie pet = item as Movie;
if (pet != null)
{
Add(pet.Director);
}
bindingList.Add(item);
_domainObjects.Add(item);
}
示例6: GetPropertyValue
/// <summary>
/// Gets value for given business object's property using reflection.
/// </summary>
protected object GetPropertyValue(DomainObject domainObject)
{
return domainObject.GetType().GetProperty(PropertyName).GetValue(domainObject, null);
}
示例7: Validate
public override bool Validate(DomainObject domainObject)
{
try
{
string propValue1 = domainObject.GetType().GetProperty(PropertyName).GetValue(domainObject, null).ToString();
string propValue2 = domainObject.GetType().GetProperty(OtherPropertyName).GetValue(domainObject, null).ToString();
switch(DataType)
{
case ValidationDataType.Integer:
int ival1 = int.Parse(propValue1);
int ival2 = int.Parse(propValue2);
switch(Operator)
{
case ValidationOperator.Equal: return ival1 == ival2;
case ValidationOperator.NotEqual: return ival1 != ival2;
case ValidationOperator.GreaterThan: return ival1 > ival2;
case ValidationOperator.GreaterThanEqual: return ival1 >= ival2;
case ValidationOperator.LessThan: return ival1 < ival2;
case ValidationOperator.LessThanEqual: return ival1 <= ival2;
}
break;
case ValidationDataType.Double:
double dval1 = double.Parse(propValue1);
double dval2 = double.Parse(propValue2);
switch(Operator)
{
case ValidationOperator.Equal: return dval1 == dval2;
case ValidationOperator.NotEqual: return dval1 != dval2;
case ValidationOperator.GreaterThan: return dval1 > dval2;
case ValidationOperator.GreaterThanEqual: return dval1 >= dval2;
case ValidationOperator.LessThan: return dval1 < dval2;
case ValidationOperator.LessThanEqual: return dval1 <= dval2;
}
break;
case ValidationDataType.Decimal:
decimal cval1 = decimal.Parse(propValue1);
decimal cval2 = decimal.Parse(propValue2);
switch(Operator)
{
case ValidationOperator.Equal: return cval1 == cval2;
case ValidationOperator.NotEqual: return cval1 != cval2;
case ValidationOperator.GreaterThan: return cval1 > cval2;
case ValidationOperator.GreaterThanEqual: return cval1 >= cval2;
case ValidationOperator.LessThan: return cval1 < cval2;
case ValidationOperator.LessThanEqual: return cval1 <= cval2;
}
break;
case ValidationDataType.Date:
DateTime tval1 = DateTime.Parse(propValue1);
DateTime tval2 = DateTime.Parse(propValue2);
switch(Operator)
{
case ValidationOperator.Equal: return tval1 == tval2;
case ValidationOperator.NotEqual: return tval1 != tval2;
case ValidationOperator.GreaterThan: return tval1 > tval2;
case ValidationOperator.GreaterThanEqual: return tval1 >= tval2;
case ValidationOperator.LessThan: return tval1 < tval2;
case ValidationOperator.LessThanEqual: return tval1 <= tval2;
}
break;
case ValidationDataType.String:
int result = string.Compare(propValue1, propValue2, StringComparison.CurrentCulture);
switch(Operator)
{
case ValidationOperator.Equal: return result == 0;
case ValidationOperator.NotEqual: return result != 0;
case ValidationOperator.GreaterThan: return result > 0;
case ValidationOperator.GreaterThanEqual: return result >= 0;
case ValidationOperator.LessThan: return result < 0;
case ValidationOperator.LessThanEqual: return result <= 0;
}
break;
}
return false;
}
catch{ return false; }
}