/// <summary> /// Scans a given <see cref="Type" /> for data type. /// </summary> /// <param name="type">The <see cref="Type" /> to scan.</param> /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param> /// <returns> /// <see langword="true" /> if <paramref name="type" /> represents a /// data type; otherwise, <see langword="false" />. /// </returns> private static bool ScanTypeForDataTypes(Type type, Task task) { try { ElementNameAttribute elementNameAttribute = (ElementNameAttribute) Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute)); if (type.IsSubclassOf(typeof(DataTypeBase)) && !type.IsAbstract && elementNameAttribute != null) { logger.Info(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("String_CreatingDataTypeBaseBuilder"), type.Name)); DataTypeBaseBuilder dtb = new DataTypeBaseBuilder(type.FullName, type.Assembly.Location); if (DataTypeBuilders[dtb.DataTypeName] == null) { logger.Debug(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("String_AddingDataType"), dtb.DataTypeName, dtb.AssemblyFileName, dtb.ClassName)); DataTypeBuilders.Add(dtb); } // specified type represents a data type return(true); } else { // specified type does not represent valid data type return(false); } } catch { task.Log(Level.Error, "Failure scanning \"{0}\" for data types.", type.AssemblyQualifiedName); throw; } }
/// <summary> /// Creates the <see cref="DataTypeBase"/> instance. /// </summary> /// <param name="elementNode">The element XML node.</param> /// <param name="proj">The current project.</param> /// <param name="targetCallStack">The current target call stack. Needed for accessing thread and target properties.</param> /// <returns>The created instance.</returns> /// <exception cref="System.ArgumentNullException">If elementNode or proj is <c>null</c>. /// </exception> /// <exception cref="BuildException">If no builder for the elment can be found. /// </exception> public static DataTypeBase CreateDataType(XmlNode elementNode, Project proj, TargetCallStack targetCallStack) { if (elementNode == null) { throw new ArgumentNullException("elementNode"); } if (proj == null) { throw new ArgumentNullException("proj"); } string dataTypeName = elementNode.Name; DataTypeBaseBuilder builder = DataTypeBuilders[dataTypeName]; if (builder == null) { Location location = proj.LocationMap.GetLocation(elementNode); throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1081"), dataTypeName), location); } DataTypeBase element = (DataTypeBase)builder.CreateDataTypeBase(); element.Project = proj; element.CallStack = targetCallStack; element.NamespaceManager = proj.NamespaceManager; // check whether the type (or its base class) is deprecated ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute) Attribute.GetCustomAttribute(element.GetType(), typeof(ObsoleteAttribute), true); if (obsoleteAttribute != null) { Location location = proj.LocationMap.GetLocation(elementNode); string obsoleteMessage = string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1085"), dataTypeName, obsoleteAttribute.Message); if (obsoleteAttribute.IsError) { throw new BuildException(obsoleteMessage, location); } else { if (targetCallStack.CurrentFrame != null && targetCallStack.CurrentFrame.TaskCallStack.CurrentFrame != null) { targetCallStack.CurrentFrame.TaskCallStack.CurrentFrame.Task.Log(Level.Warning, "{0} {1}", location, obsoleteMessage); } else { (proj as ITargetLogger).Log(Level.Warning, "{0} {1}", location, obsoleteMessage); } } } return(element); }
/// <summary> /// Removes a member from the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to remove from the collection.</param> public void Remove(DataTypeBaseBuilder item) { base.List.Remove(item); }
/// <summary> /// Inserts a <see cref="DataTypeBaseBuilder"/> into the collection at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to insert.</param> public void Insert(int index, DataTypeBaseBuilder item) { base.List.Insert(index, item); }
/// <summary> /// Retrieves the index of a specified <see cref="DataTypeBaseBuilder"/> object in the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> object for which the index is returned.</param> /// <returns> /// The index of the specified <see cref="DataTypeBaseBuilder"/>. If the <see cref="DataTypeBaseBuilder"/> is not currently a member of the collection, it returns -1. /// </returns> public int IndexOf(DataTypeBaseBuilder item) { return(base.List.IndexOf(item)); }
/// <summary> /// Determines whether a <see cref="DataTypeBaseBuilder"/> is in the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to locate in the collection.</param> /// <returns> /// <see langword="true" /> if <paramref name="item"/> is found in the /// collection; otherwise, <see langword="false" />. /// </returns> public bool Contains(DataTypeBaseBuilder item) { return(base.List.Contains(item)); }
/// <summary> /// Adds a <see cref="DataTypeBaseBuilder"/> to the end of the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to be added to the end of the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(DataTypeBaseBuilder item) { return(base.List.Add(item)); }
/// <summary> /// Initializes a new instance of the <see cref="DataTypeBaseBuilderCollection"/> class /// with the specified array of <see cref="DataTypeBaseBuilder"/> instances. /// </summary> public DataTypeBaseBuilderCollection(DataTypeBaseBuilder[] value) { AddRange(value); }
/// <summary> /// Removes a member from the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to remove from the collection.</param> public void Remove(DataTypeBaseBuilder item) { base.List.Remove(item); }
/// <summary> /// Inserts a <see cref="DataTypeBaseBuilder"/> into the collection at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to insert.</param> public void Insert(int index, DataTypeBaseBuilder item) { base.List.Insert(index, item); }
/// <summary> /// Retrieves the index of a specified <see cref="DataTypeBaseBuilder"/> object in the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> object for which the index is returned.</param> /// <returns> /// The index of the specified <see cref="DataTypeBaseBuilder"/>. If the <see cref="DataTypeBaseBuilder"/> is not currently a member of the collection, it returns -1. /// </returns> public int IndexOf(DataTypeBaseBuilder item) { return base.List.IndexOf(item); }
/// <summary> /// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array. /// </summary> /// <param name="array">The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.</param> /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param> public void CopyTo(DataTypeBaseBuilder[] array, int index) { base.List.CopyTo(array, index); }
/// <summary> /// Determines whether a <see cref="DataTypeBaseBuilder"/> is in the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to locate in the collection.</param> /// <returns> /// <see langword="true" /> if <paramref name="item"/> is found in the /// collection; otherwise, <see langword="false" />. /// </returns> public bool Contains(DataTypeBaseBuilder item) { return base.List.Contains(item); }
/// <summary> /// Adds the elements of a <see cref="DataTypeBaseBuilder"/> array to the end of the collection. /// </summary> /// <param name="items">The array of <see cref="DataTypeBaseBuilder"/> elements to be added to the end of the collection.</param> public void AddRange(DataTypeBaseBuilder[] items) { for (int i = 0; (i < items.Length); i = (i + 1)) { Add(items[i]); } }
/// <summary> /// Adds a <see cref="DataTypeBaseBuilder"/> to the end of the collection. /// </summary> /// <param name="item">The <see cref="DataTypeBaseBuilder"/> to be added to the end of the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(DataTypeBaseBuilder item) { return base.List.Add(item); }
/// <summary> /// Scans a given <see cref="Type" /> for data type. /// </summary> /// <param name="extensionAssembly">The <see cref="ExtensionAssembly" /> containing the <see cref="Type" /> to scan.</param> /// <param name="type">The <see cref="Type" /> to scan.</param> /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param> /// <returns> /// <see langword="true" /> if <paramref name="type" /> represents a /// data type; otherwise, <see langword="false" />. /// </returns> private static bool ScanTypeForDataTypes(ExtensionAssembly extensionAssembly, Type type, Task task) { try { ElementNameAttribute elementNameAttribute = (ElementNameAttribute) Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute)); if (type.IsSubclassOf(typeof(DataTypeBase)) && !type.IsAbstract && elementNameAttribute != null) { logger.Info(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("String_CreatingDataTypeBaseBuilder"), type.Name)); DataTypeBaseBuilder dtb = new DataTypeBaseBuilder(extensionAssembly, type.FullName); if (DataTypeBuilders[dtb.DataTypeName] == null) { logger.Debug(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("String_AddingDataType"), dtb.DataTypeName, GetAssemblyLocation(dtb.Assembly), dtb.ClassName)); DataTypeBuilders.Add(dtb); } // specified type represents a data type return true; } else { // specified type does not represent valid data type return false; } } catch { task.Log(Level.Error, "Failure scanning \"{0}\" for data types.", type.AssemblyQualifiedName); throw; } }