Пример #1
0
 internal TypeTemplateTypeReference (SimpleTypeReference template, int position) {
     if (template == null) throw new ArgumentNullException("template");
     if (position < 0) throw new ArgumentOutOfRangeException("position");
     this.template = template;
     this.position = position;
 }
Пример #2
0
 private string GetTypeTemplateName (SimpleTypeReference type, int position) {
     TypeTarget target = type.Resolve(targets) as TypeTarget;
     if (target != null) {
         string[] templates = target.Templates;
         if (templates.Length > position) {
             return (templates[position]);
         } else if (target.OuterType != null) {
             return (GetTypeTemplateName(target.OuterType, position));
         } else {
             return ("UTT");
         }
     } else {
         throw new InvalidOperationException(String.Format("Unknown type reference '{0}'", type.Id));
     }
 }
Пример #3
0
 internal Specialization (SimpleTypeReference template, TypeReference[] arguments) {
     if (template == null) throw new ArgumentNullException("template");
     if (arguments == null) throw new ArgumentNullException("arguments");
     this.template = template;
     this.arguments = arguments;
 }
Пример #4
0
 private void WriteSimpleType (SimpleTypeReference simple, DisplayOptions options, bool showOuterType, XmlWriter writer) {
     TypeTarget type = simple.Resolve(targets) as TypeTarget;
     if (type != null) {
         WriteTypeTarget(type, options, showOuterType, writer);
     } else {
         TextReferenceUtilities.WriteSimpleTypeReference(simple, options, writer);
     }
 }
Пример #5
0
 public void WriteSimpleType (SimpleTypeReference simple, DisplayOptions options, XmlWriter writer) {
     WriteSimpleType(simple, options, true, writer);
 }
Пример #6
0
        internal static void WriteSimpleTypeReference (SimpleTypeReference type, DisplayOptions options, XmlWriter writer) {

            // this logic won't correctly deal with nested types, but type cer strings simply don't include that
            // infomation, so this is out best guess under the assumption of a non-nested type

            string cer = type.Id;

            // get the name
            string name;
            int lastDotPosition = cer.LastIndexOf('.');
            if (lastDotPosition > 0) {
                // usually, the name will start after the last dot
                name = cer.Substring(lastDotPosition + 1);            
            } else {
                // but if there is no dot, this is a type in the default namespace and the name is everything after the colon
                name = cer.Substring(2);
            }

            // remove any generic tics from the name
            int tickPosition = name.IndexOf('`');
            if (tickPosition > 0) name = name.Substring(0, tickPosition);

            if ((options & DisplayOptions.ShowContainer) > 0) {
                // work out namespace
            }

            writer.WriteString(name);

            if ((options & DisplayOptions.ShowTemplates) > 0) {
                // work out templates
            }

        }
Пример #7
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;
            }

        }
Пример #8
0
 public static SimpleTypeReference CreateSimpleTypeReference (XPathNavigator node) {
     if (node == null) throw new ArgumentNullException("node");
     string api = node.GetAttribute("api", String.Empty);
     SimpleTypeReference reference = new SimpleTypeReference(api);
     return(reference);
 }