Exemplo n.º 1
0
 private void WriteSimpleMember (SimpleMemberReference member, DisplayOptions options, XmlWriter writer, Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary) {
     MemberTarget target = member.Resolve(targets) as MemberTarget;
     if (target != null) {
         WriteMemberTarget(target, options, writer, dictionary);
     } else {
         TextReferenceUtilities.WriteSimpleMemberReference(member, options, writer, this);
         //throw new InvalidOperationException(String.Format("Unknown member target '{0}'", member.Id));
     }
     
 }
Exemplo n.º 2
0
 internal SpecializedMemberReference (SimpleMemberReference member, SpecializedTypeReference type) {
     if (member == null) throw new ArgumentNullException("member");
     if (type == null) throw new ArgumentNullException("type");
     this.member = member;
     this.type = type;
 }
Exemplo n.º 3
0
 private void WriteSimpleMember (SimpleMemberReference member, DisplayOptions options, XmlWriter writer) {
     WriteSimpleMember(member, options, writer, null);
 }
Exemplo n.º 4
0
        internal static void WriteSimpleMemberReference (SimpleMemberReference member, DisplayOptions options, XmlWriter writer, LinkTextResolver resolver) {
            
            string cer = member.Id;

            string typeCer, memberName, arguments;
            DecomposeMemberIdentifier(cer, out typeCer, out memberName, out arguments);

            if ((options & DisplayOptions.ShowContainer) > 0) {
                SimpleTypeReference type = CreateSimpleTypeReference(typeCer);
                WriteSimpleTypeReference(type, options & ~DisplayOptions.ShowContainer, writer);
            }

            // change this so that we deal with EII names correctly, too
            writer.WriteString(memberName);

            if ((options & DisplayOptions.ShowParameters) > 0) {
                string[] parameterTypeCers;
                if (String.IsNullOrEmpty(arguments)) {
                    Parameter[] parameters = new Parameter[0];
                    resolver.WriteMethodParameters(parameters, writer);
                } else {
                    parameterTypeCers = SeperateTypes(arguments);
                    Parameter[] parameters = new Parameter[parameterTypeCers.Length];
                    for (int i = 0; i < parameterTypeCers.Length; i++) {
                        TypeReference parameterType = CreateTypeReference(parameterTypeCers[i]);
                        if (parameterType == null) {
                            parameterType = new NamedTemplateTypeReference("UAT");
                        }
                        parameters[i] = new Parameter(String.Empty, parameterType);
                    }
                    resolver.WriteMethodParameters(parameters, writer);
                }
            }

        }
Exemplo n.º 5
0
        public static void SetGenericContext (string cer) {
            //Console.WriteLine("context = {0}", cer);

            // re-set the context
            genericTypeContext = null;
            genericMemberContext = null;

            // get the new context
            Reference context = CreateReference(cer);
            if (context == null) return;
            
            // if it is a type context, set it to be the type context
            SimpleTypeReference typeContext = context as SimpleTypeReference;
            if (typeContext != null) {
                genericTypeContext = typeContext;
                return;
            }

            // if it is a member context, set it to be the member context and use it to obtain a type context, too
            SimpleMemberReference memberContext = context as SimpleMemberReference;
            if (memberContext != null) {
                genericMemberContext = memberContext;

                string typeId, memberName, arguments;
                DecomposeMemberIdentifier(memberContext.Id, out typeId, out memberName, out arguments);
                genericTypeContext = CreateSimpleTypeReference(typeId);
                return;
            }

        }
Exemplo n.º 6
0
        public static MemberReference CreateMemberReference (string api) {
            //Console.WriteLine("Testing");
            //Console.WriteLine(tr.ToString());
            //Console.WriteLine(api);
            //Console.WriteLine(tr.IsMatch(api));
            //Console.WriteLine("Tested");
            if (ValidSimpleMember.IsMatch(api)) {
                //Console.WriteLine("Is valid simple member");
                // this is just a normal member of a simple type
                return (new SimpleMemberReference(api));
            } else if (ValidSpecializedMember.IsMatch(api)) {
                //Console.WriteLine("Is valid specialized member");
                //Console.WriteLine("cer = {0}", api);
                // this is a member of a specialized type; we need to extract:
                // (1) the underlying specialized type, (2) the member name, (3) the arguments
                //Console.WriteLine("Extracting data");

                // seperate the member prefix
                int colonPosition = api.IndexOf(':');
                string prefix = api.Substring(0, colonPosition);
                string text = api.Substring(colonPosition + 1);

                // get the arguments
                string arguments = String.Empty;
                int startParenthesisPosition = text.IndexOf('(');
                if (startParenthesisPosition > 0) {
                    int endParenthesisPosition = text.LastIndexOf(')');
                    arguments = text.Substring(startParenthesisPosition + 1, endParenthesisPosition - startParenthesisPosition - 1);
                    text = text.Substring(0, startParenthesisPosition);
                }

                // seperate the type and member name
                int lastDotPosition;
                int firstHashPosition = text.IndexOf('#');
                if (firstHashPosition > 0) {
                    // if this is an EII, the boundry is at the last dot before the hash
                    lastDotPosition = text.LastIndexOf('.', firstHashPosition);
                } else {
                    // otherwise, the boundry is at the last dot
                    lastDotPosition = text.LastIndexOf('.');
                }
                string name = text.Substring(lastDotPosition+1);
                text = text.Substring(0, lastDotPosition);
                //Console.WriteLine("type = {0}", "T:" + text);
        
                // text now contains a specialized generic type; use it to create a reference
                SpecializedTypeReference type = CreateSpecializedTypeReference("T:" + text);

                // If there are no arguments...
                // we simply create a reference to a member whoose identifier we construct in the specialized type
                if (String.IsNullOrEmpty(arguments)) {
                    string typeId = type.Specializations[type.Specializations.Length - 1].TemplateType.Id;
                    string memberId = String.Format("{0}:{1}.{2}", prefix, typeId.Substring(2), name);
                    SimpleMemberReference member = new SimpleMemberReference(memberId);
                    return (new SpecializedMemberReference(member, type));
                }

                // If there are arguments... life is not so simple. We can't be sure we can identify the
                // corresponding member of the template type because any particular type that appears in
                // the argument might have come from the template or it might have come from the specialization.
                // We need to create a special kind of reference to handle this situation.
                //Console.WriteLine("Specialized member with arguments '{0}'", api);
                string[] parameterTypeCers = SeperateTypes(arguments);
                TypeReference[] parameterTypes = new TypeReference[parameterTypeCers.Length];
                for (int i = 0; i < parameterTypeCers.Length; i++) {
                    parameterTypes[i] = CreateTypeReference(parameterTypeCers[i]);
                }
                return (new SpecializedMemberWithParametersReference(prefix, type, name, parameterTypes));

            } else {
                //Console.WriteLine("No match");
                return (null);
                //throw new InvalidOperationException(String.Format("Invalid member '{0}'", api));
            }

        }
Exemplo n.º 7
0
        public static MemberReference CreateMemberReference (XPathNavigator node) {
            string api = node.GetAttribute("api", String.Empty);
            SimpleMemberReference member = new SimpleMemberReference(api);

            bool isSpecialized = (bool)node.Evaluate("boolean(./type//specialization)");
            if (isSpecialized) {
                XPathNavigator typeNode = node.SelectSingleNode("type");
                SpecializedTypeReference type = CreateSpecializedTypeReference(typeNode);
                return( new SpecializedMemberReference(member, type) );
            } else {
                return(member);
            }

        }