/// <summary> /// Initiate an instance of ExtendedTypeDefinition with the type name /// </summary> /// <param name="typeName"></param> public ExtendedTypeDefinition(string typeName) : this() { if (String.IsNullOrEmpty(typeName)) { throw PSTraceSource.NewArgumentNullException("typeName"); } TypeNames.Add(typeName); }
/// <summary> /// Constructor for the ExtendedTypeDefinition /// </summary> /// <param name="typeName"></param> /// <param name="viewDefinitions"></param> public ExtendedTypeDefinition(string typeName, IEnumerable <FormatViewDefinition> viewDefinitions) : this() { if (String.IsNullOrEmpty(typeName)) { throw PSTraceSource.NewArgumentNullException("typeName"); } if (viewDefinitions == null) { throw PSTraceSource.NewArgumentNullException("viewDefinitions"); } TypeNames.Add(typeName); foreach (FormatViewDefinition definition in viewDefinitions) { FormatViewDefinition.Add(definition); } }
private static string GetName <T>() { var type = typeof(T); var b = TypeNames.TryGetValue(type, out var name); if (b) { return(name.Ns()); } var value = type.Name; lock (TypeNames) { b = TypeNames.TryGetValue(type, out var _); if (!b) { TypeNames.Add(type, value); } } return(value.Ns()); }