コード例 #1
0
        public async Task <int> UpdateAsync(Specialized specialized)
        {
            using (SqlConnection conn = new SqlConnection(_connectionstring))
            {
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                DynamicParameters para = new DynamicParameters();
                para.Add("@id", specialized.Id);
                para.Add("@IdSpecialized", specialized.IdSpecialized);
                para.Add("@NameSpecialized", specialized.NameSpecialized);
                para.Add("@Office", specialized.Office);
                para.Add("@Email", specialized.Email);
                para.Add("@PhoneNumber", specialized.PhoneNumber);
                para.Add("@Address", specialized.Address);
                para.Add("@Note", specialized.Note);
                para.Add("@IdIndustry", specialized.IdIndustry);
                para.Add("@LastUpdate", specialized.LastUpdate);
                if (specialized.CreateDate != null && specialized.CreateDate != DateTime.MinValue)
                {
                    para.Add("@CreateDate", specialized.CreateDate);
                }
                para.Add("@IsDelete", specialized.IsDelete);
                para.Add("@IsActive", specialized.IsActive);
                var Code = await conn.ExecuteAsync("[spSpecialized_Update]", para, commandType : CommandType.StoredProcedure);

                return(Code);
            }
        }
コード例 #2
0
        internal List <Specialized> GetAllInfo(string employee)
        {
            try
            {
                connection.Open();
                string             selectQuery = @"SELECT  [empsz_specializtion_id]
  FROM [tbl_employee_specialzation_information] WHERE [empsz_employee_id]='" + employee + "'";
                SqlCommand         command     = new SqlCommand(selectQuery, connection);
                SqlDataReader      reader      = command.ExecuteReader();
                List <Specialized> sl          = new List <Specialized>();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Specialized ASpecializedObj = new Specialized();
                        ASpecializedObj.Id = reader[0].ToString();

                        sl.Add(ASpecializedObj);
                    }
                }
                return(sl);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
コード例 #3
0
    public void SaveTheSpecializedInformation(Specialized aSpecializedObj)
    {
        try
        {
            connection.Open();
            string     selectQuery = @"INSERT INTO [tbl_specialized_information]
       ([spz_id]
       ,[spz_name])
 VALUES
       ('" + aSpecializedObj.Id + "','" + aSpecializedObj.Name + "')";
            SqlCommand command     = new SqlCommand(selectQuery, connection);
            command.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
コード例 #4
0
        /// <summary>
        /// Create new specialized
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public virtual async Task <Specialized> AddSpecializedAsync(AddSpecializedViewModel model,
                                                                    CancellationToken cancellationToken = default(CancellationToken))
        {
            // Search specialized
            var specializeds = _unitOfWork.RepositorySpecialized.Search();

            specializeds =
                specializeds.Where(x => x.Name.Equals(model.Name, StringComparison.InvariantCultureIgnoreCase));

            // Check Specialized exists or not.
            if (await specializeds.AnyAsync(cancellationToken))
            {
                throw new ApiException(HttpMessages.CannotBeDuplicated, HttpStatusCode.Conflict);
            }

            var specialized = new Specialized
            {
                Name   = model.Name,
                Status = MasterItemStatus.Active
            };

            _unitOfWork.RepositorySpecialized.Insert(specialized);

            // Commit to db.
            await _unitOfWork.CommitAsync();

            return(specialized);
        }
コード例 #5
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Description,IsActive")] Specialized specialized)
        {
            if (id != specialized.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialized);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecializedExists(specialized.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialized));
        }
コード例 #6
0
        public Specialized GetAllSpecializedInformationIsNotSelected(Specialized aSpecializedObj)
        {
            try
            {
                connection.Open();
                string        selectQuery     = @"SELECT [spz_id]
      ,[spz_name]
  FROM [tbl_specialized_information] WHERE [spz_id] !='" + aSpecializedObj.Id + "'";
                SqlCommand    command         = new SqlCommand(selectQuery, connection);
                SqlDataReader reader          = command.ExecuteReader();
                Specialized   ASpecializedoBj = new Specialized();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ASpecializedoBj.Id   = reader[0].ToString();
                        ASpecializedoBj.Name = reader[1].ToString();
                    }
                }
                return(ASpecializedoBj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "id_Specialized,SpecializedName,Status")] Specialized specialized)
 {
     if (ModelState.IsValid)
     {
         db.Entry(specialized).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(specialized));
 }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,IsActive")] Specialized specialized)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialized);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialized));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "id_Specialized,SpecializedName,Status")] Specialized specialized)
        {
            if (ModelState.IsValid)
            {
                db.Specializeds.Add(specialized);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(specialized));
        }
コード例 #10
0
        public void CalculatePrice_WithOnlyPremiumPrice()
        {
            Specialized specialized = new Specialized();

            float result = specialized.CalculatePrice(1);

            Assert.AreEqual(160, result);

            result = specialized.CalculatePrice(3);

            Assert.AreEqual(280, result);
        }
コード例 #11
0
        public void CalculatePrice_WithMoreThenThreeDays()
        {
            Specialized specialized = new Specialized();

            float result = specialized.CalculatePrice(4);

            Assert.AreEqual(380, result);

            result = specialized.CalculatePrice(15);

            Assert.AreEqual(1480, result);
        }
コード例 #12
0
        public void CalculatePrice_WithDaysLessThenZero()
        {
            Specialized specialized = new Specialized();

            float result = specialized.CalculatePrice(0);

            Assert.AreEqual(0, result);

            result = specialized.CalculatePrice(-3212);

            Assert.AreEqual(0, result);
        }
コード例 #13
0
        /* UPDATE */
        public static void Update_Specialized(string Id, string Name)
        {
            var client = ConnectNeo4J.Connection();
            var term   = new Specialized {
                id = Id, name = Name
            };

            client.Cypher.Match("(a:Specialized)")
            .Where((Specialized item) => item.id == Id)
            .Set("a = {tmp}")
            .WithParam("tmp", term)
            .ExecuteWithoutResultsAsync();
        }
コード例 #14
0
        // GET: Admin/Specializeds/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Specialized specialized = db.Specializeds.Find(id);

            if (specialized == null)
            {
                return(HttpNotFound());
            }
            return(View(specialized));
        }
コード例 #15
0
        public async Task <ActionResultReponese <string> > UpdateAsync(string id, string nameSpecialized, string idSpeacialized, SpecializedsMeta specializedsMeta)
        {
            var isExist = await _ispecializedRepository.CheckExist(id);

            if (!isExist)
            {
                return(new ActionResultReponese <string>(-3, "Specialized khong ton tai", "Specialized"));
            }
            var isNameSpecialized = await _ispecializedRepository.CheckExistByNameSpecialized(nameSpecialized);

            if (!isNameSpecialized)
            {
                return(new ActionResultReponese <string>(-4, "NameSpecialized khong ton tai", "Specialized"));
            }
            var isSpecialized = await _ispecializedRepository.CheckExistByIdSpecialized(idSpeacialized);

            if (isSpecialized)
            {
                return(new ActionResultReponese <string>(-5, "IdSpecialized da ton tai", "Specialized"));
            }
            var isIdIndustry = await _iIndustryRepository.checkexitIdIndustry(specializedsMeta.IdIndustry);

            if (!isIdIndustry)
            {
                return(new ActionResultReponese <string>(-21, "IdIndustry khong tai", "Industry"));
            }
            var _specializedupdate = new Specialized
            {
                Id              = id,
                IdSpecialized   = idSpeacialized?.Trim(),
                NameSpecialized = nameSpecialized?.Trim(),
                IdIndustry      = specializedsMeta.IdIndustry?.Trim(),
                Address         = specializedsMeta.Address?.Trim(),
                Email           = specializedsMeta.Email?.Trim(),
                PhoneNumber     = specializedsMeta.PhoneNumber?.Trim(),
                Office          = specializedsMeta.Office?.Trim(),
                Note            = specializedsMeta.Note?.Trim(),
                LastUpdate      = DateTime.Now,
                IsActive        = true,
                IsDelete        = false
            };
            var Result = await _ispecializedRepository.UpdateAsync(_specializedupdate);

            if (Result >= 0)
            {
                return(new ActionResultReponese <string>(Result, "Update thanh cong ", "Specialized"));
            }
            return(new ActionResultReponese <string>(Result, "Update that bai", "Specialized"));
        }
コード例 #16
0
ファイル: SpecializedModel.cs プロジェクト: duongdg/webcv
 public bool Update(Specialized entity)
 {
     try
     {
         var Specialized = context.Specializeds.Find(entity.id_Specialized);
         Specialized.SpecializedName = entity.SpecializedName;
         Specialized.Status          = entity.Status;
         context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #17
0
        /* CREATE */
        public static void Add_Specialized(string Id, string Name, string Name_Class, string Subject_Name, string Major_Name)
        {
            var client      = ConnectNeo4J.Connection();
            var specialized = new Specialized {
                id = Id, name = Name, isDelete = false
            };

            client.Cypher.Create("(:Specialized {specialized})").WithParam("specialized", specialized).ExecuteWithoutResultsAsync().Wait();
            //client.Cypher.Match("(a:Specialized)", "(b:Class)").
            //    Where((Specialized a) => a.name == Name).
            //    AndWhere((Class b) => b.name == Name_Class).
            //    Create("(a)<-[:In_Specialized]-(b)").ExecuteWithoutResults();
            client.Cypher.Match("(a:Specialized)", "(b:Major)").
            Where((Specialized a) => a.name == Name).
            AndWhere((Major b) => b.name == Major_Name).
            Create("(b)-[:Belong_Specialized]->(a)").
            ExecuteWithoutResults();
        }
コード例 #18
0
        public void Rosser_Test()
        {
            Matrix3 R = Specialized.Rosser();


            EigenvalueDecomposition EofA = new EigenvalueDecomposition(R);

            Matrix3 V = EofA.V;

            // V is orthogonal V times V transpose is the identity
            Assert.That(Matrix3.Mult(V, Matrix3.Transpose(V)).ToFloatArray(), Is.EqualTo(Matrix3.Identity.ToFloatArray()).Within(.0000001));

            Matrix3 D    = EofA.getD();
            Matrix3 test = Matrix3.Mult(D, V.Inverted());

            test = Matrix3.Mult(V, test);

            Assert.That(test.ToFloatArray(), Is.EqualTo(R.ToFloatArray()).Within(.0000001).Percent);
        }
コード例 #19
0
 internal void DeleteTheSpecialized(Specialized aSpecializedObj)
 {
     try
     {
         connection.Open();
         string     selectQuery = @"DELETE FROM [tbl_specialized_information] WHERE [empsz_employee_id] ='" + aSpecializedObj.Id + "'  ";
         SqlCommand command     = new SqlCommand(selectQuery, connection);
         command.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
     }
 }
コード例 #20
0
      internal void UpdateTheOldSpAreaInforation(Specialized aSpecializedObj)
      {
          try
          {
              connection.Open();
              string     selectQuery = @"UPDATE [tbl_specialized_information]
 SET[spz_name] ='" + aSpecializedObj.Name + "' WHERE [empsz_employee_id] ='" + aSpecializedObj.Id + "'  ";
              SqlCommand command     = new SqlCommand(selectQuery, connection);
              command.ExecuteNonQuery();
          }
          catch (Exception ex)
          {
              throw new Exception(ex.Message);
          }
          finally
          {
              if (connection.State == ConnectionState.Open)
              {
                  connection.Close();
              }
          }
      }
コード例 #21
0
        private void SpecializeMembers()
        {
            var location = new Location(this);

            // TypeVar
            var fn = PythonFunctionType.Specialize("TypeVar", this, GetMemberDocumentation("TypeVar"));
            var o  = new PythonFunctionOverload(fn, location);

            o.SetParameters(new List <ParameterInfo> {
                new ParameterInfo("name", Interpreter.GetBuiltinType(BuiltinTypeId.Str), ParameterKind.Normal, null),
                new ParameterInfo("constraints", Interpreter.GetBuiltinType(BuiltinTypeId.Str), ParameterKind.List, null),
                new ParameterInfo("bound", Interpreter.GetBuiltinType(BuiltinTypeId.Str), ParameterKind.KeywordOnly, new PythonConstant(null, Interpreter.GetBuiltinType(BuiltinTypeId.NoneType))),
                new ParameterInfo("covariant", Interpreter.GetBuiltinType(BuiltinTypeId.Bool), ParameterKind.KeywordOnly, new PythonConstant(false, Interpreter.GetBuiltinType(BuiltinTypeId.Bool))),
                new ParameterInfo("contravariant", Interpreter.GetBuiltinType(BuiltinTypeId.Bool), ParameterKind.KeywordOnly, new PythonConstant(false, Interpreter.GetBuiltinType(BuiltinTypeId.Bool)))
            });

            // When called, create generic parameter type. For documentation
            // use original TypeVar declaration so it appear as a tooltip.
            o.SetReturnValueProvider((declaringModule, overload, args, indexSpan)
                                     => GenericTypeParameter.FromTypeVar(args, declaringModule, indexSpan));

            fn.AddOverload(o);
            _members["TypeVar"] = fn;

            // NewType
            _members["NewType"] = SpecializeNewType(location);

            // Type
            fn = PythonFunctionType.Specialize("Type", this, GetMemberDocumentation("Type"));
            o  = new PythonFunctionOverload(fn, location);
            // When called, create generic parameter type. For documentation
            // use original TypeVar declaration so it appear as a tooltip.
            o.SetReturnValueProvider((declaringModule, overload, args, indexSpan) => {
                var a = args.Values <IMember>();
                return(a.Count == 1 ? a[0] : Interpreter.UnknownType);
            });
            fn.AddOverload(o);
            _members["Type"] = fn;

            _members["Iterator"] = new SpecializedGenericType("Iterator", CreateIteratorType, this);

            _members["Iterable"]        = new SpecializedGenericType("Iterable", typeArgs => CreateListType("Iterable", BuiltinTypeId.List, typeArgs, false), this);
            _members["Sequence"]        = new SpecializedGenericType("Sequence", typeArgs => CreateListType("Sequence", BuiltinTypeId.List, typeArgs, false), this);
            _members["MutableSequence"] = new SpecializedGenericType("MutableSequence",
                                                                     typeArgs => CreateListType("MutableSequence", BuiltinTypeId.List, typeArgs, true), this);
            _members["List"] = new SpecializedGenericType("List",
                                                          typeArgs => CreateListType("List", BuiltinTypeId.List, typeArgs, true), this);

            _members["MappingView"] = new SpecializedGenericType("MappingView",
                                                                 typeArgs => CreateDictionary("MappingView", typeArgs, false), this);

            _members["KeysView"]   = new SpecializedGenericType("KeysView", CreateKeysViewType, this);
            _members["ValuesView"] = new SpecializedGenericType("ValuesView", CreateValuesViewType, this);
            _members["ItemsView"]  = new SpecializedGenericType("ItemsView", CreateItemsViewType, this);

            _members["AbstractSet"] = new SpecializedGenericType("AbstractSet",
                                                                 typeArgs => CreateListType("AbstractSet", BuiltinTypeId.Set, typeArgs, true), this);
            _members["Set"] = new SpecializedGenericType("Set",
                                                         typeArgs => CreateListType("Set", BuiltinTypeId.Set, typeArgs, true), this);
            _members["MutableSet"] = new SpecializedGenericType("MutableSet",
                                                                typeArgs => CreateListType("MutableSet", BuiltinTypeId.Set, typeArgs, true), this);
            _members["FrozenSet"] = new SpecializedGenericType("FrozenSet",
                                                               typeArgs => CreateListType("FrozenSet", BuiltinTypeId.Set, typeArgs, false), this);

            _members["Tuple"] = new SpecializedGenericType("Tuple", CreateTupleType, this);

            _members["Mapping"] = new SpecializedGenericType("Mapping",
                                                             typeArgs => CreateDictionary("Mapping", typeArgs, false), this);
            _members["MutableMapping"] = new SpecializedGenericType("MutableMapping",
                                                                    typeArgs => CreateDictionary("MutableMapping", typeArgs, true), this);
            _members["Dict"] = new SpecializedGenericType("Dict",
                                                          typeArgs => CreateDictionary("Dict", typeArgs, true), this);
            _members["OrderedDict"] = new SpecializedGenericType("OrderedDict",
                                                                 typeArgs => CreateDictionary("OrderedDict", typeArgs, true), this);
            _members["DefaultDict"] = new SpecializedGenericType("DefaultDict",
                                                                 typeArgs => CreateDictionary("DefaultDict", typeArgs, true), this);

            _members["Union"] = new SpecializedGenericType("Union", CreateUnion, this);

            _members["Counter"] = Specialized.Function("Counter", this, GetMemberDocumentation("Counter"),
                                                       Interpreter.GetBuiltinType(BuiltinTypeId.Int)).CreateInstance(ArgumentSet.WithoutContext);

            // TODO: make these classes that support __float__, etc per spec.
            //_members["SupportsInt"] = Interpreter.GetBuiltinType(BuiltinTypeId.Int);
            //_members["SupportsFloat"] = Interpreter.GetBuiltinType(BuiltinTypeId.Float);
            //_members["SupportsComplex"] = Interpreter.GetBuiltinType(BuiltinTypeId.Complex);
            //_members["SupportsBytes"] = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);
            _members["ByteString"] = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);

            fn = PythonFunctionType.Specialize("NamedTuple", this, GetMemberDocumentation("NamedTuple"));
            o  = new PythonFunctionOverload(fn, location);
            o.SetReturnValueProvider((declaringModule, overload, args, indexSpan)
                                     => CreateNamedTuple(args.Values <IMember>(), declaringModule, indexSpan));
            fn.AddOverload(o);
            _members["NamedTuple"] = fn;

            _members["Any"]    = new AnyType(this);
            _members["AnyStr"] = CreateAnyStr();

            _members["Optional"] = new SpecializedGenericType("Optional", CreateOptional, this);
            _members["Type"]     = new SpecializedGenericType("Type", CreateType, this);

            _members["Generic"] = new SpecializedGenericType("Generic", CreateGenericClassBase, this);
        }
コード例 #22
0
        private void SpecializeMembers()
        {
            var location = new Location(this, default);

            // TypeVar
            var fn = PythonFunctionType.Specialize("TypeVar", this, GetMemberDocumentation("TypeVar"));
            var o  = new PythonFunctionOverload(fn.Name, location);

            // When called, create generic parameter type. For documentation
            // use original TypeVar declaration so it appear as a tooltip.
            o.SetReturnValueProvider((interpreter, overload, args)
                                     => GenericTypeParameter.FromTypeVar(args, interpreter));

            fn.AddOverload(o);
            _members["TypeVar"] = fn;

            // NewType
            fn = PythonFunctionType.Specialize("NewType", this, GetMemberDocumentation("NewType"));
            o  = new PythonFunctionOverload(fn.Name, location);
            // When called, create generic parameter type. For documentation
            // use original TypeVar declaration so it appear as a tooltip.
            o.SetReturnValueProvider((interpreter, overload, args) => CreateTypeAlias(args.Values <IMember>()));
            fn.AddOverload(o);
            _members["NewType"] = fn;

            // Type
            fn = PythonFunctionType.Specialize("Type", this, GetMemberDocumentation("Type"));
            o  = new PythonFunctionOverload(fn.Name, location);
            // When called, create generic parameter type. For documentation
            // use original TypeVar declaration so it appear as a tooltip.
            o.SetReturnValueProvider((interpreter, overload, args) => {
                var a = args.Values <IMember>();
                return(a.Count == 1 ? a[0] : Interpreter.UnknownType);
            });
            fn.AddOverload(o);
            _members["Type"] = fn;

            _members["Iterator"] = new GenericType("Iterator", CreateIteratorType, this);

            _members["Iterable"]        = new GenericType("Iterable", typeArgs => CreateListType("Iterable", BuiltinTypeId.List, typeArgs, false), this);
            _members["Sequence"]        = new GenericType("Sequence", typeArgs => CreateListType("Sequence", BuiltinTypeId.List, typeArgs, false), this);
            _members["MutableSequence"] = new GenericType("MutableSequence",
                                                          typeArgs => CreateListType("MutableSequence", BuiltinTypeId.List, typeArgs, true), this);
            _members["List"] = new GenericType("List",
                                               typeArgs => CreateListType("List", BuiltinTypeId.List, typeArgs, true), this);

            _members["MappingView"] = new GenericType("MappingView",
                                                      typeArgs => CreateDictionary("MappingView", typeArgs, false), this);

            _members["KeysView"]   = new GenericType("KeysView", CreateKeysViewType, this);
            _members["ValuesView"] = new GenericType("ValuesView", CreateValuesViewType, this);
            _members["ItemsView"]  = new GenericType("ItemsView", CreateItemsViewType, this);

            _members["Set"] = new GenericType("Set",
                                              typeArgs => CreateListType("Set", BuiltinTypeId.Set, typeArgs, true), this);
            _members["MutableSet"] = new GenericType("MutableSet",
                                                     typeArgs => CreateListType("MutableSet", BuiltinTypeId.Set, typeArgs, true), this);
            _members["FrozenSet"] = new GenericType("FrozenSet",
                                                    typeArgs => CreateListType("FrozenSet", BuiltinTypeId.Set, typeArgs, false), this);

            _members["Tuple"] = new GenericType("Tuple", CreateTupleType, this);

            _members["Mapping"] = new GenericType("Mapping",
                                                  typeArgs => CreateDictionary("Mapping", typeArgs, false), this);
            _members["MutableMapping"] = new GenericType("MutableMapping",
                                                         typeArgs => CreateDictionary("MutableMapping", typeArgs, true), this);
            _members["Dict"] = new GenericType("Dict",
                                               typeArgs => CreateDictionary("Dict", typeArgs, true), this);
            _members["OrderedDict"] = new GenericType("OrderedDict",
                                                      typeArgs => CreateDictionary("OrderedDict", typeArgs, true), this);
            _members["DefaultDict"] = new GenericType("DefaultDict",
                                                      typeArgs => CreateDictionary("DefaultDict", typeArgs, true), this);

            _members["Union"] = new GenericType("Union", CreateUnion, this);

            _members["Counter"] = Specialized.Function("Counter", this, GetMemberDocumentation("Counter"),
                                                       new PythonInstance(Interpreter.GetBuiltinType(BuiltinTypeId.Int)));

            _members["SupportsInt"]     = Interpreter.GetBuiltinType(BuiltinTypeId.Int);
            _members["SupportsFloat"]   = Interpreter.GetBuiltinType(BuiltinTypeId.Float);
            _members["SupportsComplex"] = Interpreter.GetBuiltinType(BuiltinTypeId.Complex);
            _members["SupportsBytes"]   = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);
            _members["ByteString"]      = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);

            fn = PythonFunctionType.Specialize("NamedTuple", this, GetMemberDocumentation("NamedTuple"));
            o  = new PythonFunctionOverload(fn.Name, location);
            o.SetReturnValueProvider((interpreter, overload, args) => CreateNamedTuple(args.Values <IMember>()));
            fn.AddOverload(o);
            _members["NamedTuple"] = fn;

            _members["Any"] = new AnyType(this);

            // AnyStr
            var str        = Interpreter.GetBuiltinType(BuiltinTypeId.Str);
            var bytes      = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);
            var unicode    = Interpreter.GetBuiltinType(BuiltinTypeId.Unicode);
            var anyStrName = new PythonConstant("AnyStr", str);

            var anyStrArgs = Interpreter.LanguageVersion.Is3x()
                ? new IMember[] { anyStrName, str, bytes }
                : new IMember[] { anyStrName, str, unicode };

            _members["AnyStr"] = GenericTypeParameter.FromTypeVar(new ArgumentSet(anyStrArgs), this);

            _members["Optional"] = new GenericType("Optional", CreateOptional, this);
            _members["Type"]     = new GenericType("Type", CreateType, this);

            _members["Generic"] = new GenericType("Generic", CreateGenericClassParameter, this);
        }
コード例 #23
0
    //public double GetTwo() {
    //   return two;
    //}
    //public void SetTwo(double two) {
    //   this.two = two;
    //}
 public void TestHierarchy() {
    Serializer serializer = new Persister();
    Specialized special = new Specialized(1L, 2.0, "a", "b", 1, 2);
    validate(special, serializer);
 }
コード例 #24
0
 public void SaveTheSpecializedInformation(Specialized aSpecializedObj)
 {
     aSpecializedGatewayObj.SaveTheSpecializedInformation(aSpecializedObj);
 }
コード例 #25
0
 internal Specialized GetAllSpecializedInformationIsNotSelected(Specialized aSpecializedObj)
 {
     return(aSpecializedGatewayObj.GetAllSpecializedInformationIsNotSelected(aSpecializedObj));
 }
コード例 #26
0
 public void UpdateTheSpecialized(Specialized aSpecializedObj)
 {
     aSpecializedGatewayObj.UpdateTheOldSpAreaInforation(aSpecializedObj);
 }
コード例 #27
0
 public void DeleteTheSpecialized(Specialized aSpecializedObj)
 {
     aSpecializedGatewayObj.DeleteTheSpecialized(aSpecializedObj);
 }
コード例 #28
0
        public void LargeSymetric()
        {
            Matrix3 K = Specialized.K(100);

            TestDecomposition(K);
        }
コード例 #29
0
        private void SpecializeMembers()
        {
            var location = new Location(this);

            _members["TypeVar"] = new TypeVar(this);
            _members["NewType"] = SpecializeNewType(location);
            _members["Type"]    = new Type(this);

            _members["Iterator"] = new SpecializedGenericType("Iterator", CreateIteratorType, this);

            _members["Iterable"]        = new SpecializedGenericType("Iterable", typeArgs => CreateListType("Iterable", BuiltinTypeId.List, typeArgs, false), this);
            _members["Sequence"]        = new SpecializedGenericType("Sequence", typeArgs => CreateListType("Sequence", BuiltinTypeId.List, typeArgs, false), this);
            _members["MutableSequence"] = new SpecializedGenericType("MutableSequence",
                                                                     typeArgs => CreateListType("MutableSequence", BuiltinTypeId.List, typeArgs, true), this);
            _members["List"] = new SpecializedGenericType("List",
                                                          typeArgs => CreateListType("List", BuiltinTypeId.List, typeArgs, true), this);

            _members["MappingView"] = new SpecializedGenericType("MappingView",
                                                                 typeArgs => CreateDictionary("MappingView", typeArgs, false), this);

            _members["KeysView"]   = new SpecializedGenericType("KeysView", CreateKeysViewType, this);
            _members["ValuesView"] = new SpecializedGenericType("ValuesView", CreateValuesViewType, this);
            _members["ItemsView"]  = new SpecializedGenericType("ItemsView", CreateItemsViewType, this);

            _members["AbstractSet"] = new SpecializedGenericType("AbstractSet",
                                                                 typeArgs => CreateListType("AbstractSet", BuiltinTypeId.Set, typeArgs, true), this);
            _members["Set"] = new SpecializedGenericType("Set",
                                                         typeArgs => CreateListType("Set", BuiltinTypeId.Set, typeArgs, true), this);
            _members["MutableSet"] = new SpecializedGenericType("MutableSet",
                                                                typeArgs => CreateListType("MutableSet", BuiltinTypeId.Set, typeArgs, true), this);
            _members["FrozenSet"] = new SpecializedGenericType("FrozenSet",
                                                               typeArgs => CreateListType("FrozenSet", BuiltinTypeId.Set, typeArgs, false), this);

            _members["Tuple"] = new SpecializedGenericType("Tuple", CreateTupleType, this);

            _members["Mapping"] = new SpecializedGenericType("Mapping",
                                                             typeArgs => CreateDictionary("Mapping", typeArgs, false), this);
            _members["MutableMapping"] = new SpecializedGenericType("MutableMapping",
                                                                    typeArgs => CreateDictionary("MutableMapping", typeArgs, true), this);
            _members["Dict"] = new SpecializedGenericType("Dict",
                                                          typeArgs => CreateDictionary("Dict", typeArgs, true), this);
            _members["OrderedDict"] = new SpecializedGenericType("OrderedDict",
                                                                 typeArgs => CreateDictionary("OrderedDict", typeArgs, true), this);
            _members["DefaultDict"] = new SpecializedGenericType("DefaultDict",
                                                                 typeArgs => CreateDictionary("DefaultDict", typeArgs, true), this);

            _members["Union"] = new SpecializedGenericType("Union", CreateUnion, this);

            _members["Counter"] = Specialized.Function("Counter", this, GetMemberDocumentation("Counter"),
                                                       Interpreter.GetBuiltinType(BuiltinTypeId.Int)).CreateInstance(ArgumentSet.WithoutContext);

            // TODO: make these classes that support __float__, etc per spec.
            //_members["SupportsInt"] = Interpreter.GetBuiltinType(BuiltinTypeId.Int);
            //_members["SupportsFloat"] = Interpreter.GetBuiltinType(BuiltinTypeId.Float);
            //_members["SupportsComplex"] = Interpreter.GetBuiltinType(BuiltinTypeId.Complex);
            //_members["SupportsBytes"] = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);
            _members["ByteString"] = Interpreter.GetBuiltinType(BuiltinTypeId.Bytes);

            _members["NamedTuple"] = new NamedTuple(this);

            _members["Any"]    = new AnyType(this);
            _members["AnyStr"] = CreateAnyStr();

            _members["Optional"] = new SpecializedGenericType("Optional", CreateOptional, this);
            _members["Type"]     = new SpecializedGenericType("Type", CreateType, this);

            _members["Generic"] = new SpecializedGenericType("Generic", CreateGenericClassBase, this);
        }