Exemplo n.º 1
0
 public System.Deployment.Application.DefinitionIdentity ToPKTGroupId()
 {
     System.Deployment.Application.DefinitionIdentity identity = (System.Deployment.Application.DefinitionIdentity) this.Clone();
     identity["version"]        = null;
     identity["publicKeyToken"] = null;
     return(identity);
 }
        private IDisposable AcquireLock(System.Deployment.Application.DefinitionIdentity asmId, bool writer)
        {
            string keyForm = asmId.KeyForm;

            Directory.CreateDirectory(this._deployPath);
            return(LockedFile.AcquireLock(Path.Combine(this._deployPath, keyForm), Constants.LockTimeout, writer));
        }
 private bool IsAssemblyInstalled(System.Deployment.Application.DefinitionIdentity asmId)
 {
     using (this.AcquireStoreReaderLock())
     {
         return(this._compStore.IsAssemblyInstalled(asmId));
     }
 }
 public void SetPendingDeployment(SubscriptionState subState, System.Deployment.Application.DefinitionIdentity deployId, DateTime checkTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetPendingDeployment(subState, deployId, checkTime);
     }
 }
 public void SetUpdateSkipTime(SubscriptionState subState, System.Deployment.Application.DefinitionIdentity updateSkippedDeployment, DateTime updateSkipTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetUpdateSkipTime(subState, updateSkippedDeployment, updateSkipTime);
     }
 }
Exemplo n.º 6
0
        internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
        {
            Guid guidOfType = IsolationInterop.GetGuidOfType(typeof(IReferenceIdentity));

            System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity((IReferenceIdentity)System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType));
            string processorArchitecture = refId.ProcessorArchitecture;

            if (processorArchitecture != null)
            {
                refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
            }
            System.Deployment.Application.DefinitionIdentity definitionIdentity = new System.Deployment.Application.DefinitionIdentity(refId);
            Logger.AddInternalState("Managed Assembly Identity = " + definitionIdentity.ToString());
            return(definitionIdentity);
        }
        public void CheckForDeploymentUpdate(SubscriptionState subState)
        {
            this.CheckInstalledAndShellVisible(subState);
            Uri deploymentProviderUri = subState.DeploymentProviderUri;

            using (TempFile file = null)
            {
                AssemblyManifest deployment = DownloadManager.DownloadDeploymentManifest(subState.SubscriptionStore, ref deploymentProviderUri, out file);
                Version          version    = this.CheckUpdateInManifest(subState, deploymentProviderUri, deployment, subState.CurrentDeployment.Version);
                System.Deployment.Application.DefinitionIdentity deployId = (version != null) ? deployment.Identity : null;
                this.SetPendingDeployment(subState, deployId, DateTime.UtcNow);
                if ((version != null) && deployment.Identity.Equals(subState.PendingDeployment))
                {
                    Logger.AddPhaseInformation(Resources.GetString("Upd_FoundUpdate"), new object[] { subState.SubscriptionId.ToString(), deployment.Identity.Version.ToString(), deploymentProviderUri.AbsoluteUri });
                }
            }
        }
 public bool CheckAndReferenceApplication(SubscriptionState subState, System.Deployment.Application.DefinitionAppId appId, long transactionId)
 {
     System.Deployment.Application.DefinitionIdentity deploymentIdentity  = appId.DeploymentIdentity;
     System.Deployment.Application.DefinitionIdentity applicationIdentity = appId.ApplicationIdentity;
     if (!subState.IsInstalled || !this.IsAssemblyInstalled(deploymentIdentity))
     {
         return(false);
     }
     if (!this.IsAssemblyInstalled(applicationIdentity))
     {
         throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_IllegalApplicationId"));
     }
     if (!appId.Equals(subState.CurrentBind))
     {
         return(appId.Equals(subState.PreviousBind));
     }
     return(true);
 }
 private static void AddDependencies(XmlDocument document, DependentAssembly[] dependentAssemblies)
 {
     Hashtable hashtable = new Hashtable();
     XmlNamespaceManager namespaceMgr = GetNamespaceMgr(document);
     XmlElement element = (XmlElement) document.SelectSingleNode("/asmv1:assembly", namespaceMgr);
     foreach (DependentAssembly assembly in dependentAssemblies)
     {
         if (!hashtable.Contains(assembly.Identity))
         {
             XmlElement newChild = document.CreateElement("dependency", "urn:schemas-microsoft-com:asm.v1");
             element.AppendChild(newChild);
             XmlElement element3 = document.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
             newChild.AppendChild(element3);
             System.Deployment.Application.ReferenceIdentity refId = assembly.Identity;
             System.Deployment.Application.DefinitionIdentity asmId = new System.Deployment.Application.DefinitionIdentity(refId);
             XmlElement element4 = CreateAssemblyIdentityElement(document, asmId);
             element3.AppendChild(element4);
             hashtable.Add(refId, asmId);
         }
     }
 }
        private static void AddDependencies(XmlDocument document, DependentAssembly[] dependentAssemblies)
        {
            Hashtable           hashtable    = new Hashtable();
            XmlNamespaceManager namespaceMgr = GetNamespaceMgr(document);
            XmlElement          element      = (XmlElement)document.SelectSingleNode("/asmv1:assembly", namespaceMgr);

            foreach (DependentAssembly assembly in dependentAssemblies)
            {
                if (!hashtable.Contains(assembly.Identity))
                {
                    XmlElement newChild = document.CreateElement("dependency", "urn:schemas-microsoft-com:asm.v1");
                    element.AppendChild(newChild);
                    XmlElement element3 = document.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
                    newChild.AppendChild(element3);
                    System.Deployment.Application.ReferenceIdentity  refId = assembly.Identity;
                    System.Deployment.Application.DefinitionIdentity asmId = new System.Deployment.Application.DefinitionIdentity(refId);
                    XmlElement element4 = CreateAssemblyIdentityElement(document, asmId);
                    element3.AppendChild(element4);
                    hashtable.Add(refId, asmId);
                }
            }
        }
        public static System.Deployment.Application.DefinitionIdentity GenerateManifest(System.Deployment.Application.ReferenceIdentity suggestedReferenceIdentity, AssemblyManifest manifest, string outputManifest)
        {
            System.Deployment.Application.DefinitionIdentity asmId = manifest.Identity;
            if (manifest.RawXmlBytes != null)
            {
                using (FileStream stream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
                {
                    stream.Write(manifest.RawXmlBytes, 0, manifest.RawXmlBytes.Length);
                    return(asmId);
                }
            }
            XmlDocument document = CloneAssemblyTemplate();

            asmId = new System.Deployment.Application.DefinitionIdentity(suggestedReferenceIdentity);
            InjectIdentityXml(document, asmId);
            AddFiles(document, manifest.Files);
            AddDependencies(document, manifest.DependentAssemblies);
            using (FileStream stream2 = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
            {
                document.Save(stream2);
            }
            return(asmId);
        }
 internal ArrayList CollectCrossGroupApplications(Uri codebaseUri, System.Deployment.Application.DefinitionIdentity deploymentIdentity, ref bool identityGroupFound, ref bool locationGroupFound, ref string identityGroupProductName)
 {
     Hashtable hashtable = new Hashtable();
     ArrayList list = new ArrayList();
     foreach (System.Deployment.Internal.Isolation.STORE_ASSEMBLY store_assembly in this._store.EnumAssemblies(System.Deployment.Internal.Isolation.Store.EnumAssembliesFlags.Nothing))
     {
         System.Deployment.Application.DefinitionIdentity subId = new System.Deployment.Application.DefinitionIdentity(store_assembly.DefinitionIdentity).ToSubscriptionId();
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(subId);
         if (subscriptionState.IsInstalled)
         {
             bool flag = subscriptionState.DeploymentProviderUri.Equals(codebaseUri);
             bool flag2 = subscriptionState.PKTGroupId.Equals(deploymentIdentity.ToPKTGroupId());
             bool flag3 = subscriptionState.SubscriptionId.PublicKeyToken.Equals(deploymentIdentity.ToSubscriptionId().PublicKeyToken);
             if ((!flag || !flag2) || !flag3)
             {
                 if ((flag && flag2) && !flag3)
                 {
                     if (!hashtable.Contains(subId))
                     {
                         hashtable.Add(subId, subscriptionState);
                         list.Add(new CrossGroupApplicationData(subscriptionState, CrossGroupApplicationData.GroupType.LocationGroup));
                         locationGroupFound = true;
                     }
                 }
                 else if ((!flag && flag2) && (flag3 && !hashtable.Contains(subId)))
                 {
                     hashtable.Add(subId, subscriptionState);
                     list.Add(new CrossGroupApplicationData(subscriptionState, CrossGroupApplicationData.GroupType.IdentityGroup));
                     if (((subscriptionState.CurrentDeploymentManifest != null) && (subscriptionState.CurrentDeploymentManifest.Description != null)) && (subscriptionState.CurrentDeploymentManifest.Description.Product != null))
                     {
                         identityGroupProductName = subscriptionState.CurrentDeploymentManifest.Description.Product;
                     }
                     identityGroupFound = true;
                 }
             }
         }
     }
     return list;
 }
 public static System.Deployment.Application.DefinitionIdentity GenerateManifest(System.Deployment.Application.ReferenceIdentity suggestedReferenceIdentity, AssemblyManifest manifest, string outputManifest)
 {
     System.Deployment.Application.DefinitionIdentity asmId = manifest.Identity;
     if (manifest.RawXmlBytes != null)
     {
         using (FileStream stream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
         {
             stream.Write(manifest.RawXmlBytes, 0, manifest.RawXmlBytes.Length);
             return asmId;
         }
     }
     XmlDocument document = CloneAssemblyTemplate();
     asmId = new System.Deployment.Application.DefinitionIdentity(suggestedReferenceIdentity);
     InjectIdentityXml(document, asmId);
     AddFiles(document, manifest.Files);
     AddDependencies(document, manifest.DependentAssemblies);
     using (FileStream stream2 = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
     {
         document.Save(stream2);
     }
     return asmId;
 }
 public SubscriptionState GetSubscriptionState(System.Deployment.Application.DefinitionIdentity subId)
 {
     return(new SubscriptionState(this, subId));
 }
Exemplo n.º 15
0
 public System.Deployment.Application.DefinitionIdentity ToSubscriptionId()
 {
     System.Deployment.Application.DefinitionIdentity identity = (System.Deployment.Application.DefinitionIdentity) this.Clone();
     identity["version"] = null;
     return(identity);
 }
        private static XmlElement CreateAssemblyIdentityElement(XmlDocument document, System.Deployment.Application.DefinitionIdentity asmId)
        {
            XmlElement element = document.CreateElement("assemblyIdentity", "urn:schemas-microsoft-com:asm.v1");

            System.Deployment.Internal.Isolation.IDENTITY_ATTRIBUTE[] attributes = asmId.Attributes;
            StringComparison invariantCultureIgnoreCase = StringComparison.InvariantCultureIgnoreCase;

            foreach (System.Deployment.Internal.Isolation.IDENTITY_ATTRIBUTE identity_attribute in attributes)
            {
                string namespaceURI = identity_attribute.Namespace;
                string name         = identity_attribute.Name;
                if (namespaceURI == null)
                {
                    if (name.Equals("name", invariantCultureIgnoreCase))
                    {
                        name = "name";
                    }
                    else if (name.Equals("version", invariantCultureIgnoreCase))
                    {
                        name = "version";
                    }
                    else if (name.Equals("processorArchitecture", invariantCultureIgnoreCase))
                    {
                        name = "processorArchitecture";
                    }
                    else if (name.Equals("publicKeyToken", invariantCultureIgnoreCase))
                    {
                        name = "publicKeyToken";
                    }
                    else if (name.Equals("type", invariantCultureIgnoreCase))
                    {
                        name = "type";
                    }
                    else if (name.Equals("culture", invariantCultureIgnoreCase))
                    {
                        name = "language";
                    }
                }
                element.SetAttribute(name, namespaceURI, identity_attribute.Value);
            }
            return(element);
        }
 private SubInstance[] CollectOnlineAppsMRU(out System.Deployment.Internal.Isolation.IDefinitionAppId[] deployAppIdPtrs)
 {
     Hashtable hashtable = new Hashtable();
     foreach (System.Deployment.Internal.Isolation.STORE_ASSEMBLY store_assembly in this._compStore._store.EnumAssemblies(System.Deployment.Internal.Isolation.Store.EnumAssembliesFlags.Nothing))
     {
         System.Deployment.Application.DefinitionIdentity subId = new System.Deployment.Application.DefinitionIdentity(store_assembly.DefinitionIdentity).ToSubscriptionId();
         SubscriptionState subscriptionState = this._compStore._subStore.GetSubscriptionState(subId);
         if ((subscriptionState.IsInstalled && !subscriptionState.IsShellVisible) && ((subscriptionState.appType != AppType.CustomHostSpecified) && !hashtable.Contains(subId)))
         {
             SubInstance instance = new SubInstance {
                 SubState = subscriptionState,
                 LastAccessTime = subscriptionState.LastCheckTime
             };
             hashtable.Add(subId, instance);
         }
     }
     SubInstance[] array = new SubInstance[hashtable.Count];
     hashtable.Values.CopyTo(array, 0);
     Array.Sort<SubInstance>(array);
     ArrayList list = new ArrayList();
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i].SubState.CurrentBind != null)
         {
             list.Add(array[i].SubState.CurrentBind.ToDeploymentAppId().ComPointer);
         }
         if (array[i].SubState.PreviousBind != null)
         {
             list.Add(array[i].SubState.PreviousBind.ToDeploymentAppId().ComPointer);
         }
     }
     deployAppIdPtrs = (System.Deployment.Internal.Isolation.IDefinitionAppId[]) list.ToArray(typeof(System.Deployment.Internal.Isolation.IDefinitionAppId));
     return array;
 }
        private static void InjectIdentityXml(XmlDocument document, System.Deployment.Application.DefinitionIdentity asmId)
        {
            XmlElement newChild = CreateAssemblyIdentityElement(document, asmId);

            document.DocumentElement.AppendChild(newChild);
        }