internal static CustomAttributeTypedArgument LoadEnumValue( IBinaryAccessor accessor, Module module, TypeReference typeRef, bool isArray, int arrayLength) { var type = typeRef.Resolve(module); if (type == null) { throw new InvalidDataException(); } if (type.Fields.Count == 0) { throw new InvalidDataException(); } // First value of enum is __value field. var firstField = type.Fields[0]; var typeCode = ((IFieldSignature)firstField).FieldType.GetTypeCode(type.Module); if (typeCode == PrimitiveTypeCode.Undefined) { throw new InvalidDataException(); } int elementType = CodeModelUtils.GetElementType(typeCode); return(Load(accessor, module, elementType, isArray, arrayLength)); }
private void PrintDeclaringType(Type type, bool ignoreOwner) { if (type.IsNested) { PrintDeclaringType(type.DeclaringType, ignoreOwner); _builder.Append("/"); } else if (!ignoreOwner) { _builder.Append("["); var module = type.Module; var assembly = module.Assembly; if (module == assembly.ManifestModule) { PrintAssembly(assembly); } else { PrintModule(module); } _builder.Append("]"); } PrintIdentifier(CodeModelUtils.GetTypeName(type.Name, type.Namespace)); }
private void PropertyMapperDialog_Shown(object sender, EventArgs e) { CodeParameter2 fromParameter = m_currentMethod.Parameters.Item(1) as CodeParameter2; string returnType = m_currentMethod.Type.AsFullName; string fromType = fromParameter.Type.AsFullName; lblFromClass.Text = fromType; lblToClass.Text = returnType; try { InitListView(lstFromProperties, CodeModelUtils.GetPropertiesFromType(fromParameter.Type.CodeType)); } catch (NotImplementedException) { AddInUtils.ShowError("The method parameter '" + fromParameter.Type.AsString + "' could not be found in the code model. Please be sure the type exists and the project has been successfully built."); this.DialogResult = DialogResult.Cancel; } try { InitListView(lstToProperties, CodeModelUtils.GetPropertiesFromType(m_currentMethod.Type.CodeType)); } catch (NotImplementedException) { AddInUtils.ShowError("The method return type '" + m_currentMethod.Type.AsString + "' could not be found in the code model. Please be sure the type exists and the project has been successfully built."); this.DialogResult = DialogResult.Cancel; } //InitTreeView(treeView1, CodeModelUtils.GetPropertiesFromType(fromParameter.Type.CodeType)); RefreshView(); if (m_addInSettings.PropertyMapperAutoMapOnOpen) { AutoMap(); } }
private void PrintDeclaringType(ITypeSignature typeSig, IModule module, bool ignoreOwner) { var owner = typeSig.Owner; if (owner != null) { if (owner.SignatureType == SignatureType.Type) { PrintDeclaringType((ITypeSignature)owner, module, ignoreOwner); _builder.Append("/"); } else if (!ignoreOwner) { PrintResolutionScope(owner); } } else if (!ignoreOwner && module != null) { if (module.IsPrimeModule) { PrintResolutionScope(module.Assembly); } else { PrintResolutionScope(module); } } PrintIdentifier(CodeModelUtils.GetTypeName(typeSig.Name, typeSig.Namespace)); }
internal static CustomAttributeTypedArgument Load( IBinaryAccessor accessor, Module module, TypeReference typeRef, bool isArray, int arrayLength) { var typeCode = typeRef.GetTypeCode(module); if (typeCode != PrimitiveTypeCode.Undefined) { int elementType = CodeModelUtils.GetElementType(typeCode); return(Load(accessor, module, elementType, isArray, arrayLength)); } return(LoadEnumValue(accessor, module, typeRef, isArray, arrayLength)); }
public TypeDeclaration Find(string name, string ns, bool throwIfMissing = false) { foreach (var type in this) { if (type.Name == name && type.Namespace == ns) { return(type); } } if (throwIfMissing) { throw new CodeModelException(string.Format(SR.TypeNotFound, CodeModelUtils.GetTypeName(name, ns))); } return(null); }
public TypeDeclaration FindBackward(string name, string ns, bool throwIfMissing = false) { for (int i = Count - 1; i >= 0; i--) { var type = this[i]; if (type.Name == name && type.Namespace == ns) { return(type); } } if (throwIfMissing) { throw new CodeModelException(string.Format(SR.TypeNotFound, CodeModelUtils.GetTypeName(name, ns))); } return(null); }
private void ProcessType() { var bamlType = (BamlTypeInfo)_state.Node; var type = Resolve(bamlType) as BuildType; if (type == null) { return; } bool changed = false; // Name string name; if (type.NameChanged) { name = type.NewName; changed = true; } else { name = type.Name; } // Namespace string ns; if (type.NamespaceChanged) { ns = type.NewNamespace; changed = true; } else { ns = type.Namespace; } if (changed) { AddMapping(new TypeNameMap(bamlType, CodeModelUtils.GetTypeName(name, ns))); } }
private void ExpandSelectedItem(ListView lst) { if (lst.SelectedItems.Count == 0) { return; } ListViewItem item = lst.SelectedItems[0]; CodeProperty prop = (CodeProperty)item.SubItems[1].Tag; ArrayList properties = CodeModelUtils.GetPropertiesFromType(prop.Type.CodeType); int index = item.Index + 1; foreach (CodeProperty p in properties) { ListViewItem lvi = CreateListViewItem(p); lvi.Name = item.Name + "." + lvi.Text; lvi.ToolTipText = lvi.Name; lvi.IndentCount = item.IndentCount + 1; lst.Items.Insert(index, lvi); index = lst.Items.IndexOf(lvi); } item.ImageIndex = 0; RefreshView(); }
internal static TypeReference GetPrimitiveType(int elementType, Assembly assembly) { return(GetPrimitiveType(CodeModelUtils.GetTypeCode(elementType), assembly)); }