public CodeIdentifier(string value) { this.type = CodeIdentifierType.None; this.identifier = value; this.assembly = string.Empty; this.item = string.Empty; this.member = string.Empty; value = value.Trim(); value = value.Replace("%20", " "); value = value.Replace("%5b", "["); value = value.Replace("%5d", "]"); string codeIdentifier = "code://"; if (value.StartsWith(codeIdentifier)) { value = value.Substring(codeIdentifier.Length); while (value.EndsWith("/")) { value = value.Substring(0, value.Length - 1); } string[] parts = value.Split(new char[] { '/' }); if (parts.Length > 0) { this.assembly = parts[0]; this.type = CodeIdentifierType.Assembly; if (parts.Length > 1) { if (parts[1].StartsWith("resource:")) { this.item = parts[1].Substring(9); this.type = CodeIdentifierType.Resource; } else if (parts[1].StartsWith("module:")) { this.item = parts[1].Substring(7); this.type = CodeIdentifierType.Module; } else { this.item = parts[1]; this.type = CodeIdentifierType.Type; if (parts.Length > 2) { if (parts[2].StartsWith("property:")) { this.member = parts[2].Substring(9); this.type = CodeIdentifierType.Property; } else if (parts[2].StartsWith("event:")) { this.member = parts[2].Substring(6); this.type = CodeIdentifierType.Event; } else { if ((parts[2].IndexOf("(") != -1) && (parts[2].IndexOf(")") != -1)) { this.member = parts[2]; this.type = CodeIdentifierType.Method; } else { this.member = parts[2]; this.type = CodeIdentifierType.Field; } } } } } } } }
public CodeIdentifier(string value) { this.type = CodeIdentifierType.None; this.identifier = value; this.assembly = string.Empty; this.item = string.Empty; this.member = string.Empty; value = value.Trim(); value = value.Replace("%20", " "); value = value.Replace("%5b", "["); value = value.Replace("%5d", "]"); string codeIdentifier = "code://"; if (value.StartsWith(codeIdentifier)) { value = value.Substring(codeIdentifier.Length); while (value.EndsWith("/")) { value = value.Substring(0, value.Length - 1); } string[] parts = value.Split(new char[] { '/' }); if (parts.Length > 0) { this.assembly = parts[0]; this.type = CodeIdentifierType.Assembly; if (parts.Length > 1) { if (parts[1].StartsWith("resource:")) { this.item = parts[1].Substring(9); this.type = CodeIdentifierType.Resource; } else if (parts[1].StartsWith("module:")) { this.item = parts[1].Substring(7); this.type = CodeIdentifierType.Module; } else { this.item = parts[1]; this.type = CodeIdentifierType.Type; if (parts.Length > 2) { if (parts[2].StartsWith("property:")) { this.member = parts[2].Substring(9); this.type = CodeIdentifierType.Property; } else if (parts[2].StartsWith("event:")) { this.member = parts[2].Substring(6); this.type = CodeIdentifierType.Event; } else { if ((parts[2].IndexOf("(") != -1) && (parts[2].IndexOf(")") != -1)) { this.member = parts[2]; this.type = CodeIdentifierType.Method; } else { this.member = parts[2]; this.type = CodeIdentifierType.Field; } } } } } } } }
public CodeIdentifier(object value) { this.type = CodeIdentifierType.None; this.identifier = string.Empty; this.assembly = string.Empty; this.item = string.Empty; this.member = string.Empty; if (value is IAssemblyReference) { this.assembly = this.GetAssemblyReferenceText(value as IAssemblyReference); this.type = CodeIdentifierType.Assembly; } if (value is IModule) { IModule module = (IModule)value; this.assembly = this.GetAssemblyReferenceText(module.Assembly); this.item = module.Name; this.type = CodeIdentifierType.Module; } if (value is IResource) { IResource resource = (IResource)value; this.assembly = this.GetAssemblyReferenceText(resource.Module.Assembly); this.item = resource.Name; this.type = CodeIdentifierType.Resource; } if (value is ITypeReference) { ITypeReference typeReference = (ITypeReference)value; this.SetTypeDeclaration(typeReference); this.type = CodeIdentifierType.Type; } if (value is IMemberReference) { IMemberReference memberReference = (IMemberReference)value; this.SetTypeDeclaration(memberReference.DeclaringType); if (value is IFieldReference) { this.member = this.GetFieldReferenceText(value as IFieldReference); this.type = CodeIdentifierType.Field; } if (value is IMethodReference) { this.member = this.GetMethodReferenceText(value as IMethodReference); this.type = CodeIdentifierType.Method; } if (value is IPropertyReference) { this.member = this.GetPropertyReferenceText(value as IPropertyReference); this.type = CodeIdentifierType.Property; } if (value is IEventReference) { this.member = this.GetEventReferenceText(value as IEventReference); this.type = CodeIdentifierType.Event; } } }
public CodeIdentifier(object value) { this.type = CodeIdentifierType.None; this.identifier = string.Empty; this.assembly = string.Empty; this.item = string.Empty; this.member = string.Empty; if (value is IAssemblyReference) { this.assembly = this.GetAssemblyReferenceText(value as IAssemblyReference); this.type = CodeIdentifierType.Assembly; } if (value is IModule) { IModule module = (IModule)value; this.assembly = this.GetAssemblyReferenceText(module.Assembly); this.item = module.Name; this.type = CodeIdentifierType.Module; } if (value is IResource) { IResource resource = (IResource)value; this.assembly = this.GetAssemblyReferenceText(resource.Module.Assembly); this.item = resource.Name; this.type = CodeIdentifierType.Resource; } if (value is ITypeReference) { ITypeReference typeReference = (ITypeReference)value; this.SetTypeDeclaration(typeReference); this.type = CodeIdentifierType.Type; } if (value is IMemberReference) { IMemberReference memberReference = (IMemberReference)value; this.SetTypeDeclaration(memberReference.DeclaringType); if (value is IFieldReference) { this.member = this.GetFieldReferenceText(value as IFieldReference); this.type = CodeIdentifierType.Field; } if (value is IMethodReference) { this.member = this.GetMethodReferenceText(value as IMethodReference); this.type = CodeIdentifierType.Method; } if (value is IPropertyReference) { this.member = this.GetPropertyReferenceText(value as IPropertyReference); this.type = CodeIdentifierType.Property; } if (value is IEventReference) { this.member = this.GetEventReferenceText(value as IEventReference); this.type = CodeIdentifierType.Event; } } }