本文整理汇总了C#中ClassInfo.GetAttributeInfoFromId方法的典型用法代码示例。如果您正苦于以下问题:C# ClassInfo.GetAttributeInfoFromId方法的具体用法?C# ClassInfo.GetAttributeInfoFromId怎么用?C# ClassInfo.GetAttributeInfoFromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo.GetAttributeInfoFromId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractDifferences
public ClassInfoCompareResult ExtractDifferences(ClassInfo newCI, bool update)
{
string attributeName;
ClassAttributeInfo cai1;
ClassAttributeInfo cai2;
var result = new ClassInfoCompareResult(FullClassName);
IOdbList<ClassAttributeInfo> attributesToRemove = new OdbList<ClassAttributeInfo>(10);
IOdbList<ClassAttributeInfo> attributesToAdd = new OdbList<ClassAttributeInfo>(10);
var attributesCount = _attributes.Count;
for (var id = 0; id < attributesCount; id++)
{
// !!!WARNING : ID start with 1 and not 0
cai1 = _attributes[id];
if (cai1 == null)
continue;
attributeName = cai1.GetName();
cai2 = newCI.GetAttributeInfoFromId(cai1.GetId());
if (cai2 == null)
{
result.AddCompatibleChange(string.Format("Field '{0}' has been removed", attributeName));
if (update)
{
// Simply remove the attribute from meta-model
attributesToRemove.Add(cai1);
}
}
else
{
if (!OdbType.TypesAreCompatible(cai1.GetAttributeType(), cai2.GetAttributeType()))
{
result.AddIncompatibleChange(
string.Format("Type of Field '{0}' has changed : old='{1}' - new='{2}'", attributeName,
cai1.GetFullClassname(), cai2.GetFullClassname()));
}
}
}
var nbNewAttributes = newCI._attributes.Count;
for (var id = 0; id < nbNewAttributes; id++)
{
// !!!WARNING : ID start with 1 and not 0
cai2 = newCI._attributes[id];
if (cai2 == null)
continue;
attributeName = cai2.GetName();
cai1 = GetAttributeInfoFromId(cai2.GetId());
if (cai1 == null)
{
result.AddCompatibleChange("Field '" + attributeName + "' has been added");
if (update)
{
// Sets the right id of attribute
cai2.SetId(MaxAttributeId + 1);
MaxAttributeId++;
// Then adds the new attribute to the meta-model
attributesToAdd.Add(cai2);
}
}
}
_attributes.RemoveAll(attributesToRemove);
_attributes.AddAll(attributesToAdd);
FillAttributesMap();
return result;
}