本文整理汇总了C#中System.ComponentModel.Design.Serialization.INameCreationService.CreateName方法的典型用法代码示例。如果您正苦于以下问题:C# INameCreationService.CreateName方法的具体用法?C# INameCreationService.CreateName怎么用?C# INameCreationService.CreateName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Design.Serialization.INameCreationService
的用法示例。
在下文中一共展示了INameCreationService.CreateName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateName
// Creates an identifier for a particular data type that does not conflict
// with the identifiers of any components in the specified collection.
public string CreateName(System.ComponentModel.IContainer container, System.Type dataType)
{
// Create a basic type name string.
string baseName = dataType.Name;
int uniqueID = 1;
bool unique = false;
// Continue to increment uniqueID numeral until a
// unique ID is located.
while( !unique )
{
unique = true;
// Check each component in the container for a matching
// base type name and unique ID.
for(int i=0; i<container.Components.Count; i++)
{
// Check component name for match with unique ID string.
if( container.Components[i].Site.Name.StartsWith(baseName+uniqueID.ToString()) )
{
// If a match is encountered, set flag to recycle
// collection, increment ID numeral, and restart.
unique = false;
uniqueID++;
break;
}
}
}
return baseName+uniqueID.ToString();
}
开发者ID:.NET开发者,项目名称:System.ComponentModel.Design.Serialization,代码行数:32,代码来源:INameCreationService.CreateName