// Token: 0x06004FF4 RID: 20468 RVA: 0x00119534 File Offset: 0x00117734 internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] array = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest == null) { return(null); } ISection assemblyReferenceSection = applicationComponentManifest.AssemblyReferenceSection; uint num = (assemblyReferenceSection != null) ? assemblyReferenceSection.Count : 0U; if (num > 0U) { uint num2 = 0U; array = new IAssemblyReferenceEntry[num]; IEnumUnknown enumUnknown = (IEnumUnknown)assemblyReferenceSection._NewEnum; int num3 = enumUnknown.Next(num, array, ref num2); if (num2 != num || num3 < 0) { return(null); } } return(array); }
static void Main(string[] args) { CalculadoraDeImpostos calculadora = new CalculadoraDeImpostos(); Imposto iss = new ISS(); Imposto icms = new ICMS(); Imposto ibb = new IBB(); Imposto brl = new BRL(); Imposto ihit = new IHIT(); Orcamento orcamento = new Orcamento(500); orcamento.AdicionaItens(new Item("Caneta", 20)); orcamento.AdicionaItens(new Item("Lápis", 15)); orcamento.AdicionaItens(new Item("Borracha", 3)); orcamento.AdicionaItens(new Item("Caneta", 300)); //orcamento.AdicionaItens(new Item("Mochila", 200)); //orcamento.AdicionaItens(new Item("6º elemento", 1)); calculadora.RealizaCalculo(orcamento, iss); calculadora.RealizaCalculo(orcamento, icms); calculadora.RealizaCalculo(orcamento, ibb); calculadora.RealizaCalculo(orcamento, brl); calculadora.RealizaCalculo(orcamento, ihit); //double desconto = calculadora.Calcula(orcamento); //Console.WriteLine(desconto); }
internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] entries = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null) { return(null); } ISection dependencySection = appManifest.AssemblyReferenceSection; uint count = (dependencySection != null) ? dependencySection.Count : 0; if (count > 0) { uint fetched = 0; entries = new IAssemblyReferenceEntry[count]; IEnumUnknown dependencyEnum = (IEnumUnknown)dependencySection._NewEnum; int hr = dependencyEnum.Next(count, entries, ref fetched); if (fetched != count || hr < 0) { return(null); // } } return(entries); }
// Token: 0x06004FF3 RID: 20467 RVA: 0x00119454 File Offset: 0x00117654 internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest == null || applicationComponentManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown enumUnknown = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum; uint num = 0U; object[] array = new object[1]; if (enumUnknown.Next(1U, array, ref num) == 0 && num == 1U) { IEntryPointEntry entryPointEntry = (IEntryPointEntry)array[0]; EntryPointEntry allData = entryPointEntry.AllData; if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0) { fileName = allData.CommandLine_File; } else { object obj = null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out obj); IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)obj; fileName = assemblyReferenceEntry.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; } }
private static ApplicationId ParseApplicationId(ICMS manifest) { if (manifest.Identity == null) { return((ApplicationId)null); } return(new ApplicationId(Hex.DecodeHexString(manifest.Identity.GetAttribute("", "publicKeyToken")), manifest.Identity.GetAttribute("", "name"), new Version(manifest.Identity.GetAttribute("", "version")), manifest.Identity.GetAttribute("", "processorArchitecture"), manifest.Identity.GetAttribute("", "culture"))); }
private static System.ApplicationId ParseApplicationId(ICMS manifest) { if (manifest.Identity == null) { return null; } return new System.ApplicationId(Hex.DecodeHexString(manifest.Identity.GetAttribute("", "publicKeyToken")), manifest.Identity.GetAttribute("", "name"), new Version(manifest.Identity.GetAttribute("", "version")), manifest.Identity.GetAttribute("", "processorArchitecture"), manifest.Identity.GetAttribute("", "culture")); }
public void EmitirNotaFiscal(Pedido pedido) { this.NumeroNotaFiscal = 99999; this.Serie = new Random().Next(Int32.MaxValue); this.NomeCliente = pedido.NomeCliente; this.EstadoDestino = pedido.EstadoOrigem; this.EstadoOrigem = pedido.EstadoDestino; foreach (PedidoItem itemPedido in pedido.ItensDoPedido) { NotaFiscalItem notaFiscalItem = new NotaFiscalItem(); //Uso padrao de Projeto Clain of Responsability, para resolver o problema de manutanção e sujeira de codigo CalculaCfop cfop = new CalculaCfop(); notaFiscalItem.Cfop = cfop.ObtemCfop(pedido); //Centralizo para cada classe responsavel notaFiscalItem.AliquotaIcms = ICMS.ObtemAliquotaIcms(pedido); notaFiscalItem.TipoIcms = ICMS.ObtemTipoIcms(pedido); notaFiscalItem.BaseIcms = ICMS.CalculaBaseIcms(notaFiscalItem.Cfop, itemPedido.ValorItemPedido); notaFiscalItem.ValorIcms = ICMS.CalculaValorIcms(notaFiscalItem); if (itemPedido.Brinde) { notaFiscalItem.TipoIcms = "60"; notaFiscalItem.AliquotaIcms = 0.18; notaFiscalItem.ValorIcms = notaFiscalItem.BaseIcms * notaFiscalItem.AliquotaIcms; } notaFiscalItem.NomeProduto = itemPedido.NomeProduto; notaFiscalItem.CodigoProduto = itemPedido.CodigoProduto; // caulculo IPI notaFiscalItem.AliquotaIpi = IPI.CalculaAliquotaIpi(itemPedido.Brinde); notaFiscalItem.BaseIpi += itemPedido.ValorItemPedido; notaFiscalItem.ValorIpi = IPI.CalculaValorIpi(notaFiscalItem.BaseIpi, notaFiscalItem.AliquotaIpi); //Desconto Sudeste notaFiscalItem.Desconto = DescontosSudeste.ObtemDesconto(this.EstadoDestino); this.ItensDaNotaFiscal.Add(notaFiscalItem); } //Validação se persistiu xml com sucesso if (!Xml.Exportar(pedido)) { throw new Exception("Problemas para gravar Xml"); } // Salvando no Banco var idNota = NotaFiscalRepository.InsertNotaFiscal(this); foreach (var item in this.ItensDaNotaFiscal.ToList()) { item.IdNotaFiscal = idNota; NotaFiscalRepository.InsertNotaFiscalItem(item); } }
public void TestaValorLiquido() { ItensNotasFiscais i = new ItensNotasFiscais(); i.Quantidade = 10; i.ValorUnitario = 10; i.Imposto = ICMS.CalculaICMS(i.ValorTotal); Assert.AreEqual(i.ValorLiquido, 92); }
static void Main(string[] args) { IImposto iss = new ISS(); IImposto icms = new ICMS(); Orcamento orcamento = new Orcamento(500.0); CalculadorDeImpostos calculador = new CalculadorDeImpostos(); calculador.RealizaCalculo(orcamento, iss); calculador.RealizaCalculo(orcamento, icms); }
static void Main(string[] args) { IImposto iss = new ISS(); IImposto icms = new ICMS(); IImposto iccc = new ICCC(); CalcularImposto calc = new CalcularImposto(); Console.WriteLine("Entre com o Orçamento!!"); var valor = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("O valor é de : " + calc.RealizaCalculoImposto(valor, iss)); Console.ReadKey(); }
static void Main(string[] args) { IImposto iss = new ISS(); IImposto icms = new ICMS(); var orcamento = new Orcamento(500.0); var calculador = new CalculadorDeImpostos(); calculador.RealizaCalculo(orcamento, iss); calculador.RealizaCalculo(orcamento, icms); }
public void RetornaImpostoUsadoDadoUmImpostoDeICMSComUmOrcamentoValido(decimal impostoEsperado, decimal valorOrcamento) { // Arrange var orcamento = new Orcamento(valorOrcamento); var imposto = new ICMS(); var calculadorDeImposto = new CalculadorDeImposto(orcamento, imposto); // Act var impostoCalculado = calculadorDeImposto.CalculaImposto(); // Assert Assert.Equal(impostoEsperado, impostoCalculado); }
static void Main(string[] args) { // testando implementação do strategy IImposto iss = new ISS(); IImposto icms = new ICMS(); var orcamento = new Orcamento(1000); var calculadorDeImpostos = new CalculardorDeImpostos(); calculadorDeImpostos.RealizarCalculo(orcamento, iss); calculadorDeImpostos.RealizarCalculo(orcamento, icms); }
static void Main(string[] args) { IImposto iss = new ISS(); IImposto icms = new ICMS(); IImposto iccc = new ICCC(); var orcamento = new Orcamento(500.0); Console.WriteLine("Valor Orçamemto: " + orcamento.Valor); CalculadorDeImposto.RealizaCalculo(orcamento, iss); CalculadorDeImposto.RealizaCalculo(orcamento, icms); CalculadorDeImposto.RealizaCalculo(orcamento, iccc); Console.ReadKey(); }
static void Main(string[] args) { //Imposto IImposto iss = new ISS(); IImposto icms = new ICMS(); IImposto ihit = new IHIT(); IImposto ikcv = new IKCV(); IImposto icpp = new ICPP(); Orcamento orcamento = new Orcamento(500.0); CalculadorDeImpostos calculador = new CalculadorDeImpostos(); // Calculando o ISS calculador.RealizaCalculo(orcamento, iss); // Calculando o ICMS calculador.RealizaCalculo(orcamento, icms); // Calculando o IHIT calculador.RealizaCalculo(orcamento, ihit); // Calculando o IKCV calculador.RealizaCalculo(orcamento, ikcv); // Calculando o ICPP calculador.RealizaCalculo(orcamento, icpp); Console.WriteLine("\nPressione qualquer tecla para continuar."); Console.ReadKey(); //Relatorio IList <Conta> contaList = new List <Conta>(); contaList.Add(new Conta("Josivaldo", 123, 321, 459)); contaList.Add(new Conta("Rosemari", 456, 654, 12378)); contaList.Add(new Conta("Marinalva", 890, 098, 66789)); RelatorioSimples relatorioSimples = new RelatorioSimples(); Console.WriteLine("\n--- Relatório Simples ---"); relatorioSimples.Imprime(contaList); RelatorioComplexo relatorioComplexo = new RelatorioComplexo(); Console.WriteLine("\n--- Relatório Complexo ---"); relatorioComplexo.Imprime(contaList); Console.WriteLine("\nPressione qualquer tecla para continuar."); Console.ReadKey(); }
internal static string GetFriendlyName(ActivationContext activationContext) { ICMS deplManifest = activationContext.DeploymentComponentManifest; IMetadataSectionEntry metadataSectionEntry = (IMetadataSectionEntry)deplManifest.MetadataSectionEntry; IDescriptionMetadataEntry descriptionMetadataEntry = metadataSectionEntry.DescriptionData; string friendlyName = String.Empty; if (descriptionMetadataEntry != null) { DescriptionMetadataEntry entry = descriptionMetadataEntry.AllData; friendlyName = (entry.Publisher != null ? String.Format("{0} {1}", entry.Publisher, entry.Product) : entry.Product); } return(friendlyName); }
public static void Execute() { var iss = new ISS(); var icms = new ICMS(); var budget = new Budget(500.0); var taxCalculator = new TaxCalculator(); Console.Write("ISS: "); taxCalculator.PerformCalculation(budget, iss); Console.Write("ICMS: "); taxCalculator.PerformCalculation(budget, icms); }
// Token: 0x06004FF9 RID: 20473 RVA: 0x0011967C File Offset: 0x0011787C internal static string GetFriendlyName(ActivationContext activationContext) { ICMS deploymentComponentManifest = activationContext.DeploymentComponentManifest; IMetadataSectionEntry metadataSectionEntry = (IMetadataSectionEntry)deploymentComponentManifest.MetadataSectionEntry; IDescriptionMetadataEntry descriptionData = metadataSectionEntry.DescriptionData; string result = string.Empty; if (descriptionData != null) { DescriptionMetadataEntry allData = descriptionData.AllData; result = ((allData.Publisher != null) ? string.Format("{0} {1}", allData.Publisher, allData.Product) : allData.Product); } return(result); }
public void DeveRetornarCincoPorCentoDadoUmOrcamentoComValorValido() { // Arrange var orcamento = new Orcamento((decimal)1000.0); var icms = new ICMS(); // Act var impostoCalculado = icms.Calcula(orcamento); // Assert var valorEsperado = (decimal)(1000.0 * 0.05 + 50.0); impostoCalculado.Should().Be(valorEsperado); }
static void Main(string[] args) { Orcamento orcamento = new Orcamento(500); orcamento.AdicionaItens(new Item("Caneta", 20)); orcamento.AdicionaItens(new Item("Lápis", 15)); orcamento.AdicionaItens(new Item("Borracha", 3)); orcamento.AdicionaItens(new Item("Mochila", 300)); CalculadoraDeImpostos calculadora = new CalculadoraDeImpostos(); Imposto iss = new ICMS(new IBB()); calculadora.RealizaCalculo(orcamento, iss); }
static void Main(string[] args) { Imposto iss = new ISS(); Imposto icms = new ICMS(); Imposto issretido = new ISSRetido(); Orcamento orcamento = new Orcamento(250.00); CalculadordeImpostos calculador = new CalculadordeImpostos(); Console.WriteLine($"Valor ISS: {calculador.RealizaCalculo(orcamento, iss)}"); Console.WriteLine($"Valor ICMS: {calculador.RealizaCalculo(orcamento, icms)}"); Console.WriteLine($"Valor ISSRetido: {calculador.RealizaCalculo(orcamento, issretido)}"); Console.ReadKey(); }
private ICMS ICMS(string CSTCSOSNICMS, string orig, string modBCICMS, string vBCICMS, string pICMS) { var ICMS = new ICMS(); if (CSTCSOSNICMS == "00") { ICMS = new ICMS { ICMS00 = new ICMS00 { CST = !string.IsNullOrEmpty(CSTCSOSNICMS) ? CSTCSOSNICMS : null, Orig = !string.IsNullOrEmpty(orig) ? orig : null, modBC = !string.IsNullOrEmpty(modBCICMS) ? modBCICMS : null, vBC = !string.IsNullOrEmpty(vBCICMS) ? vBCICMS : null, pICMS = !string.IsNullOrEmpty(pICMS) ? pICMS : null, vICMS = null } }; } else if (CSTCSOSNICMS == "40") { ICMS = new ICMS { ICMS40 = new ICMS40 { CST = !string.IsNullOrEmpty(CSTCSOSNICMS) ? CSTCSOSNICMS : null, Orig = !string.IsNullOrEmpty(orig) ? orig : null, vICMSDeson = null, //sem parametros recebidos da função motDesICMS = null //sem parametros recebidos da função } }; } else if (CSTCSOSNICMS == "60") { ICMS = new ICMS { ICMS40 = new ICMS40 { CST = !string.IsNullOrEmpty(CSTCSOSNICMS) ? CSTCSOSNICMS : null, Orig = !string.IsNullOrEmpty(orig) ? orig : "0", vBCSTRet = null, //sem parametros recebidos da função vICMSSTRet = null //sem parametros recebidos da função } }; } return(ICMS); }
public IImposto[] Processar(DetalhesProdutos prod) { var dados = new DadosRN.Tipo90(this) { CST = Detalhamento.TipoICMSRN.Substring(0, 2), Origem = Detalhamento.Origem }; var imposto = new ICMS { Corpo = (ComumICMS)dados.Processar(prod) }; return(new IImposto[1] { imposto }); }
public CMSFacade() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("DefaultConnection").ToString(); var optionsBuilder = new DbContextOptionsBuilder <ljgbContext>(); optionsBuilder.UseSqlServer(connectionString); db = new ljgbContext(optionsBuilder.Options); this.dep = new CMSRepository(db); }
public IImposto[] Processar(DetalhesProdutos prod) { var dados = new DadosSN.Tipo201(this) { CSOSN = Detalhamento.TipoICMSSN, Origem = Detalhamento.Origem }; var imposto = new ICMS { Corpo = (ComumICMS)dados.Processar(prod) }; return(new IImposto[1] { imposto }); }
public void RetornaImpostoDoCMSDadoUmImpostoDeICMSComUmOrcamentoValido() { // Arrange var valor = (decimal)1000.0; var orcamento = new Orcamento(valor); var imposto = new ICMS(); var calculadorDeImposto = new CalculadorDeImposto(orcamento, imposto); // Act var impostoCalculado = calculadorDeImposto.CalculaImposto(); // Assert var impostoEsperado = decimal.Add(decimal.Multiply(valor, (decimal)0.05), (decimal)50.0); Assert.Equal(impostoEsperado, impostoCalculado); }
public static void Main(string[] args) { Console.WriteLine("Olá, bem-vindo!"); string valorLido; double valor; bool temErros; do { temErros = false; Console.Write("Digite um valor para calcular os impostos aplicados: "); valorLido = Console.ReadLine(); if (!double.TryParse(valorLido, out valor)) { Console.WriteLine("Digite um valor numérico válido!"); temErros = true; } } while (temErros); Imposto icms = new ICMS(); Imposto ipi = new IPI(); Imposto cofins = new COFINS(); double valorIcms = icms.CalculaImposto(valor); double valorIpi = ipi.CalculaImposto(valor); double valorCofins = cofins.CalculaImposto(valor); Console.WriteLine("O valor do ICMS é: {0:0.0000}", valorIcms); Console.WriteLine("O valor do IPI é: {0:0.0000}", valorIpi); if (valorCofins == 0.00) { Console.WriteLine("O COFINS não se aplica sobre esse valor"); } else { Console.WriteLine("O valor do COFINS é: {0:0.0000}", valorCofins); } Console.WriteLine("------------------------------------------"); double valorTotal = valor + valorIcms + valorIpi + valorCofins; Console.WriteLine("O valor total com os impostos é: {0:0.0000}", valorTotal); }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = (string)null; fileName = (string)null; ICMS componentManifest = activationContext.ApplicationComponentManifest; if (componentManifest == null || componentManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown enumUnknown = (IEnumUnknown)componentManifest.EntryPointSection._NewEnum; uint num1 = 0; object[] objArray = new object[1]; int num2 = 1; object[] rgelt = objArray; // ISSUE: explicit reference operation // ISSUE: variable of a reference type uint& celtFetched = @num1; if (enumUnknown.Next((uint)num2, rgelt, celtFetched) != 0 || (int)num1 != 1) { return; } EntryPointEntry allData = ((IEntryPointEntry)objArray[0]).AllData; if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0) { fileName = allData.CommandLine_File; } else { object ppUnknown = (object)null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)componentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown); IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)ppUnknown; fileName = assemblyReferenceEntry.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; }
private void CreateFromNameAndManifests(ApplicationIdentity applicationIdentity, string[] manifestPaths) { if (applicationIdentity == null) { throw new ArgumentNullException("applicationIdentity"); } if (manifestPaths == null) { throw new ArgumentNullException("manifestPaths"); } this._applicationIdentity = applicationIdentity; IEnumDefinitionIdentity identity = this._applicationIdentity.Identity.EnumAppPath(); this._manifests = new ArrayList(2); this._manifestPaths = new string[manifestPaths.Length]; IDefinitionIdentity[] definitionIdentity = new IDefinitionIdentity[1]; int index = 0; while (identity.Next(1, definitionIdentity) == 1) { ICMS icms = (ICMS)IsolationInterop.ParseManifest(manifestPaths[index], null, ref IsolationInterop.IID_ICMS); if (!IsolationInterop.IdentityAuthority.AreDefinitionsEqual(0, icms.Identity, definitionIdentity[0])) { throw new ArgumentException(Environment.GetResourceString("Argument_IllegalAppIdMismatch")); } this._manifests.Add(icms); this._manifestPaths[index] = manifestPaths[index]; index++; } if (index != manifestPaths.Length) { throw new ArgumentException(Environment.GetResourceString("Argument_IllegalAppId")); } this._manifests.TrimToSize(); if (this._manifests.Count <= 1) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidAppId")); } this._definitionIdentities = null; this._actContext = null; this._form = ContextForm.Loose; this._appRunState = ApplicationStateDisposition.Undefined; }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null || appManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown refEnum = (IEnumUnknown)appManifest.EntryPointSection._NewEnum; uint count = 0; Object[] entries = new Object[1]; // Look for the first entry point. ClickOnce semantic validation ensures exactly one entry point is present. if (refEnum.Next(1, entries, ref count) == 0 && count == 1) { IEntryPointEntry iref = (IEntryPointEntry)entries[0]; EntryPointEntry reference = iref.AllData; if (reference.CommandLine_File != null && reference.CommandLine_File.Length > 0) { fileName = reference.CommandLine_File; } else { // Locate the dependent assembly that is being refered to. Well-formed manifests should have an identity. IAssemblyReferenceEntry refEntry = null; object assemblyObj = null; if (reference.Identity != null) { ((ISectionWithReferenceIdentityKey)appManifest.AssemblyReferenceSection).Lookup(reference.Identity, out assemblyObj); refEntry = (IAssemblyReferenceEntry)assemblyObj; fileName = refEntry.DependentAssembly.Codebase; } } parameters = reference.CommandLine_Parameters; } }
internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] rgelt = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest != null) { ISection assemblyReferenceSection = applicationComponentManifest.AssemblyReferenceSection; uint celt = (assemblyReferenceSection != null) ? assemblyReferenceSection.Count : 0; if (celt <= 0) { return(rgelt); } uint celtFetched = 0; rgelt = new IAssemblyReferenceEntry[celt]; int num3 = ((IEnumUnknown)assemblyReferenceSection._NewEnum).Next(celt, rgelt, ref celtFetched); if ((celtFetched == celt) && (num3 >= 0)) { return(rgelt); } } return(null); }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if ((applicationComponentManifest == null) || (applicationComponentManifest.EntryPointSection == null)) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown unknown = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum; uint celtFetched = 0; object[] rgelt = new object[1]; if ((unknown.Next(1, rgelt, ref celtFetched) == 0) && (celtFetched == 1)) { IEntryPointEntry entry = (IEntryPointEntry)rgelt[0]; EntryPointEntry allData = entry.AllData; if ((allData.CommandLine_File != null) && (allData.CommandLine_File.Length > 0)) { fileName = allData.CommandLine_File; } else { IAssemblyReferenceEntry entry3 = null; object ppUnknown = null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown); entry3 = (IAssemblyReferenceEntry)ppUnknown; fileName = entry3.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; } }
private static bool ParseManifest(ICMS cms, ParsedData parsedData) { // parsedData is safely initialized to requestsShellIntegration:false/supportUrl:null/authenticodedPublisher:null //deploymentProviderCodebase:null try { if (cms != null) { // Extract SupportUrl and Shell Visibility if (cms.MetadataSectionEntry != null) { IMetadataSectionEntry metaDataSectionEntry = cms.MetadataSectionEntry as IMetadataSectionEntry; if (metaDataSectionEntry != null) { IDescriptionMetadataEntry description = metaDataSectionEntry.DescriptionData; if (description != null) { parsedData.SupportUrl = description.SupportUrl; parsedData.AppName = description.Product; parsedData.AppPublisher = description.Publisher; } IDeploymentMetadataEntry deployment = metaDataSectionEntry.DeploymentData; if (deployment != null) { parsedData.RequestsShellIntegration = ((deployment.DeploymentFlags & (uint)(CMS_ASSEMBLY_DEPLOYMENT_FLAG.CMS_ASSEMBLY_DEPLOYMENT_FLAG_INSTALL)) != 0); // parsedData.DeploymentProviderCodebase = deployment.DeploymentProviderCodebase; } if ((metaDataSectionEntry.ManifestFlags & (uint)CMS_MANIFEST_FLAG.CMS_MANIFEST_FLAG_USEMANIFESTFORTRUST) != 0) { parsedData.UseManifestForTrust = true; } else { parsedData.UseManifestForTrust = false; } } } } } catch (Exception e) { Debug.Fail("Error parsing manifest: " + e.Message); return false; } return true; }
private unsafe static bool ExtractManifestContent(ICMS cms, out MemoryStream ms) { ms = new MemoryStream(); try { System.Runtime.InteropServices.ComTypes.IStream pStream = cms as System.Runtime.InteropServices.ComTypes.IStream; if (pStream == null) { return false; } byte[] pv = new byte[4096]; int size = 4096; do { pStream.Read(pv, size, new IntPtr(&size)); ms.Write(pv, 0, size); } while (size == 4096); ms.Position = 0; return true; } catch (Exception) { Debug.Fail("Exception occurred in ExtractDeploymentManifestContent."); return false; } }