コード例 #1
0
        public IEnumerable<Local> getAll()
        {
            MySqlCommand cmm = new MySqlCommand();

            StringBuilder sql = new StringBuilder();
            sql.Append("select  * ");
            sql.Append(" FROM locais  ");

            cmm.CommandText = sql.ToString();

            MySqlDataReader dr = conn.executarConsultas(cmm);
            while (dr.Read())
            {

                Local loc = new Local
                {
                    idLocal = (int)dr["idLocal"],
                    sigla = (string)dr["sigla"],
                    nomeEstado = (string)dr["nomeEstado"],
                    nomeCidade = (string)dr["nomeCidade"],

                };
                local.Add(loc);
            }
            dr.Dispose();
            return local;
        }
コード例 #2
0
        public void agregarLocal(String _nombre, String _telefono, int _preferencia, int _provincia, String _url, String _descripcion = "")
        {
            try
            {
                Local local = new Local(0,_nombre, _url, _telefono, _descripcion, _preferencia, _provincia);

                if (local.IsValid)
                {
                   LocalRepositorio.Instance.Insert(local);
                   LocalRepositorio.Instance.Save();
                }
                else
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (RuleViolation rv in local.GetRuleViolations())
                    {
                        sb.AppendLine(rv.ErrorMessage);
                    }
                    throw new ApplicationException(sb.ToString());
                }

            }
            catch (DataAccessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Error: {0}", ex.Message));
            }
        }
コード例 #3
0
        public Reserva_AlterarHorario()
        {
            local = MockRepository.GenerateStub<Local>();
            data = DateTime.Now.Date;

            reserva = new Reserva(local, data, new List<HoraReservaEnum> { HoraReservaEnum.Manha });
        }
コード例 #4
0
        /// <summary>
        /// Returns true if the local variable has no name in the IL and the name was introduced by the IL reader.
        /// </summary>
        public static bool IsAnonymousLocal(Local local)
        {
            if (local == null)
                return false;

            return local.Anonymous;
        }
コード例 #5
0
ファイル: Empresas.cs プロジェクト: Feldens00/Music-Empire
 public Empresas(int pIdEmpresa, string pNomeEmpresa, Local pLocalEmpresa, string pEnderecoEmpresa)
 {
     idEmpresa = pIdEmpresa;
     nomeEmpresa = pNomeEmpresa;
     enderecoEmpresa = pEnderecoEmpresa;
     localEmpresa = pLocalEmpresa;
 }
コード例 #6
0
ファイル: LocalOptions.cs プロジェクト: BahNahNah/dnSpy
 public Local CopyTo(Local local)
 {
     local.Type = this.Type;
     local.Name = this.Name;
     local.PdbAttributes = this.PdbAttributes;
     return local;
 }
コード例 #7
0
        /// <summary>
        /// This method returns true if <paramref name="local"/> is a reference to
        /// anonymous variable generated by C# compiler for expression trees.
        /// </summary>
        /// <remarks>C# compiler generates code for expression trees that would be invalid from
        /// Code Contracts perspective (for instance, local assinment before Requires could happen etc).
        /// </remarks>
        public static bool IsExpressionTreeLocal(Local local)
        {
            if (local == null)
                return false;

            return IsAnonymousLocal(local) && IsOfType(local, typeof(System.Linq.Expressions.ParameterExpression).FullName);
        }
コード例 #8
0
 public frmAgregarZonaIni(Local local)
 {
     InitializeComponent();
     this.local = local;
     cargarDatosAnaqueles();
     revisarFuncionalidades();
 }
コード例 #9
0
        static void Main(string[] args)
        {
            Centralita centralita = new Centralita("Telefonica");
            Local unaLlamada = new Local("Quilmes", 30f, "Avellaneda", 0.98f);
            Provincial dosLlamada = new Provincial("Cordoba", Franja.Franja_1, 21f, "Santa Fe");
            Local tresLlamada = new Local("Bernal", 45f, "Termperley", 0.98f);
            Provincial cuatroLlamada = new Provincial("Buenos Aires",Franja.Franja_3, 14f, "Tucuman");

            //Cargamos la lista
            centralita.Lista.Add(unaLlamada);
            centralita.Lista.Add(dosLlamada);
            centralita.Lista.Add(tresLlamada);
            centralita.Lista.Add(cuatroLlamada);

            //Mostramos el contenido
            centralita.Mostrar();

            //Ordenamos la lista y la mostramos
            centralita.OrdenarLlamadas();

            Console.WriteLine("------ Lista ordenada -------");
            centralita.Mostrar();

            Console.ReadLine();
        }
コード例 #10
0
ファイル: NormalDeriver.cs プロジェクト: 2sic4you/ConfuserEx
 public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src)
 {
     for (int i = 0; i < 0x10; i++) {
         yield return Instruction.Create(OpCodes.Ldloc, dst);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldloc, dst);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldelem_U4);
         yield return Instruction.Create(OpCodes.Ldloc, src);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldelem_U4);
         switch (i % 3) {
             case 0:
                 yield return Instruction.Create(OpCodes.Xor);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k1);
                 yield return Instruction.Create(OpCodes.Add);
                 break;
             case 1:
                 yield return Instruction.Create(OpCodes.Mul);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k2);
                 yield return Instruction.Create(OpCodes.Xor);
                 break;
             case 2:
                 yield return Instruction.Create(OpCodes.Add);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k3);
                 yield return Instruction.Create(OpCodes.Mul);
                 break;
         }
         yield return Instruction.Create(OpCodes.Stelem_I4);
     }
 }
コード例 #11
0
ファイル: LocalEntity.cs プロジェクト: mdamaceno/TodoList
        public List<Local> GetAll()
        {
            try
            {
                var lista = new List<Local>();

                var sql = "select * from " + this.Tabela;

                var dataSet = new DataSet();
                var query = new MySqlDataAdapter(sql, CorridaDAO.StringConexao);
                query.Fill(dataSet);

                foreach (var item in dataSet.Tables[0].AsEnumerable().ToList())
                {
                    var local = new Local()
                    {
                        Id = Convert.ToInt16(item["Id"]),
                        Cidade = item["Cidade"].ToString(),
                        Uf = item["Uf"].ToString()
                    };

                    lista.Add(local);
                }

                return lista;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }
コード例 #12
0
ファイル: Local.cs プロジェクト: CragonGame/GameCloud.IM
        internal bool IsSame(Local other)
        {
            if((object)this == (object)other) return true;

            object ourVal = value; // use prop to ensure obj-disposed etc
            return other != null && ourVal == (object)(other.value); 
        }
コード例 #13
0
 public override Statement VisitAssignmentStatement(AssignmentStatement assignment)
 {
   MemberBinding binding = assignment.Target as MemberBinding;
   if (binding != null) 
   {
     Expression target = VisitExpression(binding.TargetObject);
     Field boundMember = (Field) binding.BoundMember;
     Expression source = VisitExpression(assignment.Source);
     if (!boundMember.IsStatic && !boundMember.DeclaringType.IsValueType && boundMember.DeclaringType.Contract != null && boundMember.DeclaringType.Contract.FramePropertyGetter != null && boundMember != boundMember.DeclaringType.Contract.FrameField) 
     {
       Local targetLocal = new Local(boundMember.DeclaringType);
       Statement evaluateTarget = new AssignmentStatement(targetLocal, target, assignment.SourceContext);
       Local sourceLocal = new Local(boundMember.Type);
       Statement evaluateSource = new AssignmentStatement(sourceLocal, source, assignment.SourceContext);
       Expression guard = new MethodCall(new MemberBinding(targetLocal, boundMember.DeclaringType.Contract.FramePropertyGetter), null, NodeType.Call, SystemTypes.Guard);
       Statement check = new ExpressionStatement(new MethodCall(new MemberBinding(guard, SystemTypes.Guard.GetMethod(Identifier.For("CheckIsWriting"))), null, NodeType.Call, SystemTypes.Void));
       Statement stfld = new AssignmentStatement(new MemberBinding(targetLocal, boundMember), sourceLocal, assignment.SourceContext);
       return new Block(new StatementList(new Statement[] {evaluateTarget, evaluateSource, check, stfld}));
     } 
     else
     {
       binding.TargetObject = target;
       assignment.Source = source;
       return assignment;
     }
   }
   else
   {
     return base.VisitAssignmentStatement(assignment);
   }
 }
コード例 #14
0
ファイル: Musico.cs プロジェクト: Feldens00/Music-Empire
 public Musico(int pIdMusico, string pNomeMusico, string pEnderecoMusico, Local pLocalMusico)
 {
     idMusico = pIdMusico;
     nomeMusico = pNomeMusico;
     enderecoMusico = pEnderecoMusico;
     localMusico = pLocalMusico;
 }
コード例 #15
0
        public IHttpActionResult PutLocal(int id, Local local)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != local.Id)
            {
                return BadRequest();
            }

            db.Entry(local).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocalExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #16
0
ファイル: LocalDA.cs プロジェクト: pfizzer/papyrusten
        public byte Delete(Local instance)
        {
            ISession hisession = null;
            try
            {
                hisession = NHibernateHelper.GetCurrentSession();
                hisession.BeginTransaction();
                hisession.Delete(instance);
                hisession.Transaction.Commit();
                hisession.Close();
                return 1;
            }
            catch (Exception ex)
            {
                if (hisession != null)
                {
                    if (hisession.IsOpen)
                    {
                        hisession.Close();
                    }
                }

            }
            return 0;
        }
コード例 #17
0
        public Reserva_Nova_Criada_Corretamente()
        {
            local = new Local("Um Local");
            data = DateTime.Now.Date;

            reserva = new Reserva(local, data, new List<HoraReservaEnum> { HoraReservaEnum.Manha });
        }
コード例 #18
0
 public frmIngresarProductos(Local local)
 {
     if (!local.Estado.Equals("Activo"))
     {
         Utils.Utils.Mensaje("El local del cual está realizando la transacción no está activo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     InitializeComponent();
     this.local = local;
     dgvProductos.AllowUserToAddRows = false;
     dgvProductos.AllowUserToDeleteRows = false;
     txtNroDocumento.KeyPress += new System.Windows.Forms.KeyPressEventHandler(Utils.Utils.ValidaNumerico);
     this.AcceptButton = btnCargarDatos;
     List<ListItem> listItem = new List<ListItem>();
     ListItem e1 = new ListItem("Compra", (int)TipoMov.Compra);
     ListItem e3 = new ListItem("Consignacion", (int)TipoMov.Consignacion);
     ListItem e4 = new ListItem("Transferencia", (int)TipoMov.Transferencia);
     listItem.Add(e1);
     listItem.Add(e3);
     listItem.Add(e4);
     cboTipoMovimiento.DataSource = listItem;
     cboTipoMovimiento.DisplayMember = "Mostrar";
     cboTipoMovimiento.ValueMember = "Valor";
     lblFecha.Show();
     zonas = (new ZonasBL()).ObtenerDatos(this.local);
 }
コード例 #19
0
ファイル: OrdenCompraBL.cs プロジェクト: pfizzer/papyrusten
        public IList<OrdenCompra> Filtrar(DateTime fechaInicio, DateTime fechaFin, string estado, Proveedor proveedor, string numeroOC, Local local)
        {
            List<string> properties = new List<string>();
            List<object> values = new List<object>();

            properties.Add("FechaPedido >=");
            properties.Add("FechaPedido <=");

            values.Add(fechaInicio);
            values.Add(fechaFin);

            if (estado != "Todos")
            {
                properties.Add("Estado = ");
                values.Add(estado);
            }
            if (proveedor != null)
            {
                properties.Add("Proveedor.Id = ");
                values.Add(proveedor.Id);
            }
            if (numeroOC.Trim().Length > 0)
            {
                properties.Add("Id = ");
                values.Add(numeroOC);
            }

            if (local != null) {
                properties.Add("LugarEntrega = ");
                values.Add(local.Nombre);
            }

            return new OrdenCompraDA().FindByProperties(properties, values);
        }
コード例 #20
0
 public frmRegistarRevisionInventario(Local local)
 {
     InitializeComponent();
     this.local = local;
     btnQuitar.Enabled = false;
     CargaPorFecha();
 }
コード例 #21
0
 public IList<RevisionInventario> findRevisiones(List<object> criterios, Local local)
 {
     List<string> properties = (List<string>)criterios[0];
     List<object> values = (List<object>)criterios[1];
     /*            properties.Add("Estado");
     values.Add("Emitido"); */
     return new RevisionInventarioDA().FindByPropertiesE(properties, values, local);
 }
コード例 #22
0
ファイル: LocalBL.cs プロジェクト: pfizzer/papyrusten
 public string GetJefeAlmacen(Local local)
 {
     foreach (Empleado emp in local.LocalEmpleadofk)
     {
         if (emp.Cargo.Descripcion == "Jefe Almacen") return emp.ApellidoPaterno + ", "+emp.Nombres;
     }
     return "Jefe Almacen";
 }
コード例 #23
0
 public frmRegistarRevisionInventario(Local local)
 {
     InitializeComponent();
     this.local = local;
     btnQuitar.Enabled = false;
     CargaPorFecha();
     dtpFecha.MinDate = DateTime.Today;
 }
コード例 #24
0
ファイル: TransferenciaBL.cs プロジェクト: pfizzer/papyrusten
 public IList<Transferencia> findEnviadas(List<object> criterios, Local local)
 {
     List<string> properties = (List<string>)criterios[0];
     List<object> values = (List<object>)criterios[1];
     properties.Add("Estado");
     values.Add("Enviado");
     return new TransferenciaDA().FindByPropertiesE(properties, values, local);
 }
コード例 #25
0
 static bool checkStloc(IList<Local> locals, Instr instr, Local local)
 {
     if (!instr.isStloc())
         return false;
     if (Instr.getLocalVar(locals, instr) != local)
         return false;
     return true;
 }
コード例 #26
0
ファイル: Noticia.cs プロジェクト: josuecorrea/Eva
 public Noticia()
 {
     Data = new DateTime();
     Arquivos = new List<Arquivo>();
     Categoria = new Categoria();
     Local = new Local();
     Fonte = new Fonte();
     Zona = new NoticiaZona();
 }
コード例 #27
0
 public bool equals(Local L)
 {
     bool rta = false;
         if (L is Local)
         {
             rta = true;
         }
         return rta;
 }
コード例 #28
0
ファイル: Eventos.cs プロジェクト: Feldens00/Music-Empire
 public Eventos(int pIdEvento, string pNomeEvento, string pDataEvento, string pEnderecoEvento,
     Local pLocalEvento)
 {
     idEvento = pIdEvento;
     nomeEvento = pNomeEvento;
     dataEvento = pDataEvento;
     enderecoEvento = pEnderecoEvento;
     localEvento = pLocalEvento;
 }
コード例 #29
0
ファイル: Block.cs プロジェクト: chenzuo/SharpLua
 public void CheckLocalName(string varname)
 {
     //if (V.has(varname))
     //{
     Local l = new Local(varname, 0, 0);
     if (Chunk.Locals.Any((L) => l.Name == varname))
         return;
     Chunk.Locals.Add(l);
     //}
 }
コード例 #30
0
ファイル: PlistWriter.cs プロジェクト: kaduardo/cyberduck
        public void write(Serializable bookmark, Local file)
        {
            XmlDocument plistDocument = GetPlistDocument();
            XmlNode plistElement = plistDocument.LastChild;

            XmlNode impNode = plistDocument.ImportNode((XmlNode) bookmark.getAsDictionary(), true);
            plistElement.AppendChild(impNode);

            plistDocument.Save(file.getAbsolute());
        }
コード例 #31
0
 static WebRequest GetRequestPointRoute(Local ori, Local des)
 => WebRequest.Create(
     $"{Url}directions/json?" +
     $"origin={ConvNumber(ori.Latitude)},{ConvNumber(ori.Longitude)}&" +
     $"destination={ConvNumber(des.Latitude)},{ConvNumber(des.Longitude)}&" +
     $"sensor=false&key={Key}");
コード例 #32
0
 public void EmitDeserialize(Emit emiter, Local value)
 {
     emiter.LoadArgument(1);
     emiter.Call(typeof(NetsphereExtensions).GetMethod(nameof(NetsphereExtensions.ReadCompressedVector3)));
     emiter.StoreLocal(value);
 }
コード例 #33
0
 public IRVariable ResolveLocal(Local local) => this.locals[local.Index];
コード例 #34
0
 public T Remove(T item)
 {
     Local.Remove(item);
     return(item);
 }
コード例 #35
0
 public string IngresarLocal(Local value)
 {
     return(LocalDAO.Ingresar(value));
 }
コード例 #36
0
ファイル: SisMueblum.cs プロジェクト: DmonicAct/SISMUEBLUM
 public void anhadirLocal(Local valor)
 {
     locales.Add(valor);
 }
コード例 #37
0
 public static void WriteEvent(Categories Category, EventSeverity Severity, string message)
 {
     Local.WriteEvent(1337, Local.GetCategory(Category), Severity, message);
 }
コード例 #38
0
 public T Add(T item)
 {
     Local.Add(item);
     return(item);
 }
コード例 #39
0
 public NotaFiscalModel(NotaFiscal nota, Local local)
 {
     Nota     = nota;
     Local    = local;
     Produtos = new List <Produto>();
 }
コード例 #40
0
ファイル: Dataset.cs プロジェクト: aws/aws-sdk-unity-net
 /// <summary>
 /// Gets the size of a record with the given key. If the key is deleted, -1
 /// will be returned.
 ///  The size is calculated as sum of UTF-8 string length of record key and value
 /// </summary>
 /// <returns>The size in bytes.</returns>
 /// <param name="key">The key of a record</param>
 public long GetSizeInBytes(string key)
 {
     return(DatasetUtils.ComputeRecordSize(Local.GetRecord(IdentityId,
                                                           DatasetName, DatasetUtils.ValidateRecordKey(key))));
 }
コード例 #41
0
ファイル: Dataset.cs プロジェクト: aws/aws-sdk-unity-net
 /// <summary>
 /// Puts a <see cref="Amazon.CognitoSync.SyncManager.Record"/> with the given key and value into the
 /// Dataset. If a <see cref="Amazon.CognitoSync.SyncManager.Record"/> with the same key exists, its value
 /// will be overwritten. If a <see cref="Amazon.CognitoSync.SyncManager.Record"/> is marked as deleted previously,
 /// then it will be resurrected with new value while the sync count continues
 /// with previous value. No matter whether the value changes or not, the
 /// record is considered as updated, and it will be written to Cognito Sync
 /// service on next synchronize operation. If value is null, a
 /// ArgumentNullException will be thrown.
 /// </summary>
 /// <param name="key">Key of the record</param>
 /// <param name="value">String value of a <see cref="Amazon.CognitoSync.SyncManager.Record"/> to be put into the
 /// <see cref="Amazon.CognitoSync.SyncManager.Dataset"/></param>
 /// <seealso href="http://docs.aws.amazon.com/cognito/latest/developerguide/synchronizing-data.html#reading-and-writing-data">Amazon Cognito Sync Dev. Guide - Reading and Writing Data</seealso>
 public void Put(string key, string value)
 {
     Local.PutValue(IdentityId, DatasetName,
                    DatasetUtils.ValidateRecordKey(key), value);
 }
コード例 #42
0
ファイル: Dataset.cs プロジェクト: aws/aws-sdk-unity-net
 /// <summary>
 /// Gets the <see cref="Amazon.CognitoSync.SyncManager.Record"/> with the given key. If the
 /// <see cref="Amazon.CognitoSync.SyncManager.Record"/> doesn't exist or is marked deleted, null will be returned.
 /// </summary>
 /// <param name="key">Key of the record in the dataset.</param>
 public Record GetRecord(string key)
 {
     return(Local.GetRecord(IdentityId, DatasetName,
                            DatasetUtils.ValidateRecordKey(key)));
 }
コード例 #43
0
ファイル: Dataset.cs プロジェクト: aws/aws-sdk-unity-net
 /// <summary>
 /// Gets the value of a <see cref=
 /// "Record"/> with the given key. If the
 /// <see cref="Amazon.CognitoSync.SyncManager.Record"/> doesn't exist or is marked deleted, null will be returned.
 /// </summary>
 /// <param name="key">Key of the record in the dataset.</param>
 /// <seealso href="http://docs.aws.amazon.com/cognito/latest/developerguide/synchronizing-data.html#reading-and-writing-data">Amazon Cognito Sync Dev. Guide - Reading and Writing Data</seealso>
 public string Get(string key)
 {
     return(Local.GetValue(IdentityId, DatasetName,
                           DatasetUtils.ValidateRecordKey(key)));
 }
コード例 #44
0
ファイル: Dataset.cs プロジェクト: aws/aws-sdk-unity-net
 /// <summary>
 /// Delete this <see cref="Amazon.CognitoSync.SyncManager.Dataset"/>. You cannot do any more operations
 /// on this dataset.
 /// </summary>
 public void Delete()
 {
     Local.DeleteDataset(IdentityId, DatasetName);
 }
コード例 #45
0
 static WebRequest GetRequestNameRoute(Local ori, Local des)
 => WebRequest.Create(
     $"{Url}directions/json?origin={ori.Endereco}&destination={des.Endereco}&sensor=false&key={Key}");
コード例 #46
0
        public void EmitDeserialize(CompilerContext context, Local value)
        {
            var elementType     = value.LocalType.GetElementType();
            var emptyArrayLabel = context.Emit.DefineLabel();
            var endLabel        = context.Emit.DefineLabel();

            using (var length = context.Emit.DeclareLocal <int>("length"))
            {
                // length = ProudNetBinaryReaderExtensions.ReadScalar(reader)
                context.Emit.LoadReaderOrWriterParam();
                context.Emit.Call(ReflectionHelper.GetMethod((BinaryReader _) => _.ReadScalar()));
                context.Emit.StoreLocal(length);

                // if(length < 1) {
                //  value = Array.Empty<>()
                //  return
                // }
                context.Emit.LoadLocal(length);
                context.Emit.LoadConstant(1);
                context.Emit.BranchIfLess(emptyArrayLabel);

                // value = new [length]
                context.Emit.LoadLocal(length);
                context.Emit.NewArray(elementType);
                context.Emit.StoreLocal(value);

                // Little optimization for byte arrays
                if (elementType == typeof(byte))
                {
                    // value = reader.ReadBytes(length);
                    context.Emit.LoadReaderOrWriterParam();
                    context.Emit.LoadLocal(length);
                    context.Emit.Call(ReflectionHelper.GetMethod((BinaryReader _) => _.ReadBytes(default(int))));
                    context.Emit.StoreLocal(value);
                }
                else
                {
                    var loopLabel      = context.Emit.DefineLabel();
                    var loopCheckLabel = context.Emit.DefineLabel();

                    using (var element = context.Emit.DeclareLocal(elementType, "element"))
                        using (var i = context.Emit.DeclareLocal <int>("i"))
                        {
                            context.Emit.MarkLabel(loopLabel);
                            context.EmitDeserialize(element);

                            // value[i] = element
                            context.Emit.LoadLocal(value);
                            context.Emit.LoadLocal(i);
                            context.Emit.LoadLocal(element);
                            context.Emit.StoreElement(elementType);

                            // ++i
                            context.Emit.LoadLocal(i);
                            context.Emit.LoadConstant(1);
                            context.Emit.Add();
                            context.Emit.StoreLocal(i);

                            // i < length
                            context.Emit.MarkLabel(loopCheckLabel);
                            context.Emit.LoadLocal(i);
                            context.Emit.LoadLocal(length);
                            context.Emit.BranchIfLess(loopLabel);
                        }
                }

                context.Emit.Branch(endLabel);
            }

            // value = Array.Empty<>()
            context.Emit.MarkLabel(emptyArrayLabel);
            context.Emit.Call(typeof(Array)
                              .GetMethod(nameof(Array.Empty))
                              .GetGenericMethodDefinition()
                              .MakeGenericMethod(elementType));
            context.Emit.StoreLocal(value);
            context.Emit.MarkLabel(endLabel);
        }
コード例 #47
0
        /// <summary>
        ///     Copies the information from the origin method to injected method.
        /// </summary>
        /// <param name="methodDef">The origin MethodDef.</param>
        /// <param name="ctx">The injection context.</param>
        static void CopyMethodDef(MethodDef methodDef, InjectContext ctx)
        {
            var newMethodDef = (MethodDef)ctx.Map[methodDef];

            newMethodDef.Signature = ctx.Importer.Import(methodDef.Signature);
            newMethodDef.Parameters.UpdateParameterTypes();

            if (methodDef.ImplMap != null)
            {
                newMethodDef.ImplMap = new ImplMapUser(new ModuleRefUser(ctx.TargetModule, methodDef.ImplMap.Module.Name), methodDef.ImplMap.Name, methodDef.ImplMap.Attributes);
            }

            foreach (CustomAttribute ca in methodDef.CustomAttributes)
            {
                newMethodDef.CustomAttributes.Add(new CustomAttribute((ICustomAttributeType)ctx.Importer.Import(ca.Constructor)));
            }

            if (methodDef.HasBody)
            {
                newMethodDef.Body          = new CilBody(methodDef.Body.InitLocals, new List <Instruction>(), new List <ExceptionHandler>(), new List <Local>());
                newMethodDef.Body.MaxStack = methodDef.Body.MaxStack;

                var bodyMap = new Dictionary <object, object>();

                foreach (Local local in methodDef.Body.Variables)
                {
                    var newLocal = new Local(ctx.Importer.Import(local.Type));
                    newMethodDef.Body.Variables.Add(newLocal);
                    newLocal.Name          = local.Name;
                    newLocal.PdbAttributes = local.PdbAttributes;

                    bodyMap[local] = newLocal;
                }

                foreach (Instruction instr in methodDef.Body.Instructions)
                {
                    var newInstr = new Instruction(instr.OpCode, instr.Operand);
                    newInstr.SequencePoint = instr.SequencePoint;

                    if (newInstr.Operand is IType)
                    {
                        newInstr.Operand = ctx.Importer.Import((IType)newInstr.Operand);
                    }

                    else if (newInstr.Operand is IMethod)
                    {
                        newInstr.Operand = ctx.Importer.Import((IMethod)newInstr.Operand);
                    }

                    else if (newInstr.Operand is IField)
                    {
                        newInstr.Operand = ctx.Importer.Import((IField)newInstr.Operand);
                    }

                    newMethodDef.Body.Instructions.Add(newInstr);
                    bodyMap[instr] = newInstr;
                }

                foreach (Instruction instr in newMethodDef.Body.Instructions)
                {
                    if (instr.Operand != null && bodyMap.ContainsKey(instr.Operand))
                    {
                        instr.Operand = bodyMap[instr.Operand];
                    }

                    else if (instr.Operand is Instruction[])
                    {
                        instr.Operand = ((Instruction[])instr.Operand).Select(target => (Instruction)bodyMap[target]).ToArray();
                    }
                }

                foreach (ExceptionHandler eh in methodDef.Body.ExceptionHandlers)
                {
                    newMethodDef.Body.ExceptionHandlers.Add(new ExceptionHandler(eh.HandlerType)
                    {
                        CatchType    = eh.CatchType == null ? null : (ITypeDefOrRef)ctx.Importer.Import(eh.CatchType),
                        TryStart     = (Instruction)bodyMap[eh.TryStart],
                        TryEnd       = (Instruction)bodyMap[eh.TryEnd],
                        HandlerStart = (Instruction)bodyMap[eh.HandlerStart],
                        HandlerEnd   = (Instruction)bodyMap[eh.HandlerEnd],
                        FilterStart  = eh.FilterStart == null ? null : (Instruction)bodyMap[eh.FilterStart]
                    });
                }

                newMethodDef.Body.SimplifyMacros(newMethodDef.Parameters);
            }
        }
コード例 #48
0
 public static void WriteTrace(Categories Category, TraceSeverity Severity, string message)
 {
     Local.WriteTrace(1337, Local.GetCategory(Category), Severity, message);
 }
コード例 #49
0
        // Token: 0x06000053 RID: 83 RVA: 0x00006DCC File Offset: 0x00004FCC
        public static void InlineInteger(MethodDef method, int i)
        {
            bool isGlobalModuleType = method.DeclaringType.IsGlobalModuleType;

            if (!isGlobalModuleType)
            {
                IList <Instruction> instructions = method.Body.Instructions;
                try
                {
                    bool flag = instructions[i - 1].OpCode == OpCodes.Callvirt;
                    if (flag)
                    {
                        bool flag2 = instructions[i + 1].OpCode == OpCodes.Call;
                        if (flag2)
                        {
                            return;
                        }
                    }
                    bool flag3 = instructions[i + 4].IsBr();
                    if (!flag3)
                    {
                        bool flag4 = true;
                        int  num   = numbers.random.Next(0, 2);
                        int  num2  = num;
                        if (num2 != 0)
                        {
                            if (num2 == 1)
                            {
                                flag4 = false;
                            }
                        }
                        else
                        {
                            flag4 = true;
                        }
                        Local local = new Local(method.Module.CorLibTypes.String);
                        method.Body.Variables.Add(local);
                        Local local2 = new Local(method.Module.CorLibTypes.Int32);
                        method.Body.Variables.Add(local2);
                        int    ldcI4Value = instructions[i].GetLdcI4Value();
                        string text       = Renamer.Generator.GenerateString();
                        instructions.Insert(i, Instruction.Create(OpCodes.Ldloc_S, local2));
                        instructions.Insert(i, Instruction.Create(OpCodes.Stloc_S, local2));
                        bool flag5 = flag4;
                        if (flag5)
                        {
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I4, ldcI4Value));
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I4, ldcI4Value + 1));
                        }
                        else
                        {
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I4, ldcI4Value + 1));
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I4, ldcI4Value));
                        }
                        instructions.Insert(i, Instruction.Create(OpCodes.Call, method.Module.Import(typeof(string).GetMethod("op_Equality", new Type[]
                        {
                            typeof(string),
                            typeof(string)
                        }))));
                        instructions.Insert(i, Instruction.Create(OpCodes.Ldstr, text));
                        instructions.Insert(i, Instruction.Create(OpCodes.Ldloc_S, local));
                        instructions.Insert(i, Instruction.Create(OpCodes.Stloc_S, local));
                        bool flag6 = flag4;
                        if (flag6)
                        {
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldstr, text));
                        }
                        else
                        {
                            instructions.Insert(i, Instruction.Create(OpCodes.Ldstr, Renamer.Generator.GenerateString()));
                        }
                        instructions.Insert(i + 5, Instruction.Create(OpCodes.Brtrue_S, instructions[i + 6]));
                        instructions.Insert(i + 7, Instruction.Create(OpCodes.Br_S, instructions[i + 8]));
                        instructions.RemoveAt(i + 10);
                    }
                }
                catch
                {
                }
            }
        }
コード例 #50
0
ファイル: LocalTest.cs プロジェクト: lolkabagm/finan-api
 public LocalTest()
 {
     _local = new Local("Market", 1);
 }
コード例 #51
0
        public void EmitSerialize(CompilerContext context, Local value)
        {
            var elementType = value.LocalType.GetElementType();

            using (var length = context.Emit.DeclareLocal <int>("length"))
            {
                var writeLabel = context.Emit.DefineLabel();

                // if (value != null) goto write
                context.Emit.LoadLocal(value);
                context.Emit.LoadNull();
                context.Emit.CompareEqual();
                context.Emit.BranchIfFalse(writeLabel);

                // value = Array.Empty<>()
                context.Emit.Call(typeof(Array)
                                  .GetMethod(nameof(Array.Empty))
                                  .GetGenericMethodDefinition()
                                  .MakeGenericMethod(elementType));
                context.Emit.StoreLocal(value);

                // length = value.Length
                context.Emit.MarkLabel(writeLabel);
                context.Emit.LoadLocal(value);
                context.Emit.Call(value.LocalType.GetProperty(nameof(Array.Length)).GetMethod);
                context.Emit.StoreLocal(length);

                // ProudNetBinaryWriterExtensions.WriteScalar(writer, length)
                context.Emit.LoadReaderOrWriterParam();
                context.Emit.LoadLocal(length);
                context.Emit.Call(ReflectionHelper.GetMethod((BinaryWriter _) => _.WriteScalar(default(int))));

                var loopLabel      = context.Emit.DefineLabel();
                var loopCheckLabel = context.Emit.DefineLabel();

                using (var element = context.Emit.DeclareLocal(elementType, "element"))
                    using (var i = context.Emit.DeclareLocal <int>("i"))
                    {
                        context.Emit.Branch(loopCheckLabel);
                        context.Emit.MarkLabel(loopLabel);

                        // element = value[i]
                        context.Emit.LoadLocal(value);
                        context.Emit.LoadLocal(i);
                        context.Emit.LoadElement(elementType);
                        context.Emit.StoreLocal(element);

                        context.EmitSerialize(element);

                        // ++i
                        context.Emit.LoadLocal(i);
                        context.Emit.LoadConstant(1);
                        context.Emit.Add();
                        context.Emit.StoreLocal(i);

                        // i < length
                        context.Emit.MarkLabel(loopCheckLabel);
                        context.Emit.LoadLocal(i);
                        context.Emit.LoadLocal(length);
                        context.Emit.BranchIfLess(loopLabel);
                    }
            }
        }
コード例 #52
0
 public T Attach(T item)
 {
     Local.Add(item);
     return(item);
 }
コード例 #53
0
 public LocalOptions(Local local)
 {
     this.Type          = local.Type;
     this.Name          = local.Name;
     this.PdbAttributes = local.PdbAttributes;
 }
コード例 #54
0
ファイル: Repository.cs プロジェクト: fevrierd/AspMvcKit
 /// <summary>
 /// retourne tous les éléments
 /// </summary>
 /// <returns></returns>
 public List <T> FindAll()
 {
     return(Local.ToList());
 }
コード例 #55
0
 public string ActualizarLocal(Local value)
 {
     return(LocalDAO.Actualizar(value));
 }
コード例 #56
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Microsoft.Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (AwsElasticBlockStore != null)
     {
         AwsElasticBlockStore.Validate();
     }
     if (AzureDisk != null)
     {
         AzureDisk.Validate();
     }
     if (AzureFile != null)
     {
         AzureFile.Validate();
     }
     if (Cephfs != null)
     {
         Cephfs.Validate();
     }
     if (Cinder != null)
     {
         Cinder.Validate();
     }
     if (Csi != null)
     {
         Csi.Validate();
     }
     if (FlexVolume != null)
     {
         FlexVolume.Validate();
     }
     if (GcePersistentDisk != null)
     {
         GcePersistentDisk.Validate();
     }
     if (Glusterfs != null)
     {
         Glusterfs.Validate();
     }
     if (HostPath != null)
     {
         HostPath.Validate();
     }
     if (Iscsi != null)
     {
         Iscsi.Validate();
     }
     if (Local != null)
     {
         Local.Validate();
     }
     if (Nfs != null)
     {
         Nfs.Validate();
     }
     if (PhotonPersistentDisk != null)
     {
         PhotonPersistentDisk.Validate();
     }
     if (PortworxVolume != null)
     {
         PortworxVolume.Validate();
     }
     if (Quobyte != null)
     {
         Quobyte.Validate();
     }
     if (Rbd != null)
     {
         Rbd.Validate();
     }
     if (ScaleIO != null)
     {
         ScaleIO.Validate();
     }
     if (VsphereVolume != null)
     {
         VsphereVolume.Validate();
     }
 }
コード例 #57
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="local"></param>
 /// <param name="name"></param>
 /// <param name="attributes"></param>
 public PdbLocal(Local local, string name, PdbLocalAttributes attributes)
 {
     Local      = local;
     Name       = name;
     Attributes = attributes;
 }
コード例 #58
0
 public void EmitSerialize(Emit emiter, Local value)
 {
     emiter.LoadArgument(1);
     emiter.LoadLocal(value);
     emiter.Call(typeof(NetsphereExtensions).GetMethod(nameof(NetsphereExtensions.WriteCompressed), new[] { typeof(BinaryWriter), typeof(Vector3) }));
 }
コード例 #59
0
 public void Add(Local local)
 {
     _service.Add(local);
 }
コード例 #60
0
 public void Update(int id, Local local)
 {
     _service.Update(id, local);
 }