Exemple #1
0
    public static void Main(String[] args)
    {
        Console.WriteLine("MkMsil:");

        ArrayList streams = new ArrayList();

        foreach (string arg in args)
        {
            streams.Add(new MetaDataResolver.LoadedStream(arg,
                                                          Path.GetFullPath(arg),
                                                          new FileStream(arg,
                                                                         FileMode.Open,
                                                                         FileAccess.Read,
                                                                         FileShare.Read)));
        }

        Console.WriteLine("-----------------------------------------------------------------");
        MetaDataResolver resolver = new MetaDataResolver(streams, false, false, false);

        Console.WriteLine("-----------------------------------------------------------------");
        MetaDataResolver.ResolveCustomAttributes(new MetaDataResolver[] { resolver });
        Console.WriteLine("-----------------------------------------------------------------");

        MetaDataTypeDefinition shellCommandAttribute
            = resolver.ResolveName("Microsoft.Singularity.Shell.ShellCommandAttribute");

        Console.WriteLine("{0}", shellCommandAttribute);
        Console.WriteLine("-----------------------------------------------------------------");

#if DONT
        foreach (MetaData metadata in resolver.MetaDataList)
        {
            DumpMetaData(metadata);
        }
#endif

        foreach (MetaData metadata in resolver.MetaDataList)
        {
            foreach (MetaDataTypeDefinition type in metadata.TypeDefs)
            {
                foreach (MetaDataMethod method in type.Methods)
                {
                    MetaDataCustomAttribute attribute
                        = MethodFindAttribute(method, shellCommandAttribute);

                    if (attribute != null)
                    {
                        Console.WriteLine("new ShellCommand(\"{0}\", \"{1}\", new Command({2})),",
                                          attribute.FixedArgs[0],
                                          attribute.FixedArgs[1],
                                          method.Name);
                    }
                }
            }
        }
    }
    private XmlNode GetEndpointHierarchy(string nodeName, string endpointType)
    {
        XmlNode node = AddElement(null, nodeName);
        MetaDataTypeDefinition epType = resolver.ResolveName(endpointType);

        XmlNode oldChild = null;
        XmlNode newChild = null;

        while (epType.FullName != "Microsoft.Singularity.Channels.Endpoint")
        {
            newChild = manifest.CreateNode(XmlNodeType.Element, "inherit", "");

            AddAttribute(newChild, "name", epType.FullName);

            if (oldChild == null)
            {
                node.AppendChild(newChild);
            }
            else
            {
                node.InsertBefore(newChild, oldChild);
            }
            oldChild = newChild;

            string nextName;
            if (epType.Extends is MetaDataTypeReference)
            {
                nextName = ((MetaDataTypeReference)epType.Extends).FullName;
                if (nextName == "Exp" || nextName == "Imp")
                {
                    MetaDataTypeReference mdtr =
                        (MetaDataTypeReference)epType.Extends;
                    nextName =
                        ((MetaDataTypeReference)mdtr.ResolutionScope).FullName
                        + "." + nextName;
                }
            }
            else if (epType.Extends is MetaDataTypeDefinition)
            {
                nextName = ((MetaDataTypeDefinition)epType.Extends).FullName;
            }
            else
            {
                return(node);
            }

            epType = resolver.ResolveName(nextName);
        }

        newChild = manifest.CreateNode(XmlNodeType.Element, "inherit", "");
        AddAttribute(newChild, "name", epType.FullName);

        if (oldChild == null)
        {
            node.AppendChild(newChild);
        }
        else
        {
            node.InsertBefore(newChild, oldChild);
            oldChild = newChild;
        }

        return(node);
    }