本文整理匯總了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