public void Ctor_Type_Type(Type designerType, Type designerBaseType) { var attribute = new DesignerAttribute(designerType, designerBaseType); Assert.Equal(designerType.AssemblyQualifiedName, attribute.DesignerTypeName); Assert.Equal(designerBaseType.AssemblyQualifiedName, attribute.DesignerBaseTypeName); }
public void Ctor_String_String(string designerTypeName, string designerBaseTypeName) { var attribute = new DesignerAttribute(designerTypeName, designerBaseTypeName); Assert.Equal(designerTypeName, attribute.DesignerTypeName); Assert.Equal(designerBaseTypeName, attribute.DesignerBaseTypeName); }
internal static IDictionary <Type, DataControlFieldDesigner> GetCustomFieldDesigners(DesignerForm designerForm, DataBoundControl control) { Dictionary <Type, DataControlFieldDesigner> dictionary = new Dictionary <Type, DataControlFieldDesigner>(); ITypeDiscoveryService service = (ITypeDiscoveryService)control.Site.GetService(typeof(ITypeDiscoveryService)); if (service != null) { foreach (Type type in service.GetTypes(typeof(DataControlField), false)) { DesignerAttribute customAttribute = (DesignerAttribute)Attribute.GetCustomAttribute(type, typeof(DesignerAttribute)); if (customAttribute != null) { Type type2 = Type.GetType(customAttribute.DesignerTypeName, false, true); if ((type2 != null) && type2.IsSubclassOf(typeof(DataControlFieldDesigner))) { try { DataControlFieldDesigner designer = (DataControlFieldDesigner)Activator.CreateInstance(type2); if (designer.IsEnabled(control)) { designer.DesignerForm = designerForm; dictionary.Add(type, designer); } } catch { } } } } } return(dictionary); }
public void Ctor_Type(Type designerType) { var attribute = new DesignerAttribute(designerType); Assert.Equal(designerType.AssemblyQualifiedName, attribute.DesignerTypeName); Assert.Equal("System.ComponentModel.Design.IDesigner, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", attribute.DesignerBaseTypeName); }
public void TypeId_Get_ReturnsExcepted(string designerBaseTypeName, object expected) { var attribute = new DesignerAttribute("SerializerType", designerBaseTypeName); Assert.Equal(expected, attribute.TypeId); Assert.Same(attribute.TypeId, attribute.TypeId); }
private void OnComponentAdding(object sender, ComponentEventArgs eventArgs) { //We are adding root component, while doing this make sure that we provide the root designer attribute IDesignerHost designerHost = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost)); if (designerHost != null) { if (designerHost.RootComponent == null) { Activity rootActivity = eventArgs.Component as Activity; if (rootActivity != null) { //Add root designer attribute DesignerAttribute rootDesignerAttrib = GetDesignerAttribute(rootActivity, typeof(IRootDesigner)); if (rootDesignerAttrib.DesignerTypeName == typeof(ActivityDesigner).AssemblyQualifiedName) { DesignerAttribute designerAttrib = GetDesignerAttribute(rootActivity, typeof(IDesigner)); if (designerAttrib != null) { TypeDescriptor.AddAttributes(rootActivity, new Attribute[] { new DesignerAttribute(designerAttrib.DesignerTypeName, typeof(IRootDesigner)) }); } } } } } }
public void Equals_Object_ReturnsExpected(DesignerAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is DesignerAttribute otherAttribute && attribute.DesignerBaseTypeName != null && otherAttribute.DesignerBaseTypeName != null) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
[Test] // ctor (Type) public void Constructor2() { DesignerAttribute da = new DesignerAttribute(typeof(string)); Assert.AreEqual(typeof(IDesigner).FullName, da.DesignerBaseTypeName, "#1"); Assert.AreEqual(typeof(string).AssemblyQualifiedName, da.DesignerTypeName, "#2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#3"); }
public void Equals_Object_ReturnsExpected(DesignerAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is DesignerAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
DesignerAttribute GetDesignerAttribute(Type type) { DesignerAttribute designerAttribute = null; //do not return designers for IValueSerializableExpression (i.e. VisualBasicValue or VisualBasicReference if (!typeof(IValueSerializableExpression).IsAssignableFrom(type)) { designerAttribute = GetAttribute <DesignerAttribute>(type); } return(designerAttribute); }
private static DesignerAttribute GetDesignerAttribute(object component, System.Type designerBaseType) { foreach (Attribute attribute in TypeDescriptor.GetAttributes(component)) { DesignerAttribute attribute2 = attribute as DesignerAttribute; if ((attribute2 != null) && (attribute2.DesignerBaseTypeName == designerBaseType.AssemblyQualifiedName)) { return(attribute2); } } return(null); }
// Since most of the specific designers are missing this temporary method // will fallback to the first available designer type in the type's base types // private IDesigner CreateDesigner(IComponent component, Type designerBaseType) { IDesigner instance = null; AttributeCollection attributes = TypeDescriptor.GetAttributes(component); foreach (Attribute attribute in attributes) { DesignerAttribute designerAttr = attribute as DesignerAttribute; if (designerAttr != null && (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { Type type = Type.GetType(designerAttr.DesignerTypeName); if (type == null && designerBaseType == typeof(IRootDesigner)) { type = typeof(System.Windows.Forms.Design.DocumentDesigner); } if (type != null) { instance = (IDesigner)Activator.CreateInstance(type); } break; } } if (instance == null) { Type baseType = component.GetType().BaseType; do { attributes = TypeDescriptor.GetAttributes(baseType); foreach (Attribute attribute in attributes) { DesignerAttribute designerAttr = attribute as DesignerAttribute; if (designerAttr != null && (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { Type type = Type.GetType(designerAttr.DesignerTypeName); if (type != null) { instance = (IDesigner)Activator.CreateInstance(type); } break; } } baseType = baseType.BaseType; }while (instance == null && baseType != null); } return(instance); }
public void TypeId_NullDesignerDesignerTypeName_ThrowsNullReferenceException() { var attribute = new DesignerAttribute("DesignerType", (string)null); if (!PlatformDetection.IsFullFramework) { Assert.Equal("System.ComponentModel.DesignerAttribute", attribute.TypeId); } else { Assert.Throws <NullReferenceException>(() => attribute.TypeId); } }
private static bool ModelItemHasDesigner(ModelItem modelItem) { if (modelItem != null) { DesignerAttribute attribute = WorkflowViewService.GetAttribute <DesignerAttribute>(modelItem.ItemType); if (attribute != null && !string.IsNullOrEmpty(attribute.DesignerTypeName)) { return(true); } } return(false); }
public void Constructor3_DesignerBaseType_Null() { DesignerAttribute da = new DesignerAttribute( "CategoryType", (string)null); Assert.IsNull(da.DesignerBaseTypeName, "#1"); Assert.AreEqual("CategoryType", da.DesignerTypeName, "#2"); try { object typeId = da.TypeId; Assert.Fail("#3: " + typeId); } catch (NullReferenceException) { } }
[Test] // ctor (Type, Type) public void Constructor5() { DesignerAttribute da; da = new DesignerAttribute(typeof(int), typeof(string)); Assert.AreEqual(typeof(string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#A1"); Assert.AreEqual(typeof(int).AssemblyQualifiedName, da.DesignerTypeName, "#A2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + typeof(string).FullName, da.TypeId, "#A3"); da = new DesignerAttribute(typeof(string), typeof(int)); Assert.AreEqual(typeof(int).AssemblyQualifiedName, da.DesignerBaseTypeName, "#B1"); Assert.AreEqual(typeof(string).AssemblyQualifiedName, da.DesignerTypeName, "#B2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + typeof(int).FullName, da.TypeId, "#B3"); }
private static DesignerAttribute GetDesignerAttribute(object component, Type designerBaseType) { AttributeCollection attribs = TypeDescriptor.GetAttributes(component); foreach (Attribute attribute in attribs) { DesignerAttribute designerAttribute = attribute as DesignerAttribute; if (designerAttribute != null && designerAttribute.DesignerBaseTypeName == designerBaseType.AssemblyQualifiedName) { return(designerAttribute); } } return(null); }
private void OnComponentAdding(object sender, ComponentEventArgs eventArgs) { IDesignerHost service = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost)); if ((service != null) && (service.RootComponent == null)) { Activity component = eventArgs.Component as Activity; if ((component != null) && (GetDesignerAttribute(component, typeof(IRootDesigner)).DesignerTypeName == typeof(ActivityDesigner).AssemblyQualifiedName)) { DesignerAttribute designerAttribute = GetDesignerAttribute(component, typeof(IDesigner)); if (designerAttribute != null) { TypeDescriptor.AddAttributes(component, new Attribute[] { new DesignerAttribute(designerAttribute.DesignerTypeName, typeof(IRootDesigner)) }); } } } }
public bool FilterAttributes(System.ComponentModel.IComponent component, System.Collections.IDictionary attributes) { if (oldService != null) { oldService.FilterAttributes(component, attributes); } // Creates a designer attribute to compare its TypeID with the TypeID of existing attributes of the component. DesignerAttribute da = new DesignerAttribute(typeof(ColorCycleButtonDesigner)); // Adds the designer attribute if the attribute collection does not contain a DesignerAttribute of the same TypeID. if (component is System.Windows.Forms.Button && attributes.Contains(da.TypeId)) { attributes[da.TypeId] = da; } return(true); }
// </Snippet1> // <Snippet2> public static int Main() { // Creates a new form. MyForm myNewForm = new MyForm(); // Gets the attributes for the collection. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm); /* Prints the name of the designer by retrieving the DesignerAttribute * from the AttributeCollection. */ DesignerAttribute myAttribute = (DesignerAttribute)attributes[typeof(DesignerAttribute)]; Console.WriteLine("The designer for this class is: " + myAttribute.DesignerTypeName); return(0); }
[Test] // ctor (String, String) public void Constructor3() { DesignerAttribute da; da = new DesignerAttribute("Mono.Components.CategoryType", "Mono.Design.CompositeAttribute"); Assert.AreEqual("Mono.Design.CompositeAttribute", da.DesignerBaseTypeName, "#A1"); Assert.AreEqual("Mono.Components.CategoryType", da.DesignerTypeName, "#A2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#A3"); da = new DesignerAttribute("CategoryType", "CompositeAttribute"); Assert.AreEqual("CompositeAttribute", da.DesignerBaseTypeName, "#B1"); Assert.AreEqual("CategoryType", da.DesignerTypeName, "#B2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + da.DesignerBaseTypeName, da.TypeId, "#B3"); da = new DesignerAttribute(string.Empty, string.Empty); Assert.AreEqual(string.Empty, da.DesignerBaseTypeName, "#C1"); Assert.AreEqual(string.Empty, da.DesignerTypeName, "#C2"); Assert.AreEqual(typeof(DesignerAttribute).FullName, da.TypeId, "#C3"); }
[Test] // ctor (String, Type) public void Constructor4() { DesignerAttribute da; da = new DesignerAttribute("Mono.Components.CategoryType", typeof(string)); Assert.AreEqual(typeof(string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#A1"); Assert.AreEqual("Mono.Components.CategoryType", da.DesignerTypeName, "#A2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + typeof(string).FullName, da.TypeId, "#A3"); da = new DesignerAttribute("CategoryType", typeof(int)); Assert.AreEqual(typeof(int).AssemblyQualifiedName, da.DesignerBaseTypeName, "#B1"); Assert.AreEqual("CategoryType", da.DesignerTypeName, "#B2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + typeof(int).FullName, da.TypeId, "#B3"); da = new DesignerAttribute(string.Empty, typeof(string)); Assert.AreEqual(typeof(string).AssemblyQualifiedName, da.DesignerBaseTypeName, "#C1"); Assert.AreEqual(string.Empty, da.DesignerTypeName, "#C2"); Assert.AreEqual(typeof(DesignerAttribute).FullName + typeof(string).FullName, da.TypeId, "#C3"); }
public void Register() { var builder = new AttributeTableBuilder(); // Designers var simpleClassifierDesigner = new DesignerAttribute(typeof(SimpleClassifierDesigner)); var simpleExtractorDesigner = new DesignerAttribute(typeof(SimpleExtractorDesigner)); //Categories var classifierCategoryAttribute = new CategoryAttribute("Sample Classifiers"); var extractorCategoryAttribute = new CategoryAttribute("Sample Extractors"); builder.AddCustomAttributes(typeof(SimpleClassifier), classifierCategoryAttribute); builder.AddCustomAttributes(typeof(SimpleClassifier), simpleClassifierDesigner); builder.AddCustomAttributes(typeof(SimpleExtractor), extractorCategoryAttribute); builder.AddCustomAttributes(typeof(SimpleExtractor), simpleExtractorDesigner); MetadataStore.AddAttributeTable(builder.CreateTable()); }
public static ComponentDesigner GetComponentDesignerForType(ITypeResolutionService tr, System.Type type) { ComponentDesigner designer = null; DesignerAttribute attribute = null; AttributeCollection attributes = TypeDescriptor.GetAttributes(type); for (int i = 0; i < attributes.Count; i++) { DesignerAttribute attribute2 = attributes[i] as DesignerAttribute; if (attribute2 != null) { System.Type type2 = System.Type.GetType(attribute2.DesignerBaseTypeName); if ((type2 != null) && (type2 == iDesignerType)) { attribute = attribute2; break; } } } if (attribute != null) { System.Type c = null; if (tr != null) { c = tr.GetType(attribute.DesignerTypeName); } else { c = System.Type.GetType(attribute.DesignerTypeName); } if ((c != null) && typeof(ComponentDesigner).IsAssignableFrom(c)) { designer = (ComponentDesigner)Activator.CreateInstance(c); } } return(designer); }
public static IEnumerable <object[]> Equals_TestData() { var attribute = new DesignerAttribute("designerTypeName", "designerBaseTypeName"); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new DesignerAttribute("designerTypeName", "designerBaseTypeName"), true }); yield return(new object[] { attribute, new DesignerAttribute("designertypename", "designerBaseTypeName"), false }); yield return(new object[] { attribute, new DesignerAttribute("designerTypeName", "designerbasetypename"), false }); yield return(new object[] { attribute, new DesignerAttribute("designerTypeName", (string)null), false }); yield return(new object[] { new DesignerAttribute("designerTypeName", (string)null), new DesignerAttribute("designerTypeName", (string)null), true }); yield return(new object[] { new DesignerAttribute("designerTypeName", (string)null), new DesignerAttribute("designertypename", (string)null), false }); yield return(new object[] { new DesignerAttribute("designerTypeName", (string)null), new DesignerAttribute("designerTypeName", "designertBaseTypeName"), false }); yield return(new object[] { attribute, new object(), false }); yield return(new object[] { attribute, null, false }); }
internal Type GetDesignerType(Type type, bool throwOnFailure) { Type designerType = null; // Try to identify a designer using the DesignerAttribute, either on the type or from MetaDataStore DesignerAttribute designerAttribute = GetDesignerAttribute(type); if (designerAttribute != null && !String.IsNullOrEmpty(designerAttribute.DesignerTypeName)) { designerType = Type.GetType(designerAttribute.DesignerTypeName, throwOnFailure); //if we have generic activity, check if there is a designer defined at type definition i.e. Assign<T>, //rather then using a default one (which happens to be ActivityDesigner) if (type.IsGenericType && Type.Equals(designerType, typeof(ActivityDesigner))) { Type genericType = type.GetGenericTypeDefinition(); DesignerAttribute genericDesignerAttribute = TypeDescriptor.GetAttributes(genericType)[typeof(DesignerAttribute)] as DesignerAttribute; designerType = (null == genericDesignerAttribute ? designerType : Type.GetType(genericDesignerAttribute.DesignerTypeName, throwOnFailure)); } } return(designerType); }
// Temp method to fallback to searching base type of component for a designer, // because I am missing quite a few specific (most of which cosmetic) designers // private IDesigner CreateDesigner(IComponent component, Type designerBaseType) { IDesigner instance = null; AttributeCollection attributes = TypeDescriptor.GetAttributes(component); foreach (Attribute attribute in attributes) { DesignerAttribute designerAttr = attribute as DesignerAttribute; /* * if (designerAttr != null) { * Console.WriteLine (component.GetType().Name); * Console.WriteLine (designerAttr.DesignerBaseTypeName); * Console.WriteLine (designerBaseType.FullName); * } */ if (designerAttr != null && (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { Type type = this.GetDesignerType(designerAttr.DesignerTypeName); if (type != null) { instance = (IDesigner)Activator.CreateInstance(type); } break; } } if (instance == null) { Type baseType = component.GetType().BaseType; do { attributes = TypeDescriptor.GetAttributes(baseType); foreach (Attribute attribute in attributes) { DesignerAttribute designerAttr = attribute as DesignerAttribute; /* * if (designerAttr != null) { * Console.WriteLine (component.GetType().Name); * Console.WriteLine (designerAttr.DesignerBaseTypeName); * Console.WriteLine (designerBaseType.FullName); * } */ if (designerAttr != null && (designerBaseType.FullName == designerAttr.DesignerBaseTypeName || designerBaseType.AssemblyQualifiedName == designerAttr.DesignerBaseTypeName)) { Type type = this.GetDesignerType(designerAttr.DesignerTypeName); if (type != null) { instance = (IDesigner)Activator.CreateInstance(type); } break; } } baseType = baseType.BaseType; } while (instance == null && baseType != null); } return(instance); }
// Loads the new ITypeDescriptorFilterService and reloads the // designers for each button. public override void Initialize(System.ComponentModel.IComponent component) { base.Initialize(component); // Loads the custom service if it has not been loaded already LoadService(); // Build list of buttons from Container.Components. ArrayList buttons = new ArrayList(); foreach (IComponent c in this.Component.Site.Container.Components) { if (c.GetType() == typeof(System.Windows.Forms.Button)) { buttons.Add((System.Windows.Forms.Button)c); } } if (buttons.Count > 0) { // Tests each Button for an existing // ColorCycleButtonDesigner; // if it has no designer of type // ColorCycleButtonDesigner, adds a designer. foreach (System.Windows.Forms.Button b in buttons) { bool loaddesigner = true; // Gets the attributes for each button. AttributeCollection ac = TypeDescriptor.GetAttributes(b); for (int i = 0; i < ac.Count; i++) { // If designer attribute is not for a // ColorCycleButtonDesigner, adds a new // ColorCycleButtonDesigner. if (ac[i] is DesignerAttribute) { DesignerAttribute da = (DesignerAttribute)ac[i]; if (da.DesignerTypeName.Substring(da.DesignerTypeName.LastIndexOf(".") + 1) == "ColorCycleButtonDesigner") { loaddesigner = false; } } } if (loaddesigner) { // Saves the button location so that it // can be repositioned. Point p = b.Location; // Gets an IMenuCommandService to cut and // paste control in order to register with // selection and movement interface after // designer is changed without reloading. IMenuCommandService imcs = (IMenuCommandService)this.GetService(typeof(IMenuCommandService)); if (imcs == null) { throw new Exception("Could not obtain IMenuCommandService interface."); } // Gets an ISelectionService to select the // button so that it can be cut and pasted. ISelectionService iss = (ISelectionService)this.GetService(typeof(ISelectionService)); if (iss == null) { throw new Exception("Could not obtain ISelectionService interface."); } iss.SetSelectedComponents(new IComponent[] { b }, SelectionTypes.Auto); // Invoke Cut and Paste. imcs.GlobalInvoke(StandardCommands.Cut); imcs.GlobalInvoke(StandardCommands.Paste); // Regains reference to button from // selection service. System.Windows.Forms.Button b2 = (System.Windows.Forms.Button)iss.PrimarySelection; iss.SetSelectedComponents(null); // Refreshes TypeDescriptor properties of // button to load new attributes from // ButtonDesignerFilterService. TypeDescriptor.Refresh(b2); b2.Location = p; b2.Focus(); } } } }
public bool RunWizard(Dictionary <string, string> replacementsDictionary) { bool bOK; DataTypePointer dtp = DesignUtil.SelectDataType(_prj, null, null, EnumObjectSelectType.BaseClass, null, null, null, null); if (dtp != null) { //for non-generic type: // $typevalues$ is empty // $typeparameters$ is empty // $typeDefinition$ is empty // $ObjectType$ = $typeName$ = name // $qualifiedTypeName$ = t.AssemblyQualifiedName // $typeFileName$ = t.Assembly.Location //for generic type: // $ObjectType$ = $typeName$ = classBaseTypeName = name+"A" // $typeparameters$=<Item for t, type=name><Item for each generic type parameter><Item for each type argument> // $qualifiedTypeName$ = empty // $typeDefinition$ = name // $typevalues$ = <TypeParameter for each type argument> StringBuilder sbTypes = new StringBuilder(); StringBuilder sbValues = new StringBuilder(); Type t = dtp.ObjectType; Type tBase = t; // string name = XmlUtility.XmlUtil.CheckCreateTypeName(t); string classBaseTypeName = name; string fullTypename = t.AssemblyQualifiedName; string typeDefName = string.Empty; string fileLocation = t.Assembly.Location; if (t.IsGenericType) { typeDefName = name; fullTypename = string.Empty; fileLocation = string.Empty; classBaseTypeName = string.Format(CultureInfo.InvariantCulture, "{0}A", name); tBase = t.GetGenericTypeDefinition(); Type[] targs = t.GetGenericArguments(); string[] pnames = new string[targs.Length]; sbTypes.Append("<Item type=\""); sbTypes.Append(name); sbTypes.Append("\" fullTypeName=\""); sbTypes.Append(t.AssemblyQualifiedName); sbTypes.Append("\" filename=\""); sbTypes.Append(t.Assembly.Location); sbTypes.Append("\" />"); if (targs != null && targs.Length > 0) { for (int i = 0; i < targs.Length; i++) { sbTypes.Append("<Item ownerTypeName=\""); sbTypes.Append(name); sbTypes.Append("\" typeName=\""); sbTypes.Append(targs[i].Name); sbTypes.Append("\" type=\""); pnames[i] = XmlUtility.XmlUtil.CheckCreateTypeName(targs[i]); sbTypes.Append(pnames[i]); sbTypes.Append("\" />"); } } if (dtp.TypeParameters != null) { for (int i = 0; i < dtp.TypeParameters.Length; i++) { sbValues.Append("<TypeParameter "); sbTypes.Append("<Item "); if (dtp.TypeParameters[i].IsLibType) { string argname = XmlUtility.XmlUtil.CheckCreateTypeName(dtp.TypeParameters[i].BaseClassType); sbValues.Append("type=\""); sbValues.Append(argname); sbValues.Append("\" />"); // sbTypes.Append("type=\""); sbTypes.Append(argname); sbTypes.Append("\" fullTypeName=\""); sbTypes.Append(dtp.TypeParameters[i].BaseClassType.AssemblyQualifiedName); sbTypes.Append("\""); if (!dtp.TypeParameters[i].BaseClassType.Assembly.GlobalAssemblyCache) { sbTypes.Append(" filename=\""); sbTypes.Append(dtp.TypeParameters[i].BaseClassType.Assembly.Location); sbTypes.Append("\""); } sbTypes.Append(">"); } else { string argname = string.Format(CultureInfo.InvariantCulture, "class{0}", dtp.TypeParameters[i].ClassId); sbValues.Append("type=\""); sbValues.Append(argname); sbValues.Append("\" />"); // sbTypes.Append("type=\""); sbTypes.Append(argname); sbTypes.Append("\" "); sbTypes.Append(XmlTags.XMLATT_ClassID); sbTypes.Append("=\""); sbTypes.Append(dtp.TypeParameters[i].ClassId); sbTypes.Append("\" "); sbTypes.Append(XmlTags.XMLATT_guid); sbTypes.Append("=\""); sbTypes.Append(_prj.ProjectGuid.ToString("N", CultureInfo.InvariantCulture)); sbTypes.Append("\">"); } sbTypes.Append("</Item>"); } } } replacementsDictionary.Add("$qualifiedTypeName$", fullTypename); replacementsDictionary.Add("$typeName$", classBaseTypeName); replacementsDictionary.Add("$typeFileName$", fileLocation); replacementsDictionary.Add("$typeDefinition$", typeDefName); bool hasTopDesigner = false; object[] vs = t.GetCustomAttributes(typeof(DesignerAttribute), true); if (vs != null && vs.Length > 0) { for (int j = 0; j < vs.Length; j++) { DesignerAttribute da = (DesignerAttribute)vs[j]; Type td = Type.GetType(da.DesignerTypeName); if (td != null) { if (td.GetInterface("IRootDesigner") != null) { hasTopDesigner = true; break; } } } } if (t.GetInterface("IComponent") != null && hasTopDesigner) { replacementsDictionary["$ObjectType$"] = classBaseTypeName; } else { if (typeof(Control).IsAssignableFrom(t)) { replacementsDictionary["$ObjectType$"] = string.Format(System.Globalization.CultureInfo.InvariantCulture, "VPL.XControl`1[[{0}]]", classBaseTypeName); } else { replacementsDictionary["$ObjectType$"] = string.Format(System.Globalization.CultureInfo.InvariantCulture, "VPL.XClass`1[[{0}]]", classBaseTypeName); } } replacementsDictionary.Add("$BaseClassId$", dtp.ClassId.ToString()); replacementsDictionary.Add("$typevalues$", sbValues.ToString()); replacementsDictionary.Add("$typeparameters$", sbTypes.ToString()); bOK = true; } else { bOK = false; } return(bOK); }
public void DesignerAttributes_DesignerAttribute_TypeExists(Type annotatedType, DesignerAttribute attribute) { var type = Type.GetType(attribute.DesignerTypeName, false); _output.WriteLine($"{annotatedType.FullName}: {attribute.DesignerTypeName} --> {type?.FullName}"); if (SkipList.Contains(attribute.DesignerTypeName)) { Assert.Null(type); return; } Assert.NotNull(type); }