Example #1
0
        public override string BaseServiceAddress(Guid appId, Guid clsid, Guid iid)
        {
            ComAdminAppInfo adminAppInfo = ComAdminWrapper.GetAppInfo(appId.ToString("B"));

            if (null == adminAppInfo)
            {
                throw Tool.CreateException(SR.GetString(SR.CannotFindAppInfo, appId.ToString("B")), null);
            }

            ComAdminClassInfo adminClassInfo = adminAppInfo.FindClass(clsid.ToString("B"));

            if (null == adminClassInfo)
            {
                throw Tool.CreateException(SR.GetString(SR.CannotFindClassInfo, clsid.ToString("B")), null);
            }

            string uri = Uri.EscapeUriString("net.pipe://localhost/" + adminAppInfo.Name + "/" + GetPartitionId(appId) + adminClassInfo.Name);

            if (Uri.IsWellFormedUriString(uri, UriKind.Absolute))
            {
                return(uri);
            }

            return("net.pipe://localhost/" + (appId.ToString() + "/" + clsid.ToString()));
        }
Example #2
0
        public override string DefaultEndpointAddress(Guid appId, Guid clsid, Guid iid)
        {
            ComAdminAppInfo adminAppInfo = ComAdminWrapper.GetAppInfo(appId.ToString("B"));

            if (null == adminAppInfo)
            {
                throw Tool.CreateException(SR.GetString(SR.CannotFindAppInfo, appId.ToString("B")), null);
            }

            ComAdminClassInfo adminClassInfo = adminAppInfo.FindClass(clsid.ToString("B"));

            if (null == adminClassInfo)
            {
                throw Tool.CreateException(SR.GetString(SR.CannotFindClassInfo, clsid.ToString("B")), null);
            }

            ComAdminInterfaceInfo adminInterfaceInfo = adminClassInfo.FindInterface(iid.ToString("B"));

            if (null == adminInterfaceInfo)
            {
                throw Tool.CreateException(SR.GetString(SR.CannotFindInterfaceInfo, iid.ToString("B")), null);
            }

            string uri = Uri.EscapeUriString(adminInterfaceInfo.Name);

            if (Uri.IsWellFormedUriString(uri, UriKind.RelativeOrAbsolute))
            {
                return(uri);
            }

            return(iid.ToString().ToUpperInvariant());
        }
            public static SvcFile CreateNew(string webDirectoryPath, Guid appid, Guid clsid)
            {
                ComAdminAppInfo adminAppInfo = ComAdminWrapper.GetAppInfo(appid.ToString("B"));

                if (null == adminAppInfo)
                {
                    throw Tool.CreateException(SR.GetString(SR.CannotFindAppInfo, appid.ToString("B")), null);
                }

                ComAdminClassInfo adminClassInfo = adminAppInfo.FindClass(clsid.ToString("B"));

                if (null == adminClassInfo)
                {
                    throw Tool.CreateException(SR.GetString(SR.CannotFindClassInfo, clsid.ToString("B")), null);
                }

                string fileName = webDirectoryPath + "\\" + adminClassInfo.Name;

                if (File.Exists(fileName + ".svc"))
                {
                    int count = 1;

                    while (File.Exists(fileName + "." + count.ToString(CultureInfo.InvariantCulture) + ".svc"))
                    {
                        count++;
                    }

                    fileName = fileName + "." + count.ToString(CultureInfo.InvariantCulture);
                }

                fileName = fileName + ".svc";

                string comPlusString = clsid.ToString("B") + "," + appid.ToString("B");

                using (StreamWriter sw = File.CreateText(fileName))
                {
                    sw.WriteLine("<%@ServiceHost {0}=\"{1}\" {2}=\"{3}\" %>",
                                 factoryAttributeName,
                                 typeof(WasHostedComPlusFactory).FullName,
                                 serviceAttributeName,
                                 comPlusString);
                }

                return(new SvcFile(appid, clsid, SvcFileState.Added, new AtomicFile(fileName)));
            }
Example #4
0
        static void GetComponentsFromInputForRemove(ComAdminAppInfo appInfo, IList<ComponentDefinition<string>> inComps, out IList<ComponentDefinition<Guid>> outComps)
        {
            outComps = new List<ComponentDefinition<Guid>>();

            foreach (ComponentDefinition<string> inComp in inComps)
            {
                ComponentDefinition<Guid> outComp = null;

                ComAdminClassInfo classInfo = appInfo.FindClass(inComp.Component);

                if (classInfo == null)
                {
                    ToolConsole.WriteWarning(SR.GetString(SR.CannotFindComponentInApplicationSkipping, inComp.Component, Tool.Options.ShowGuids ? appInfo.ID.ToString("B") : appInfo.Name));
                    continue;
                }


                // Find existing componentDef if it was referenced in an earlier iteration
                foreach (ComponentDefinition<Guid> cd in outComps)
                {
                    if (cd.Component == classInfo.Clsid)
                    {
                        outComp = cd;
                    }
                }

                if (outComp == null)
                {
                    outComp = new ComponentDefinition<Guid>(classInfo.Clsid);
                }

                if (inComp.AllInterfaces)
                {
                    foreach (ComAdminInterfaceInfo interfaceInfo in classInfo.Interfaces)
                        outComp.AddInterface(interfaceInfo.Iid, ComPlusTypeValidator.FetchAllMethodsForInterface(interfaceInfo, false));
                    outComp.AddInterface(typeof(IMetadataExchange).GUID, null);


                }
                else
                {
                    foreach (InterfaceDefination<string> comInterface in inComp.Interfaces)
                    {
                        string itfName = comInterface.Interface;
                        if (itfName == typeof(IMetadataExchange).GUID.ToString("B"))
                        {
                            outComp.AddInterface(typeof(IMetadataExchange).GUID, null);
                        }
                        else
                        {
                            ComAdminInterfaceInfo interfaceInfo = classInfo.FindInterface(itfName);
                            if (interfaceInfo == null)
                            {
                                ToolConsole.WriteWarning(SR.GetString(SR.CannotFindInterfaceInCatalogForComponentSkipping, itfName, inComp.Component));
                                continue;
                            }
                            if (comInterface.AllMethods)
                            {
                                outComp.AddInterface(interfaceInfo.Iid, ComPlusTypeValidator.FetchAllMethodsForInterface(interfaceInfo));
                            }
                            else
                            {

                                outComp.AddInterface(interfaceInfo.Iid, (List<string>)comInterface.Methods);
                            }

                        }
                    }
                }
                if (outComp.Interfaces != null)
                    outComps.Add(outComp);
                else
                {
                    ToolConsole.WriteWarning(SR.GetString(SR.NoneOfTheSpecifiedInterfacesForComponentWereFoundSkipping, inComp.Component));
                }
            }
        }
Example #5
0
        // returns strongly typed, verified components, from loosely-typed (string) user inputs
        static void GetComponentsFromInputForAdd(ComAdminAppInfo appInfo, IList<ComponentDefinition<string>> inComps, bool mex, bool priorEndpointsExist, out IList<ComponentDefinition<Guid>> outComps)
        {
            string missingInterface = String.Empty;
            outComps = new List<ComponentDefinition<Guid>>();

            foreach (ComponentDefinition<string> inComp in inComps)
            {
                ComponentDefinition<Guid> outComp = null;

                ComAdminClassInfo classInfo = appInfo.FindClass(inComp.Component);

                if (classInfo == null)
                {
                    ToolConsole.WriteWarning(SR.GetString(SR.CannotFindComponentInApplicationSkipping, inComp.Component, Tool.Options.ShowGuids ? appInfo.ID.ToString("B") : appInfo.Name));
                    continue;
                }

                if (!ValidateClass(classInfo))
                    continue;

                // Find existing componentDef if it was referenced in an earlier iteration
                foreach (ComponentDefinition<Guid> cd in outComps)
                {
                    if (cd.Component == classInfo.Clsid)
                    {
                        outComp = cd;
                    }
                }

                if (outComp == null)
                {
                    outComp = new ComponentDefinition<Guid>(classInfo.Clsid);
                }

                if (inComp.AllInterfaces)
                {
                    foreach (ComAdminInterfaceInfo interfaceInfo in classInfo.Interfaces)
                    {
                        if (ComPlusTypeValidator.VerifyInterface(interfaceInfo, options.AllowReferences, classInfo.Clsid))
                            outComp.AddInterface(interfaceInfo.Iid, ComPlusTypeValidator.FetchAllMethodsForInterface(interfaceInfo));

                    }
                    if ((outComp.Interfaces != null) && mex)
                        outComp.AddInterface(typeof(IMetadataExchange).GUID, null);


                }
                else
                {
                    foreach (InterfaceDefination<string> comInterface in inComp.Interfaces)
                    {
                        string itfName = comInterface.Interface;
                        if (itfName == typeof(IMetadataExchange).GUID.ToString("B"))
                        {
                            if (!mex)
                                outComp.AddInterface(typeof(IMetadataExchange).GUID, null);
                        }
                        else
                        {
                            ComAdminInterfaceInfo interfaceInfo = classInfo.FindInterface(itfName);
                            if (interfaceInfo == null)
                            {
                                ToolConsole.WriteWarning(SR.GetString(SR.CannotFindInterfaceInCatalogForComponentSkipping, itfName, inComp.Component));
                                missingInterface = itfName;
                                continue;
                            }
                            if (comInterface.AllMethods)
                            {
                                if (ComPlusTypeValidator.VerifyInterface(interfaceInfo, options.AllowReferences, classInfo.Clsid, true))
                                    outComp.AddInterface(interfaceInfo.Iid, ComPlusTypeValidator.FetchAllMethodsForInterface(interfaceInfo));
                                else
                                    throw CreateException(SR.GetString(SR.InvalidInterface), null);
                            }
                            else
                            {
                                if (ComPlusTypeValidator.VerifyInterfaceMethods(interfaceInfo, comInterface.Methods, options.AllowReferences, true))
                                    outComp.AddInterface(interfaceInfo.Iid, (List<string>)comInterface.Methods);
                                else
                                    throw CreateException(SR.GetString(SR.InvalidMethod), null);
                            }

                        }
                    }

                    if ((outComp.Interfaces != null) || priorEndpointsExist)
                    {
                        if (mex)
                            outComp.AddInterface(typeof(IMetadataExchange).GUID, null);
                    }

                }
                if (outComp.Interfaces != null)
                    outComps.Add(outComp);
                else
                    ToolConsole.WriteWarning(SR.GetString(SR.NoneOfTheSpecifiedInterfacesForComponentWereFoundSkipping, inComp.Component));
            }

            if (outComps.Count == 0 && (!String.IsNullOrEmpty(missingInterface)))
                throw Tool.CreateException(SR.GetString(SR.NoComponentContainsInterface, missingInterface), null);
        }