本文整理汇总了C#中Com.Aote.ObjectTools.GeneralObject.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralObject.CopyFrom方法的具体用法?C# GeneralObject.CopyFrom怎么用?C# GeneralObject.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Com.Aote.ObjectTools.GeneralObject
的用法示例。
在下文中一共展示了GeneralObject.CopyFrom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewPropertyValue
public void NewPropertyValue(string propertyName)
{
//有属性默认值
var p = (from ps in PropertySetters where ps.PropertyName == propertyName select ps).FirstOrDefault();
if (p != null && p.Default != null)
{
//设置默认属性结果
SetPropertyValue(propertyName, p.Default, true, true);
//如果默认属性是列表,调用列表的New过程
if (p.Default is BaseObjectList)
{
(p.Default as BaseObjectList).New();
}
}
//有默认对象,复制默认对象
else if (p != null && p.DefaultObject != null)
{
if (p.DefaultObject is GeneralObject)
{
//复制默认对象到新对象
GeneralObject go = p.DefaultObject as GeneralObject;
GeneralObject ngo = new GeneralObject();
ngo.CopyFrom(go);
p.Object.SetPropertyValue(p.PropertyName, ngo, false, true);
}
else if (p.DefaultObject is ObjectList)
{
//复制默认对象到新对象
ObjectList go = p.DefaultObject as ObjectList;
ObjectList ngo = new ObjectList();
ngo.CopyFrom(go);
p.Object.SetPropertyValue(p.PropertyName, ngo, false, true);
}
}
else
{
//如果属性是集合
if (GetProperty(propertyName).PropertyType == typeof(BaseObjectList))
{
//如果属性存在,清空集合
BaseObjectList old = (BaseObjectList)this.GetPropertyValue(propertyName);
if (old != null)
{
old.New();
}
//否则,无不置空标记,设置一个空集合
else if (!NotEmpty)
{
SetPropertyValue(propertyName, new ObjectList(), true);
}
}
else
{
SetPropertyValue(propertyName, null, true, true);
}
}
}
示例2: FindResource
/// <summary>
/// 根据名称,查找所有资源
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public object FindResource(string name)
{
//如果是left,返回当前左侧数据
if (name == "left")
{
GeneralObject go = new GeneralObject();
go.CopyFrom(CurrentLeft);
return go;
}
else if (name == "head")
{
GeneralObject go = new GeneralObject();
go.CopyFrom(CurrentHead);
return go;
}
else if (name == "each")
{
GeneralObject go = new GeneralObject();
go.CopyFrom(CurrentMain);
return go;
}
else
{
//在主体数据中查询资源
foreach (BodyDatas item in TableBodyItems)
{
if (item.Name == name)
{
return item.Value;
}
}
}
//调用框架的查找资源
return FrameworkElementExtension.FindResource(this,name);
}
示例3: CopyDataFrom
public void CopyDataFrom(GeneralObject go)
{
//复制实体类型
if (go.entityType != null)
{
EntityType = go.EntityType;
}
foreach (string key in go._customPropertyValues.Keys)
{
object value = go._customPropertyValues[key];
//是列表,进行列表复制
if (value is BaseObjectList)
{
//如果列表不存在,新建列表
if (!_customPropertyValues.ContainsKey(key) || _customPropertyValues[key] == null)
{
ObjectList ol = new ObjectList();
SetPropertyValue(key, ol, true);
}
ObjectList nol = (ObjectList)_customPropertyValues[key];
nol.CopyFrom(value as BaseObjectList);
}
//是对象,进行对象复制
else if (value is GeneralObject)
{
GeneralObject newgo = new GeneralObject();
newgo.CopyFrom((GeneralObject)value);
SetPropertyValue(key, newgo, true);
}
//是一般属性,调用设置属性值的过程
else
{
this.NewGetType();
SetPropertyValue(key, value, true);
}
}
}
示例4: Clone
/// <summary>
/// 复制自己
/// </summary>
/// <returns>复制结果</returns>
public GeneralObject Clone()
{
GeneralObject go = new GeneralObject();
go.CopyFrom(this);
return go;
}
示例5: ToSource
public void ToSource()
{
//如果Source不为空,把数据复制到Source中
if (Source != null)
{
Source.CopyFrom(this);
}
//如果有对应列表,复制一份到列表中
else if (List != null)
{
GeneralObject go = new GeneralObject();
go.CopyFrom(this);
List.Add(go);
}
}