public void Remove(OutputExtension value) { int index = IndexOf(value); if (index == -1) { throw(new Exception("ClassOutputPlugin not found in collection.")); } RemoveAt(index); }
public int IndexOf(OutputExtension value) { for (int x = 0; x < itemCount; x++) { if (extensions[x].Equals(value)) { return(x); } } return(-1); }
public void Insert(int index, OutputExtension value) { itemCount++; if (itemCount > extensions.Length) { for (int x = index + 1; x == itemCount - 2; x++) { extensions[x] = extensions[x - 1]; } } extensions[index] = value; }
public int Add(OutputExtension value) { itemCount++; if (itemCount > extensions.GetUpperBound(0) + 1) { OutputExtension[] tempExtensions = new OutputExtension[itemCount * 2]; for (int x = 0; x <= extensions.GetUpperBound(0); x++) { tempExtensions[x] = extensions[x]; } extensions = tempExtensions; } extensions[itemCount - 1] = value; return(itemCount - 1); }
public OutputExtensionConnector(XmlTextReader r, ModelClass classEntry) { _parentClassEntry = classEntry; _config = new NameValueCollection(); if (r.Name != "ClassOutputConnector") { throw new Exception(string.Format("Source file does not match NitroCast DTD; " + "expected 'ClassOutputConnector', found '{0}'.", r.Name)); } r.MoveToContent(); string pluginName = r.ReadElementString("ParentPlugin"); ExtensionManager m = ExtensionManager.GetInstance(); _parentPlugin = m.OutputExtensions[pluginName]; if (_parentPlugin == null) { throw new Exception(string.Format("Cannot connect to OutputPlugin '{0}'.", pluginName)); } if (r.Name == "Config") { if (!r.IsEmptyElement) { r.Read(); while (r.NodeType != XmlNodeType.EndElement) { _config.Add(r.Name, r.ReadElementString(r.Name)); } r.ReadEndElement(); } else { r.ReadEndElement(); } } r.ReadEndElement(); }
public bool Contains(OutputExtension value) { return(IndexOf(value) != -1); }
/// <summary> /// Adds a plugin to the plugin manager's plugin lists. If the plugin /// does not implement ClassOutputPlugin or EnumOutputPlugin then the /// type to be added will be ignored. /// </summary> /// <param name="type">The plugin to add.</param> public void AddExtension(Type type) { ExtensionAttribute attribute; object[] attributes; attributes = type.GetCustomAttributes(typeof(ExtensionAttribute), false); if (type.BaseType != null) { switch (type.BaseType.Name) { case "ValueFieldExtension": { objectExtensionTypes.Add(type.FullName, type); break; } case "ReferenceFieldExtension": { objectExtensionTypes.Add(type.FullName, type); break; } case "EnumFieldExtension": { objectExtensionTypes.Add(type.FullName, type); break; } case "ClassFolderExtension": { objectExtensionTypes.Add(type.FullName, type); break; } case "OutputExtension": { if (attributes.Length > 0) { attribute = (ExtensionAttribute)attributes[0]; OutputExtension p = (OutputExtension) Activator.CreateInstance(type); p.Name = attribute.Name; p.FullName = type.FullName; p.Author = attribute.Author; p.Copyright = attribute.Copyright; p.OutputFileNameFormat = attribute.OutputFileNameFormat; p.Description = attribute.Description; p.ExtensionPath = attribute.ExtensionPath; p.AssemblyPath = type.Assembly.Location; p.IsWebControl = attribute.IsWebControl; outputExtensions.Add(p.Name, p); } break; } case "ValueTypeBuilder": { attribute = (ExtensionAttribute)attributes[0]; ValueTypeBuilder b = (ValueTypeBuilder) Activator.CreateInstance(type); b.Name = attribute.Name; b.FullName = type.FullName; b.Author = attribute.Author; b.Copyright = b.Copyright; b.OutputFileNameFormat = string.Empty; b.Description = attribute.Description; b.ExtensionPath = string.Empty; b.AssemblyPath = type.Assembly.Location; ValueTypeBuilder.Builders.Add(b.Name, b); break; } case "ReferenceTypeBuilder": { attribute = (ExtensionAttribute)attributes[0]; ReferenceTypeBuilder b = (ReferenceTypeBuilder) Activator.CreateInstance(type); b.Name = attribute.Name; b.FullName = type.FullName; b.Author = attribute.Author; b.Copyright = b.Copyright; b.OutputFileNameFormat = string.Empty; b.Description = attribute.Description; b.ExtensionPath = string.Empty; b.AssemblyPath = type.Assembly.Location; ReferenceTypeBuilder.Builders.Add(b.Name, b); break; } case "EnumTypeBuilder": { attribute = (ExtensionAttribute)attributes[0]; EnumTypeBuilder b = (EnumTypeBuilder) Activator.CreateInstance(type); b.Name = attribute.Name; b.FullName = type.FullName; b.Author = attribute.Author; b.Copyright = b.Copyright; b.OutputFileNameFormat = string.Empty; b.Description = attribute.Description; b.ExtensionPath = string.Empty; b.AssemblyPath = type.Assembly.Location; EnumTypeBuilder.Builders.Add(b.Name, b); break; } } } }
public OutputExtensionConnector(ModelClass classEntry, OutputExtension outputPlugin) { _parentClassEntry = classEntry; _parentPlugin = outputPlugin; _config = new NameValueCollection(); }