public AddBaseType(CsType type, string name) { Contract.Requires(type != null, "type is null"); Contract.Requires(!string.IsNullOrEmpty(name), "name is null or empty"); m_type = type; m_name = name; }
public ResolvedTarget(string typeName, CsType type, bool isInstance, bool isStatic) { Contract.Requires(!string.IsNullOrEmpty(typeName), "typeName is null or empty"); Contract.Requires(isInstance || isStatic, "at least one of isInstance and isStatic should be true"); TypeName = typeName; Type = type; IsInstance = isInstance; IsStatic = isStatic; }
private object DoAddMember(CsType type, string text) { return new AddMember(type, text.Split('\n')); }
private object DoHasMember(CsType type, string name, object[] inTypes) { string[] types = new string[inTypes.Length]; for (int i = 0; i < inTypes.Length; ++i) { if (inTypes[i] == null) throw new Exception(string.Format("Type #{0} is null.", i)); string n = inTypes[i] as string; if (n == null) throw new Exception(string.Format("Type #{0} is a {1}, but should be a String.", i, RefactorType.GetName(inTypes[i].GetType()))); types[i] = n; } if (types.Length == 0) if (DoHasEnum(type.Enums, name) || DoHasEvent(type.Events, name) || DoHasField(type.Fields, name) || DoHasProperty(type.Properties, name)) return true; return DoHasDelegate(type.Delegates, name, types) || DoHasIndexer(type.Indexers, name, types) || DoHasMethod(type.Methods, name, types) || DoHasOperator(type.Operators, name, types); }
private object DoGetProperties(CsType type) { return type.Properties; }
private object DoGetName(CsType type) { return type.Name; }
private object DoGetMethods(CsType type) { return type.Methods; }
private object DoGetIsStatic(CsType type) { return (type.Modifiers & MemberModifiers.Static) == MemberModifiers.Static; }
private object DoGetFields(CsType type) { return type.Fields; }
private object DoGetEvents(CsType type) { return type.Events; }
private object DoGetDeclaringType(CsType type) { return type.DeclaringType; }
private object DoGetConstraints(CsType type) { return type.Constraints; }
private object DoGetBases(CsType type) { return type.Bases.Names; }
private object DoGetAttributes(CsType type) { return type.Attributes; }
private object DoGetAccess(CsType type) { return type.Access.ToString().ToLower(); }
private object DoGetIsProtected(CsType type) { return (type.Modifiers & MemberModifiers.Protected) == MemberModifiers.Protected; }
private object DoGetIsSealed(CsType type) { if (type is CsStruct) return true; else return (type.Modifiers & MemberModifiers.Sealed) == MemberModifiers.Sealed; }
private object DoGetFullName(CsType type) { return type.FullName; }
private object DoGetMembers(CsType type) { return type.Members; }
private object DoGetGenericArguments(CsType type) { return type.GenericArguments; }
private object DoGetModifiers(CsType type) { return type.Modifiers.ToString().ToLower(); }
private object DoGetIndexers(CsType type) { return type.Indexers; }
private object DoGetOperators(CsType type) { return type.Operators; }
private object DoGetIsAbstract(CsType type) { return (type.Modifiers & MemberModifiers.Abstract) == MemberModifiers.Abstract; }
private object DoGetUniqueName(CsType type, string inName) { string name = inName; for (int i = 2; i < 102; ++i) { if (!type.Members.Any(d => d.Name == name)) // TODO: might want to use the db to check base types return name; name = inName + i; } throw new Exception("Couldn't find a unique name after 100 tries."); }
private object DoGetIsInternal(CsType type) { return (type.Modifiers & MemberModifiers.Internal) == MemberModifiers.Internal; }
public AddMember(CsType type, params string[] lines) { m_type = type; m_lines = DoMungeLines(lines); }
private object DoGetIsPartial(CsType type) { return (type.Modifiers & MemberModifiers.Partial) == MemberModifiers.Partial; }
private object DoGetIsPrivate(CsType type) { return (type.Modifiers & MemberModifiers.Private) == MemberModifiers.Private; }
private object DoAddBase(CsType type, string name) { return new AddBaseType(type, name); }