nameservice.cs

来自「c#源代码」· CS 代码 · 共 85 行

CS
85
字号
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.2032
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace SharpReport {
	using System;
	using System.Windows.Forms;
	using System.ComponentModel;
	using SharpReportCore;
	
	/// <summary>
	/// Build proper (unique) Names for all added Item's
	/// </summary>
	/// <remarks>
	/// 	created by - Susanne Jooss
	/// 	created on - 27.08.2005 16:21:50
	/// </remarks>
	public class NameService : System.ComponentModel.Design.Serialization.INameCreationService {
		
		/// <summary>
		/// Default constructor - initializes all fields to default values
		/// </summary>
		public NameService() {
		}
		
		#region Customs implementation
		
		public string CreateName (ReportItemCollection collection,
		                          string typeName) {
			string name = Char.ToLower(typeName[0]) + typeName.Substring(1);
			int number = 1;
			
			while (collection[name + number.ToString()] != null) {
				++number;
			}
			
			return name + number.ToString();
		}
		
		
		public bool IsValidName(ReportItemCollection collection,
		                        string name) {
			if (name == null || name.Length == 0 || !(Char.IsLetter(name[0]) || name[0] == '_')) {
				return false;
			}
			IItemRenderer ii= collection[name];
			if (ii != null) {
				return true;
			}
			return false;
		}
		
		public void ValidateName(ReportItemCollection collection,
		                         string name) {
			if (!IsValidName(collection,name)) {
				throw new System.Exception("Invalid name " + name);
			}
		}
		#endregion
		
		#region System.ComponentModel.Design.Serialization.INameCreationService interface implementation
		public void ValidateName(string name) {
			throw new NotImplementedException("Name Service No Designersupport");
		}
		
		public bool IsValidName(string name) {
			throw new NotImplementedException("Name Service No Designersupport");
		}
		
		
		
		public string CreateName(System.ComponentModel.IContainer container, System.Type dataType) {
			throw new NotImplementedException("Name Service No Designersupport");
		}
		#endregion
		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?