Пример #1
0
 public DataTable getNguoiDung(clsNguoiDung_DTO nguoidungDTO)
 {
     ListDictionary _list = new ListDictionary();
     _list.Add("TenDangNhap", nguoidungDTO.TenDangNhap);
     _list.Add("MaDiemThi", nguoidungDTO.MaDiemThi);
     _list.Add("MatKhau", nguoidungDTO.MatKhau);
     _list.Add("Ho", nguoidungDTO.Ho);
     _list.Add("Ten", nguoidungDTO.Ten);
     _list.Add("CMND", nguoidungDTO.CMND);
     _list.Add("NgaySinh", nguoidungDTO.NgaySinh);
     _list.Add("DiaChi", nguoidungDTO.DiaChi);
     _list.Add("DienThoai", nguoidungDTO.DienThoai);
     _list.Add("Email", nguoidungDTO.Email);
     _list.Add("NgayDK", nguoidungDTO.NgayDK);
     _list.Add("TrangThai", nguoidungDTO.TrangThai);
     _list.Add("MaNhom", nguoidungDTO.MaNhom);
     DataTable dt = new DataTable();
     try
     {
         dt = obj.GetDataTable("Select_Nguoi_Dung",_list, CommandType.StoredProcedure);
     }
     catch
     {
         dt = null;
     }
     return dt;
 }
    public CatalogPropertiesDialog(Catalog catalog)
    {
        this.catalog = catalog;
        this.Title = String.Format (Mono.Posix.Catalog.GetString ("{0} properties"), catalog.Name);
        this.HasSeparator = false;

        cancelButton = (Button)this.AddButton (Stock.Cancel, 0);
        okButton     = (Button)this.AddButton (Stock.Ok, 1);
        cancelButton.Clicked += OnCancelButtonClicked;
        okButton.Clicked     += OnOkButtonClicked;
        VBox vBox = this.VBox;

        HBox titleBox = new HBox ();
        Gtk.Frame frame = new Frame ("<b>"+Mono.Posix.Catalog.GetString ("Columns to show")+"</b>");
        ((Label)(frame.LabelWidget)).UseMarkup = true;
        titleBox.PackEnd (frame);
        vBox.PackStart (titleBox);

        VBox columnsBox = new VBox ();

        columns = catalog.Columns;
        Hashtable columnsToShow = catalog.ColumnsToShow;
        checks = new Hashtable ();
        foreach (string colName in columns.Keys) {
            if (colName.Equals ("id")) continue;
            CheckButton check = new CheckButton ((string)columns[colName]);
            check.Active = (bool)columnsToShow[colName];
            checks.Add (columns[colName], check);
            columnsBox.PackStart (check);
        }

        frame.Add (columnsBox);

        this.ShowAll();
    }
Пример #3
0
    public DataTable getThiSinh(clsThiSinh_DTO thisinhDTO)
    {
        ListDictionary _list = new ListDictionary();
        _list.Add("MaTS", thisinhDTO.MaTS);
        _list.Add("MatKhau", thisinhDTO.MatKhau);
        _list.Add("HoTenLot", thisinhDTO.HoTenLot);
        _list.Add("Ten", thisinhDTO.Ten);
        _list.Add("QuocTich", thisinhDTO.QuocTich);
        _list.Add("NgaySinh", thisinhDTO.NgaySinh);
        _list.Add("NguyenQuan", thisinhDTO.NguyenQuan);
        _list.Add("NoiDKHoKhau", thisinhDTO.NoiDKHoKhau);
        _list.Add("NoiThuongTru", thisinhDTO.NoiThuongTru);
        _list.Add("DienThoai", thisinhDTO.DienThoai);
        _list.Add("DVCongTac", thisinhDTO.DVCongTac);
        _list.Add("CMND", thisinhDTO.CMND);
        _list.Add("NgayCapCMND", thisinhDTO.NgayCapCMND);
        _list.Add("NoiCapCMND", thisinhDTO.NoiCapCMND);
        _list.Add("TrinhDoVanHoa", thisinhDTO.TrinhDoVanHoa);
        _list.Add("NgayDKThi", thisinhDTO.NgayDKThi);
        _list.Add("MaCaThi", thisinhDTO.MaCaThi);
        _list.Add("MaPhong", thisinhDTO.MaPhong);

        DataTable dt = new DataTable();
        try
        {
            dt = obj.GetDataTable("Select_Thi_Sinh", _list, CommandType.StoredProcedure);
        }
        catch
        {
            dt = null;
        }
        return dt;
    }
Пример #4
0
    protected void gridHistoricData_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try {
            if (e.CommandName == "Insert") {
                string[] fields = { "Date", "CASH", "COMM", "GLEQ", "HEDG", "LOSH", "PREQ" };
                ListDictionary listDictionary = new ListDictionary();

                foreach (var f in fields) {
                    string boxName = "text" + f + "Add";
                    TextBox textBox = (TextBox)gridHistoricData.FooterRow.FindControl(boxName);
                    if (f == "Date") {
                        DateTime dt = DateTime.Parse(textBox.Text);
                        listDictionary.Add(f, dt);
                    } else {
                        double db = Double.Parse(textBox.Text);
                        listDictionary.Add(f, db);
                    }
                    textBox.Text = String.Empty;
                }

                sourceHistoricData.Insert(listDictionary);
                gridHistoricData.DataBind();
            }
        } catch (Exception ex) {
            showException(ex, labelException, "adding the asset class prices");
        }
    }
Пример #5
0
    // Submit Button adds a new guestbook entry to the database,
    // clears the form and displays the updated list of guestbook entries
    protected void submitButton_Click( object sender, EventArgs e )
    {
        // create dictionary of parameters for inserting
          ListDictionary insertParameters = new ListDictionary();

          // add current date and the user's name, e-mail address
          // and message to dictionary of insert parameters
          insertParameters.Add( "Date", DateTime.Now.ToShortDateString() );
          insertParameters.Add( "Name", nameTextBox.Text );
          insertParameters.Add( "Email", emailTextBox.Text );
          insertParameters.Add( "Message1", messageTextBox.Text );

          // execute an INSERT LINQ statement to add a new entry to the
          // Messages table in the Guestbook data context that contains the
          // current date and the user's name, e-mail address and message
          messagesLinqDataSource.Insert( insertParameters );

          // clear the TextBoxes
          nameTextBox.Text = String.Empty;
          emailTextBox.Text = String.Empty;
          messageTextBox.Text = String.Empty;

          // update the GridView with the new database table contents
          messagesGridView.DataBind();
    }
Пример #6
0
        static void Main(string[] args)
        {
            ListDictionary<string, string> listDictionary = new ListDictionary<string, string>();
            ListDictionary<int,int> listDictionaryInt = new ListDictionary<int,int>();
            //ListDictionary<byte> listDictionaryByte = new ListDictionary<byte>();

            listDictionary.addItemToDictionary("hello");
            
            Console.WriteLine(listDictionary.getItemFromDictionaryByHash(532));

            listDictionaryInt.addItemToDictionary(500);
            Console.WriteLine(listDictionaryInt.getItemFromDictionaryByHash(149));


            
            Console.ReadLine();





            //Console.WriteLine("would you like to search or add?");
            //string answer = Console.ReadLine().ToString();
            //switch (answer)
            //{
            //    case "search":
            //        //call function to search
            //        listDictionary.calculateHash(answer);
            //        break;

            //    case "add":
            //        //call function to add
            //        break;
            //}
        }
Пример #7
0
 //lay cau lua chon theo cau hoi
 public DataTable getcauluachon_cauhoi(string MaCauHoi)
 {
     //DataTable dt_dethi1 = new DataTable();
     DataTable dt_cauhoi_cauluachon = new DataTable();
     try
     {
        // dt_dethi1 = obj.GetDataTable("select top 0 * from View_cauhoi_cauluachon", CommandType.Text);
        // dt_cauhoi_cauluachon = obj.GetDataTable("Select_cauluachontheocauhoi", //getcauluachon_cauhoi(MaCauHoi);
         //foreach (DataRow dr in dt_cauhoi_cauluachon.Rows)
         //{
             ListDictionary _list = new ListDictionary();
             _list.Add("MaCauHoi", MaCauHoi);
         //    _list.Add("NoiDung", dr["NoiDung"].ToString());
         //    _list.Add("HinhAnh", dr["HinhAnh"].ToString());
         //    _list.Add("NoiDungCLC", dr["NoiDungCLC"].ToString());
         //    //_list.Add("NoiDung", dr["NoiDung"].ToString());
             dt_cauhoi_cauluachon = obj.GetDataTable("Select_cauluachontheocauhoi", _list, CommandType.StoredProcedure);
            //for (int i = 0; i < dt_cauhoi_cauluachon.Rows.Count; i++)
            // {
            //     DataRow drDeThi = dt_dethi1.NewRow();
            //     drDeThi["MaCauHoi"] = dt_cauhoi_cauluachon.Rows[i]["MaCauHoi"];
            //     drDeThi["NoiDung"] = dt_cauhoi_cauluachon.Rows[i]["NoiDung"];
            //     drDeThi["HinhAnh"] = dt_cauhoi_cauluachon.Rows[i]["HinhAnh"];
            //     drDeThi["NoiDungCLC"] = dt_cauhoi_cauluachon.Rows[i]["NoiDungCLC"];
            //     dt_dethi1.Rows.Add(drDeThi);
            // }
         }
     //}
     catch
     {
         dt_cauhoi_cauluachon = null;
     }
     return dt_cauhoi_cauluachon;
 }
Пример #8
0
            public void AddRemoveAddItemsDoesntChangeItemsOrder(int itemsToAddCount, int itemsToRemoveCount)
            {
                var dict = new ListDictionary<string, int>();

                for (var i = 0; i < itemsToAddCount; i++)
                {
                    var key = i.ToString();
                    dict[key] = 0;
                }

                for (var i = 0; i < itemsToRemoveCount; i++)
                {
                    var key = (itemsToAddCount - itemsToRemoveCount + i).ToString();
                    dict.Remove(key);
                }

                for (var i = itemsToAddCount - itemsToRemoveCount; i < itemsToAddCount; i++)
                {
                    var key = i.ToString();
                    dict[key] = 0;
                }

                var keyValuePairs = dict.ToList();
                for (var i = 0; i < itemsToAddCount; i++)
                {
                    Assert.AreEqual(i.ToString(), keyValuePairs[i].Key);
                }
            }
Пример #9
0
    public static void FindSpriteNamesInAllScene()
    {
        ListDictionary<string, string> spriteNames = new ListDictionary<string, string>();

        string[] scenes = (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray();
        foreach (string scene in scenes)
        {
            EditorApplication.OpenScene(scene);

            Transform[] allTrnasforms = GameObject.FindObjectsOfType<Transform>();
            foreach (Transform transform in allTrnasforms)
            {
                UISprite sprite = transform.GetComponent<UISprite>();
                if (sprite != null && !spriteNames.ContainsValue(scene, sprite.spriteName))
                    spriteNames.Add(scene, sprite.spriteName);
            }
        }

        string log = string.Empty;
        foreach (string scene in scenes)
        {
            if (!spriteNames.ContainsKey(scene))
                continue;

            log += string.Format("Scene : {0}\n", scene);

            string spriteNameInScene = string.Empty;
            foreach (string spriteName in spriteNames[scene])
                spriteNameInScene += string.Format("{0}\n", spriteName);

            log += string.Format("{0}\n\n", spriteNameInScene);
        }

        Debug.LogWarning(log);
    }
        internal void Stop()
        {
            foreach (var rShip in r_Snapshots.Keys)
                rShip.UpdateAnchorageRepairStatus(false);

            TimeToComplete = null;
            r_Snapshots = null;
        }
Пример #11
0
 /// <summary>Default constructor.</summary>
 public SQLNETItem()
 {
     CacheKey = Guid.NewGuid().ToString();
     ParameterTables = new ListDictionary();
     ParameterTypes = new SharedCache<string, Type>();
     ParameterValues = new ListDictionary();
     ParallelItems = new SharedBucketList();
 }
Пример #12
0
 private static ListDictionary Fill(ListDictionary ld, KeyValuePair<string, string>[] data)
 {
     foreach (KeyValuePair<string, string> d in data)
     {
         ld.Add(d.Key, d.Value);
     }
     return ld;
 }
 protected override ICollection NonGenericICollectionFactory(int count)
 {
     ListDictionary list = new ListDictionary();
     int seed = 13453;
     for (int i = 0; i < count; i++)
         list.Add(CreateT(seed++), CreateT(seed++));
     return list.Keys;
 }
        internal void Update()
        {
            var rResult = new ListDictionary<FleetLoSFormulaInfo, double>();
            foreach (var rCalculation in FleetLoSFormulaInfo.Formulas.Select(r => new { Formula = r, LoS = r.Calculate(r_Fleet) }))
                rResult.Add(rCalculation.Formula, rCalculation.LoS);

            Formulas = rResult;
            OnPropertyChanged(nameof(Formulas));
        }
Пример #15
0
    protected void GetBuddyList()
    {
        ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign];
        int userId = (int)Session[Constant.NormalUserSessionSign];

        DateTime time = DateTime.Now;

        if ((Session["cometchat_buddytime"] == null) || (Request["initialize"] == "1") || (Session["cometchat_buddytime"] != null) && ((DateTime.Now - (DateTime)Session["cometchat_buddytime"]).Seconds > 60))
        {
            IDbCommand cmdGetBuddy = session.Connection.CreateCommand();
            cmdGetBuddy.CommandText = "select users.id as userid, user.username, user.last_update, chat_status.message, chat_status.status from userlist join users on  userlist.relationid = users.id left join chat_status on users.id = chat_status.userid where userlist.friend = 'yes' and userlist.userid = @userId order by username asc";
            IDbDataParameter paramUserId = cmdGetBuddy.CreateParameter();
            paramUserId.DbType = DbType.Int32;
            paramUserId.ParameterName = "@userid";
            paramUserId.Value = userId;
            cmdGetBuddy.Parameters.Add(paramUserId);
            session.Transaction.Enlist(cmdGetBuddy);

            IDataReader readerGetBuddyList = cmdGetBuddy.ExecuteReader();
            ListDictionary chat = new ListDictionary();
            IList<ListDictionary> buddyList = new List<ListDictionary>();
            

            while (readerGetBuddyList.Read())
            {
                string status = readerGetBuddyList["status"].ToString();

                if ((time - (DateTime)readerGetBuddyList["last_update"]).Seconds < 120 && status != "invisible" && status != "offline")
                {
                    if (status != "busy")
                        status = "available";
                }
                else
                    status = "offline";

                string message = readerGetBuddyList["message"].ToString();
                if (string.IsNullOrEmpty(message))
                    message = "I'm " + TextUtility.UppercaseFirst(status);


                ListDictionary buddy = new ListDictionary();
                buddy["id"] = readerGetBuddyList["userid"];
                buddy["name"] = readerGetBuddyList["username"];
                buddy["status"] = status;
                buddy["message"] = message;
                buddy["time"] = readerGetBuddyList["last_update"];
                buddyList.Add(buddy);
            }
            readerGetBuddyList.Close();

            Session["cometchat_buddytime"] = time;

            if (buddyList.Count > 0)
                response["buddylist"] = buddyList;

        }
    }
Пример #16
0
	void Start() {
		DontDestroyOnLoad(gameObject);
		breakdownObjects = new Dictionary<Type, int>();
		objectDictionary = new ListDictionary<System.Type, UnityEngine.Object>();
		baseLineSizes = new Dictionary<Type, int>();
		meshes = new List<Mesh>();
		Resources.UnloadUnusedAssets();
		InvokeRepeating("Detect",3f,3f);
	}
Пример #17
0
 public FriendDictionary(IEnumerable<TwitterUser> users)
 {
     FriendsByCount = new ListDictionary<int, TwitterUser>();
     foreach (TwitterUser user in users)
     {
         friendsByName.Add(user.Name, user);
         FriendsByCount.Add(user.FriendCount, user);
     }
 }
Пример #18
0
 public static void Constructor_DefaultTests(ListDictionary ld)
 {
     Assert.Equal(0, ld.Count);
     Assert.False(ld.IsReadOnly);
     Assert.Empty(ld);
     Assert.Empty(ld.Keys);
     Assert.Empty(ld.Values);
     Assert.False(ld.Contains(new object()));
     Assert.Null(ld[new object()]);
 }
 StringResources()
 {
     r_InstalledLanguages = new ListDictionary<string, LanguageInfo>()
     {
         { "Japanese", new LanguageInfo("Japanese", "ja-JP", "日本語") },
         { "SimplifiedChinese", new LanguageInfo("SimplifiedChinese", "zh-Hans", "简体中文") },
         { "English", new LanguageInfo("English", "en", "English") },
     };
     InstalledLanguages = r_InstalledLanguages.Values.ToArray();
 }
        public CustomerAccountService()
        {
            customerAccounts = new ListDictionary<int, CustomerAccount>();

            customerAccounts.Add(1, new CustomerAccount(123456781, "Checking", 1842.75M));
            customerAccounts.Add(1, new CustomerAccount(123456782, "Savings", 9367.92M));

            customerAccounts.Add(2, new CustomerAccount(987654321, "Interest Checking", 2496.44M));
            customerAccounts.Add(2, new CustomerAccount(987654322, "Money Market", 21959.38M));
            customerAccounts.Add(2, new CustomerAccount(987654323, "Car Loan", -19483.95M));
        }
Пример #21
0
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
 {
     if (e.CommandName == RadGrid.InitInsertCommandName)
     {
         e.Canceled = true;
         //Prepare an IDictionary with the predefined values
         ListDictionary newValues = new ListDictionary();
         newValues["Subject"] = "New Person";
         //Insert the item and rebind
         e.Item.OwnerTableView.InsertItem(newValues);
     }
 }
Пример #22
0
		public HybridDictionary (int initialSize, bool caseInsensitive)
		{
			this.caseInsensitive = caseInsensitive;

			IComparer comparer = caseInsensitive ? CaseInsensitiveComparer.DefaultInvariant : null;
			IHashCodeProvider hcp = caseInsensitive ? CaseInsensitiveHashCodeProvider.DefaultInvariant : null;

			if (initialSize <= switchAfter)
				list = new ListDictionary (comparer);
			else
				hashtable = new Hashtable (initialSize, hcp, comparer);
		}
        public void Initialize()
        {
            r_InstalledLanguages = new ListDictionary<string, LanguageInfo>(StringComparer.InvariantCultureIgnoreCase);

            var rRootDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            r_StringResourceDirectory = new DirectoryInfo(Path.Combine(rRootDirectory, "Resources", "Strings"));
            if (r_StringResourceDirectory.Exists)
                foreach (var rLanguageDirectory in r_StringResourceDirectory.EnumerateDirectories())
                    InitializeMainResource(rLanguageDirectory);

            InstalledLanguages = r_InstalledLanguages.Values.ToList().AsReadOnly();
        }
Пример #24
0
 public int Check_TenDangNhap(string strTenDangNhap)
 {
     try
       {
           ListDictionary _list = new ListDictionary();
           _list.Add("TenDangNhap", strTenDangNhap);
           int iReturn = obj.ExcSql("Check_TenDangNhap", _list, CommandType.StoredProcedure);
           return iReturn;
       }
       catch (Exception)
       {
           return -1111;
       }
 }
 public int Check_STT(string strSTT)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("STT", strSTT);
         int iReturn = obj.ExcSql("Check_Phan_Cong_Coi_Thi", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         return -1111;
     }
 }
Пример #26
0
 public int Check_MaCaThi(string strMaCaThi)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("MaCaThi", strMaCaThi);
         int iReturn = obj.ExcSql("Check_CaThi", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         return -1111;
     }
 }
Пример #27
0
 public int Delete(clsCauLuaChon_DTO clcDTO)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("MaCauLuaChon", clcDTO.MaCauLuaChon);
         int iReturn = obj.ExcSql("Delete_Cau_Lua_Chon", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         //return ex.Message;
         return -1111;
     }
 }
        internal EquipmentGroupByLevel(EquipmentGroupByMasterID rpOwner, EquipmentGroupingKey rpKey, IEnumerable<Equipment> rpEquipment)
        {
            r_Owner = rpOwner;

            Key = rpKey;
            r_Fleets = new ListDictionary<int, EquipmentGroupByFleet>();

            Count = rpEquipment.Count();

            var rUnequipedEquipment = KanColleGame.Current.Port.UnequippedEquipment[r_Owner.Info.Type];
            if (rUnequipedEquipment == null)
                RemainingCount = 0;
            else
                RemainingCount = rUnequipedEquipment.Count(r => r.Info == r_Owner.Info && r.Level == Key.Level && r.Proficiency == Key.Proficiency);
        }
 public int Delete(clsNhomNguoiDung_DTO nhomndDTO)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("MaNhom", nhomndDTO.MaNhom);
         int iReturn = obj.ExcSql("Delete_Nhom_Nguoi_Dung", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         //return ex.Message;
         return -1111;
     }
 }
 public int Delete(clsPhanCongCoiThi_DTO pcctDTO)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("STT", pcctDTO.STT);
         int iReturn = obj.ExcSql("Delete_Phan_Cong_Coi_Thi", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         //return ex.Message;
         return -1111;
     }
 }
Пример #31
0
        public bool Search(int pageIndex, int pageSize, ref int totalRecords, int?IDPlugin, string Name, string JSfileName, string Version, string Description, string Settings, string Css, string JSinit, string sortExpression)
        {
            ListDictionary parameters = new ListDictionary();

            parameters.Add(new SqlParameter("@PageIndex", SqlDbType.Int), pageIndex);
            parameters.Add(new SqlParameter("@PageSize", SqlDbType.Int), pageSize);

            SqlParameter sqlParam = new SqlParameter("@TotalRecords", SqlDbType.Int);

            sqlParam.Direction = ParameterDirection.InputOutput;
            parameters.Add(sqlParam, totalRecords);

            if (IDPlugin.HasValue)
            {
                parameters.Add(new SqlParameter("@IDPlugin", SqlDbType.Int), IDPlugin);
            }

            if (!string.IsNullOrEmpty(Name))
            {
                parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 128), Name);
            }

            if (!string.IsNullOrEmpty(JSfileName))
            {
                parameters.Add(new SqlParameter("@JSfileName", SqlDbType.NVarChar, 256), JSfileName);
            }

            if (!string.IsNullOrEmpty(Version))
            {
                parameters.Add(new SqlParameter("@Version", SqlDbType.NVarChar, 128), Version);
            }

            if (!string.IsNullOrEmpty(Description))
            {
                parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar), Description);
            }

            if (!string.IsNullOrEmpty(Settings))
            {
                parameters.Add(new SqlParameter("@Settings", SqlDbType.NVarChar), Settings);
            }

            if (!string.IsNullOrEmpty(Css))
            {
                parameters.Add(new SqlParameter("@Css", SqlDbType.NVarChar), Css);
            }

            if (!string.IsNullOrEmpty(JSinit))
            {
                parameters.Add(new SqlParameter("@JSinit", SqlDbType.NVarChar), JSinit);
            }

            if (!string.IsNullOrEmpty(sortExpression))
            {
                parameters.Add(new SqlParameter("@SortExpression", SqlDbType.NVarChar, 1000), sortExpression);
            }

            base.LoadFromSql("Ciemesus_tPluginsSearch", parameters, System.Data.CommandType.StoredProcedure);

            totalRecords = (int)sqlParam.Value;
            return(true);
        }
Пример #32
0
        public void Constructor_Default()
        {
            ListDictionary ld = new ListDictionary();

            BasicTests(ld);
        }
Пример #33
0
        public void Constructor_IComparer()
        {
            ListDictionary ld = new ListDictionary(new CaseInsensitiveComparer());

            BasicTests(ld);
        }
Пример #34
0
        private void ParseXml(XmlTextReader reader)
        {
            bool success = false;

            try
            {
                try
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            string s = reader.LocalName;

                            if (reader.LocalName.Equals(ResXResourceWriter.AssemblyStr))
                            {
                                ParseAssemblyNode(reader);
                            }
                            else if (reader.LocalName.Equals(ResXResourceWriter.DataStr))
                            {
                                ParseDataNode(reader, false);
                            }
                            else if (reader.LocalName.Equals(ResXResourceWriter.ResHeaderStr))
                            {
                                ParseResHeaderNode(reader);
                            }
                            else if (reader.LocalName.Equals(ResXResourceWriter.MetadataStr))
                            {
                                ParseDataNode(reader, true);
                            }
                        }
                    }

                    success = true;
                }
                catch (SerializationException se)
                {
                    Point                  pt         = GetPosition(reader);
                    string                 newMessage = string.Format(SR.SerializationException, reader[ResXResourceWriter.TypeStr], pt.Y, pt.X, se.Message);
                    XmlException           xml        = new XmlException(newMessage, se, pt.Y, pt.X);
                    SerializationException newSe      = new SerializationException(newMessage, xml);

                    throw newSe;
                }
                catch (TargetInvocationException tie)
                {
                    Point        pt                  = GetPosition(reader);
                    string       newMessage          = string.Format(SR.InvocationException, reader[ResXResourceWriter.TypeStr], pt.Y, pt.X, tie.InnerException.Message);
                    XmlException xml                 = new XmlException(newMessage, tie.InnerException, pt.Y, pt.X);
                    TargetInvocationException newTie = new TargetInvocationException(newMessage, xml);

                    throw newTie;
                }
                catch (XmlException e)
                {
                    throw new ArgumentException(string.Format(SR.InvalidResXFile, e.Message), e);
                }
                catch (Exception e)
                {
                    if (ClientUtils.IsSecurityOrCriticalException(e))
                    {
                        throw;
                    }
                    else
                    {
                        Point        pt    = GetPosition(reader);
                        XmlException xmlEx = new XmlException(e.Message, e, pt.Y, pt.X);
                        throw new ArgumentException(string.Format(SR.InvalidResXFile, xmlEx.Message), xmlEx);
                    }
                }
            }
            finally
            {
                if (!success)
                {
                    resData     = null;
                    resMetadata = null;
                }
            }

            bool validFile = false;

            if (resHeaderMimeType == ResXResourceWriter.ResMimeType)
            {
                Type readerType = typeof(ResXResourceReader);
                Type writerType = typeof(ResXResourceWriter);

                string readerTypeName = resHeaderReaderType;
                string writerTypeName = resHeaderWriterType;
                if (readerTypeName != null && readerTypeName.IndexOf(',') != -1)
                {
                    readerTypeName = readerTypeName.Split(',')[0].Trim();
                }
                if (writerTypeName != null && writerTypeName.IndexOf(',') != -1)
                {
                    writerTypeName = writerTypeName.Split(',')[0].Trim();
                }

                if (readerTypeName != null &&
                    writerTypeName != null &&
                    readerTypeName.Equals(readerType.FullName) &&
                    writerTypeName.Equals(writerType.FullName))
                {
                    validFile = true;
                }
            }

            if (!validFile)
            {
                resData     = null;
                resMetadata = null;
                throw new ArgumentException(SR.InvalidResXFileReaderWriterTypes);
            }
        }
Пример #35
0
        public void Remove()
        {
            ListDictionary ld = new ListDictionary();

            ld.Remove(null);
        }
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_ReceiptDocumentLoadAll]", parameters));
        }
Пример #37
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "LoadAllLogEntryStatus]", parameters));
        }
Пример #38
0
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[proc_GRUPO_ESTADOSLoadAll]", parameters));
        }
Пример #39
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            CatalogEntryDto dto = (CatalogEntryDto)context["CatalogEntryDto"];

            /*
             *          if (CatalogEntryId > 0 && dto == null)
             *                  dto = CatalogContext.Current.GetCatalogEntryDto(CatalogEntryId);
             *          else if (CatalogEntryId == 0)
             *                  dto = new CatalogEntryDto();
             * */

            foreach (UserControl ctrl in SeoCtrl.Controls)
            {
                IDictionary newContext = new ListDictionary();
                CatalogEntryDto.CatalogItemSeoRow seoRow = null;

                if (dto.CatalogItemSeo.Count > 0)
                {
                    // find appropriate row
                    DataRow[] rows = dto.CatalogItemSeo.Select(String.Format("LanguageCode = '{0}'", ((SeoTab)ctrl).LanguageCode));

                    if (rows.Length > 0)
                    {
                        seoRow = (CatalogEntryDto.CatalogItemSeoRow)rows[0];
                    }
                    else
                    {
                        seoRow = dto.CatalogItemSeo.NewCatalogItemSeoRow();
                        seoRow.ApplicationId  = CatalogConfiguration.Instance.ApplicationId;
                        seoRow.CatalogEntryId = CatalogEntryId == 0 ? -1 : CatalogEntryId;
                        seoRow.Uri            = String.Empty;
                    }
                }
                else
                {
                    seoRow = dto.CatalogItemSeo.NewCatalogItemSeoRow();
                    seoRow.ApplicationId  = CatalogConfiguration.Instance.ApplicationId;
                    seoRow.CatalogEntryId = CatalogEntryId == 0 ? -1 : CatalogEntryId;
                    seoRow.Uri            = String.Empty;
                }

                // Auto generate the URL if empty
                if (String.IsNullOrEmpty(seoRow.Uri))
                {
                    string name     = dto.CatalogEntry.Count > 0 ? dto.CatalogEntry[0].Name : "";
                    string langCode = ((SeoTab)ctrl).LanguageCode;
                    string url      = String.Format("{0}.aspx", CommerceHelper.CleanUrlField(name));

                    int index = 1;
                    while (CatalogContext.Current.GetCatalogEntryByUriDto(url, langCode).CatalogEntry.Count != 0 || CatalogContext.Current.GetCatalogNodeDto(url, langCode).CatalogNode.Count != 0)
                    {
                        url = String.Format("{0}-{1}.aspx", CommerceHelper.CleanUrlField(name), index.ToString());
                        index++;
                    }

                    // Check
                    seoRow.Uri = url;
                }

                newContext.Add("CatalogItemSeoRow", seoRow);

                ((IAdminTabControl)ctrl).SaveChanges(newContext);

                if (seoRow.RowState == DataRowState.Detached)
                {
                    dto.CatalogItemSeo.Rows.Add(seoRow);
                }
            }
        }
Пример #40
0
 public ServiceDispatcher(MetaStrategyBase metaStrategyBase)
 {
     this.metaStrategyBase = metaStrategyBase;
     this.services         = new ListDictionary();
 }
Пример #41
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("PL_EMPLOYEES", parameters));
        }
Пример #42
0
        public void Test01()
        {
            IntlStrings    intl;
            ListDictionary ld;

            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aA",
                "text",
                "     SPaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // keys for simple string values
            string[] keys =
            {
                "zero",
                "oNe",
                " ",
                "",
                "aa",
                "1",
                System.DateTime.Today.ToString(),
                "$%^#",
                Int32.MaxValue.ToString(),
                "     spaces",
                "2222222222222222222222222"
            };

            int cnt = 0;            // Count

            // initialize IntStrings
            intl = new IntlStrings();


            // [] ListDictionary is constructed as expected
            //-----------------------------------------------------------------

            ld = new ListDictionary();

            // [] set Item() on empty dictionary
            //
            cnt = ld.Count;
            Assert.Throws <ArgumentNullException>(() => { ld[null] = "item"; });

            cnt = ld.Count;
            ld["some_string"] = "item";
            if (ld.Count != cnt + 1)
            {
                Assert.False(true, string.Format("Error, failed to add item"));
            }
            if (String.Compare(ld["some_string"].ToString(), "item") != 0)
            {
                Assert.False(true, string.Format("Error, failed to set item"));
            }

            cnt = ld.Count;
            Hashtable lbl = new Hashtable();
            ArrayList b   = new ArrayList();

            ld[lbl] = b;
            if (ld.Count != cnt + 1)
            {
                Assert.False(true, string.Format("Error, failed to add item"));
            }
            if (!ld[lbl].Equals(b))
            {
                Assert.False(true, string.Format("Error, failed to set object-item"));
            }

            // [] set Item() on dictionary filled with simple strings
            //

            cnt = ld.Count;
            int len = values.Length;

            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != cnt + len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, cnt + len));
            }
            //

            for (int i = 0; i < len; i++)
            {
                if (!ld.Contains(keys[i]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain key", i));
                }
                ld[keys[i]] = "newValue" + i;
                if (String.Compare(ld[keys[i]].ToString(), "newValue" + i) != 0)
                {
                    Assert.False(true, string.Format("Error, failed to set value", i));
                }
                ld[keys[i]] = b;
                if (!ld[keys[i]].Equals(b))
                {
                    Assert.False(true, string.Format("Error, failed to set object-value", i));
                }
            }


            //
            // Intl strings
            // [] set Item() on dictionary filled with Intl strings
            //

            string[] intlValues = new string[len * 2 + 1];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2 + 1; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetRandomString(MAX_LEN);
                }
                intlValues[i] = val;
            }

            Boolean caseInsensitive = false;

            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }

            cnt = ld.Count;
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != (cnt + len))
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, cnt + len));
            }

            for (int i = 0; i < len; i++)
            {
                //
                if (!ld.Contains(intlValues[i + len]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain key", i));
                }
                ld[intlValues[i + len]] = intlValues[len * 2];
                if (String.Compare(ld[intlValues[i + len]].ToString(), intlValues[len * 2]) != 0)
                {
                    Assert.False(true, string.Format("Error, failed to set value", i));
                }
                ld[intlValues[i + len]] = b;
                if (!ld[intlValues[i + len]].Equals(b))
                {
                    Assert.False(true, string.Format("Error, failed to set object-value", i));
                }
            }


            //
            // [] Case sensitivity
            //

            string[] intlValuesLower = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }

            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }

            ld.Clear();
            //
            // will use first half of array as values and second half as keys
            //
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);     // adding uppercase strings
            }

            //
            for (int i = 0; i < len; i++)
            {
                // uppercase key
                if (!ld.Contains(intlValues[i + len]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain key", i));
                }

                ld[intlValues[i + len]] = b;
                if (!ld[intlValues[i + len]].Equals(b))
                {
                    Assert.False(true, string.Format("Error, failed to set via uppercase key", i));
                }
            }

            ld.Clear();
            //
            // will use first half of array as values and second half as keys
            //
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);     // adding uppercase strings
            }

            //  LD is case-sensitive by default  - new entries should be added
            for (int i = 0; i < len; i++)
            {
                // lowercase key
                cnt = ld.Count;
                ld[intlValuesLower[i + len]] = "item";
                if (ld[intlValuesLower[i + len]] == null)
                {
                    Assert.False(true, string.Format("Error, failed: returned non-null for lowercase key", i));
                }
                if (!caseInsensitive && String.Compare(ld[intlValues[i + len]].ToString(), intlValues[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, failed: changed value via lowercase key", i));
                }
                // lowercase itemshould be added to the dictionary
                if (String.Compare(ld[intlValuesLower[i + len]].ToString(), "item") != 0)
                {
                    Assert.False(true, string.Format("Error, failed: didn't add when set via lowercase key", i));
                }
            }

            //
            // [] set Item() on filled dictionary with case-insensitive comparer

            ld = new ListDictionary(new InsensitiveComparer());

            len = values.Length;
            ld.Clear();
            string kk = "key";

            for (int i = 0; i < len; i++)
            {
                ld.Add(kk + i, values[i]);
            }
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
            }

            for (int i = 0; i < len; i++)
            {
                if (ld[kk.ToUpper() + i] == null)
                {
                    Assert.False(true, string.Format("Error, returned null for differently cased key", i));
                }
                else
                {
                    ld[kk.ToUpper() + i] = "Item" + i;
                    if (String.Compare(ld[kk.ToUpper() + i].ToString(), "Item" + i) != 0)
                    {
                        Assert.False(true, string.Format("Error, failed to set value", i));
                    }
                    ld[kk.ToUpper() + i] = b;
                    if (!ld[kk.ToUpper() + i].Equals(b))
                    {
                        Assert.False(true, string.Format("Error, failed to set object-value", i));
                    }
                }
            }


            //
            //   [] set Item(null) on filled LD
            //
            ld  = new ListDictionary();
            cnt = ld.Count;
            if (ld.Count < len)
            {
                ld.Clear();
                for (int i = 0; i < len; i++)
                {
                    ld.Add(keys[i], values[i]);
                }
            }

            Assert.Throws <ArgumentNullException>(() => { ld[null] = "item"; });

            //  [] set Item(special_object)
            //
            ld = new ListDictionary();

            ld.Clear();
            b = new ArrayList();
            ArrayList b1 = new ArrayList();

            lbl = new Hashtable();
            Hashtable lbl1 = new Hashtable();

            ld.Add(lbl, b);
            ld.Add(lbl1, b1);
            if (ld.Count != 2)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, 2));
            }

            ld[lbl] = b1;
            if (!ld[lbl].Equals(b1))
            {
                Assert.False(true, string.Format("Error, failed to set special object"));
            }
            ld[lbl1] = b;
            if (!ld[lbl1].Equals(b))
            {
                Assert.False(true, string.Format("Error, failed to set special object"));
            }

            //
            //  [] set to null
            //
            ld             = new ListDictionary();
            cnt            = ld.Count;
            ld["null_key"] = null;
            if (ld.Count != cnt + 1)
            {
                Assert.False(true, string.Format("Error, failed to add entry"));
            }
            if (ld["null_key"] != null)
            {
                Assert.False(true, string.Format("Error, failed to add entry with null value"));
            }

            cnt = ld.Count;
            ld.Add("key", "value");
            if (ld.Count != cnt + 1)
            {
                Assert.False(true, string.Format("Error, failed to add entry"));
            }

            cnt       = ld.Count;
            ld["key"] = null;
            if (ld["key"] != null)
            {
                Assert.False(true, string.Format("Error, failed to set entry to null "));
            }
        }
Пример #43
0
 public Category(Dictionary <String, int> mainCategory, ListDictionary subCategories)
 {
     this.mainCategory  = mainCategory;
     this.subCategories = subCategories;
 }
Пример #44
0
 public void SetUp()
 {
     list = new ListDictionary <string, object>();
 }
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_PickListLoadAll]", parameters);
		}
Пример #46
0
        public void Test01()
        {
            ListDictionary ld;
            int            cnt;

            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aA",
                "text",
                "     SPaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // keys for simple string values
            string[] keys =
            {
                "zero",
                "oNe",
                " ",
                "",
                "aa",
                "1",
                System.DateTime.Today.ToString(),
                "$%^#",
                Int32.MaxValue.ToString(),
                "     spaces",
                "2222222222222222222222222"
            };

            // [] ListDictionary.IsReadOnly should return false
            //-----------------------------------------------------------------

            ld = new ListDictionary();

            //  [] on empty dictionary
            //
            if (ld.IsReadOnly)
            {
                Assert.False(true, string.Format("Error, returned true for empty dictionary"));
            }

            //  [] on filled dictionary
            //

            ld.Clear();
            cnt = values.Length;
            for (int i = 0; i < cnt; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != cnt)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, cnt));
            }
            if (ld.IsReadOnly)
            {
                Assert.False(true, string.Format("Error, returned true for filled dictionary"));
            }
        }
 internal XmlSchemaObjectTable()
 {
     table = new ListDictionary();
 }
Пример #48
0
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[proc_SUPLIDORESLoadAll]", parameters));
        }
Пример #49
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_UserLabouringTypesLoadAll]", parameters));
        }
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_ProductOwnershipTypeLoadAll]", parameters));
        }
Пример #51
0
        public void OnAuthenticateRequest(object source, EventArgs eventArgs)
        {
            HttpApplication app = (HttpApplication)source;

            if (PathOfExtraUsersFile == String.Empty)
            {
                string extraUsersFile = ConfigurationSettings.AppSettings["Digest.Samples.DigestAuthenticationModule_ExtraUsersFiles"];
                PathOfExtraUsersFile = app.Request.MapPath(extraUsersFile);
            }

            try
            {
                byte[] bytes = new byte[app.Request.InputStream.Length];
                app.Request.InputStream.Read(bytes, 0, bytes.Length);
                app.Request.InputStream.Position = 0;
                string content = Encoding.ASCII.GetString(bytes);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
                manager.AddNamespace("s", "http://www.w3.org/2003/05/soap-envelope");

                XmlNode node = doc.SelectSingleNode("/s:Envelope/s:Body", manager);
                if (node != null && node.ChildNodes.Count > 0)
                {
                    XmlNode requestNode = node.ChildNodes[0];
                    if (requestNode.NamespaceURI.ToLower() == "http://www.onvif.org/ver10/device/wsdl")
                    {
                        if (PRE_AUTH == null)
                        {
                            PRE_AUTH = LoadPublicMethods(app);
                        }

                        if (AuthList == null)
                        {
                            AuthList = LoadLocalPublicMethods(app);
                        }

                        if (PRE_AUTH.Contains(requestNode.Name) || AuthList.Contains(requestNode.Name))
                        {
                            app.Context.User = new GenericPrincipal(new GenericIdentity("public", "Rassoc.Samples.Digest"), new string[] { "public" });
                            return;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }

            string authStr = app.Request.Headers["Authorization"];

            if (authStr == null || authStr.Length == 0)
            {
                // No credentials; anonymous request
                return;
            }

            authStr = authStr.Trim();
            if (authStr.IndexOf("Digest", 0) != 0)
            {
                // Don't understand this header...we'll pass it along and
                // assume someone else will handle it
                return;
            }

            authStr = authStr.Substring(7);

            ListDictionary reqInfo = new ListDictionary();

            string[] elems = authStr.Split(new char[] { ',' });
            foreach (string elem in elems)
            {
                // form key="value"
                string[] parts = elem.Split(new char[] { '=' }, 2);
                string   key   = parts[0].Trim(new char[] { ' ', '\"' });
                string   val   = parts[1].Trim(new char[] { ' ', '\"' });
                reqInfo.Add(key, val);
            }

            string username = (string)reqInfo["username"];
            string password = "";

            string[] roles;
            bool     bOk = GetPasswordAndRoles(app, username, out password, out roles);

            if (!bOk)
            {
                // Invalid username; deny access
                DenyAccess(app);
                return;
            }

            string realm = ConfigurationSettings.AppSettings["Rassoc.Samples.DigestAuthenticationModule_Realm"];

            // calculate the Digest hashes

            // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
            string A1 = String.Format("{0}:{1}:{2}", (string)reqInfo["username"], realm, password);

            System.Diagnostics.Debug.WriteLine(string.Format("A1: {0}", A1));

            // H(A1) = MD5(A1)
            string HA1 = GetMD5HashBinHex(A1);

            System.Diagnostics.Debug.WriteLine(string.Format("HA1: {0}", HA1));

            // A2 = Method ":" digest-uri-value
            string A2 = String.Format("{0}:{1}", app.Request.HttpMethod, (string)reqInfo["uri"]);

            System.Diagnostics.Debug.WriteLine(string.Format("A2: {0}", A2));

            // H(A2)
            string HA2 = GetMD5HashBinHex(A2);

            System.Diagnostics.Debug.WriteLine(string.Format("HA2: {0}", HA2));

            // KD(secret, data) = H(concat(secret, ":", data))
            // if qop == auth:
            // request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
            //                              ":" nc-value
            //                              ":" unq(cnonce-value)
            //                              ":" unq(qop-value)
            //                              ":" H(A2)
            //                            ) <">
            // if qop is missing,
            // request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">

            string unhashedDigest;

            if (reqInfo["qop"] != null)
            {
                unhashedDigest = String.Format("{0}:{1}:{2}:{3}:{4}:{5}",
                                               HA1,
                                               (string)reqInfo["nonce"],
                                               (string)reqInfo["nc"],
                                               (string)reqInfo["cnonce"],
                                               (string)reqInfo["qop"],
                                               HA2);
            }
            else
            {
                unhashedDigest = String.Format("{0}:{1}:{2}",
                                               HA1,
                                               (string)reqInfo["nonce"],
                                               HA2);
            }

            System.Diagnostics.Debug.WriteLine(string.Format("unhashedDigest: {0}", unhashedDigest));

            string hashedDigest = GetMD5HashBinHex(unhashedDigest);

            System.Diagnostics.Debug.WriteLine(string.Format("hashedDigest: {0}", hashedDigest));

            bool isNonceStale = !IsValidNonce((string)reqInfo["nonce"]);

            app.Context.Items["staleNonce"] = isNonceStale;

            bool realmPresent = reqInfo.Contains("realm");

            if (((string)reqInfo["response"] == hashedDigest) && (!isNonceStale) && (realmPresent))
            {
                if ((string)reqInfo["nc"] == "00000003")
                {
                    string nextNonce = "";
                    nextNonce = nextNonce + "nextnonce=\"";
                    nextNonce = nextNonce + GetCurrentNonce();
                    nextNonce = nextNonce + "\"";

                    app.Response.AddHeader("Authentication-Info", nextNonce);
                }
                app.Context.User = new GenericPrincipal(new GenericIdentity(username, "Rassoc.Samples.Digest"), roles);
            }
            else
            {
                // Invalid credentials or stale nonce; deny access
                DenyAccess(app);
                return;
            }
        }
Пример #52
0
        public void Test01()
        {
            IntlStrings    intl;
            ListDictionary ld;

            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aA",
                "text",
                "     SPaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // keys for simple string values
            string[] keys =
            {
                "zero",
                "oNe",
                " ",
                "",
                "aa",
                "1",
                System.DateTime.Today.ToString(),
                "$%^#",
                Int32.MaxValue.ToString(),
                "     spaces",
                "2222222222222222222222222"
            };

            int cnt = 0;            // Count

            // initialize IntStrings
            intl = new IntlStrings();


            // [] ListDictionary is constructed as expected
            //-----------------------------------------------------------------

            ld = new ListDictionary();

            // [] Contains() on empty dictionary
            //
            Assert.Throws <ArgumentNullException>(() => { ld.Contains(null); });

            if (ld.Contains("some_string"))
            {
                Assert.False(true, string.Format("Error, empty dictionary contains some_object"));
            }
            if (ld.Contains(new Hashtable()))
            {
                Assert.False(true, string.Format("Error, empty dictionary contains some_object"));
            }

            //  [] simple strings and Contains()
            //

            cnt = ld.Count;
            int len = values.Length;

            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length));
            }
            //
            for (int i = 0; i < len; i++)
            {
                if (!ld.Contains(keys[i]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, keys[i]));
                }
            }


            //
            // Intl strings
            // [] Intl strings and Contains()
            //

            string[] intlValues = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetRandomString(MAX_LEN);
                }
                intlValues[i] = val;
            }

            Boolean caseInsensitive = false;

            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }

            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != (len))
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
            }

            for (int i = 0; i < len; i++)
            {
                //
                if (!ld.Contains(intlValues[i + len]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, intlValues[i + len]));
                }
            }


            //
            // [] Case sensitivity
            // by default ListDictionary is case-sensitive
            //

            string[] intlValuesLower = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }

            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }

            ld.Clear();
            //
            // will use first half of array as values and second half as keys
            //
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);     // adding uppercase strings
            }

            //
            for (int i = 0; i < len; i++)
            {
                // uppercase key
                if (!ld.Contains(intlValues[i + len]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain added uppercase \"{1}\"", i, intlValues[i + len]));
                }

                // lowercase key
                if (!caseInsensitive && ld.Contains(intlValuesLower[i + len]))
                {
                    Assert.False(true, string.Format("Error, contains lowercase \"{1}\" - should not", i, intlValuesLower[i + len]));
                }
            }

            //  [] different_in_casing_only keys and Contains()
            //

            ld.Clear();
            string[] ks = { "Key", "kEy", "keY" };
            len = ks.Length;
            for (int i = 0; i < len; i++)
            {
                ld.Add(ks[i], "Value" + i);
            }
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
            }

            if (ld.Contains("Value0"))
            {
                Assert.False(true, string.Format("Error, returned true when should not"));
            }
            for (int i = 0; i < len; i++)
            {
                if (!ld.Contains(ks[i]))
                {
                    Assert.False(true, string.Format("Error, returned false when true expected", i));
                }
            }


            //
            //   [] Contains(null) - for filled dictionary
            //
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            Assert.Throws <ArgumentNullException>(() => { ld.Contains(null); });

            // [] Contains() for case-insensitive comparer
            //

            ld = new ListDictionary(new InsensitiveComparer());
            ld.Clear();
            len = ks.Length;
            ld.Add(ks[0], "Value0");

            for (int i = 1; i < len; i++)
            {
                Assert.Throws <ArgumentException>(() => { ld.Add(ks[i], "Value" + i); });
            }
            if (ld.Count != 1)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, 1));
            }

            if (ld.Contains("Value0"))
            {
                Assert.False(true, string.Format("Error, returned true when should not"));
            }
            for (int i = 0; i < len; i++)
            {
                if (!ld.Contains(ks[i]))
                {
                    Assert.False(true, string.Format("Error, returned false when true expected", i));
                }
            }
            if (!ld.Contains("KEY"))
            {
                Assert.False(true, string.Format("Error, returned false non-existing-cased key"));
            }

            // [] Contains() and objects_not_overriding_Equals
            //

            ld = new ListDictionary();
            ld.Clear();
            Hashtable lbl  = new Hashtable();
            Hashtable lbl1 = new Hashtable();
            ArrayList b    = new ArrayList();
            ArrayList b1   = new ArrayList();

            ld.Add(lbl, b);
            ld.Add(lbl1, b1);

            Assert.Throws <ArgumentException>(() => { ld.Add(lbl, "Hello"); });

            if (ld.Count != 2)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, 2));
            }

            if (!ld.Contains(lbl))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
            if (!ld.Contains(lbl1))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
            if (ld.Contains(new Hashtable()))
            {
                Assert.False(true, string.Format("Error, returned true when false expected"));
            }

            //  [] Contains and Special_Comparer for objects
            //

            ld          = new ListDictionary(new SpecialComparer());
            lbl["foo"]  = "Hello";
            lbl1["foo"] = "Hello";
            ld.Add(lbl, b);

            Assert.Throws <ArgumentException>(() => { ld.Add(lbl1, b1); });

            if (ld.Count != 1)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, 1));
            }

            if (!ld.Contains(lbl))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
            if (!ld.Contains(lbl1))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
            lbl1["foo"] = "HELLO";
            if (ld.Contains(lbl1))
            {
                Assert.False(true, string.Format("Error, returned true when false expected"));
            }

            //  [] Contains() and special_structs_not_overriding_Equals
            ld = new ListDictionary();
            SpecialStruct s = new SpecialStruct();

            s.Num = 1;
            s.Wrd = "one";
            SpecialStruct s1 = new SpecialStruct();

            s.Num = 1;
            s.Wrd = "one";
            ld.Add(s, "first");
            ld.Add(s1, "second");
            if (ld.Count != 2)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, 2));
            }
            if (!ld.Contains(s))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
            if (!ld.Contains(s1))
            {
                Assert.False(true, string.Format("Error, returned false when true expected"));
            }
        }
Пример #53
0
        public void CopyTo2()
        {
            ListDictionary ld = new ListDictionary();

            ld.CopyTo(new int[1], -1);
        }
Пример #54
0
 public NodeKeyValueCollection(ListDictionary list, bool isKeys)
 {
     _list   = list;
     _isKeys = isKeys;
 }
Пример #55
0
        public void CopyTo1()
        {
            ListDictionary ld = new ListDictionary();

            ld.CopyTo(null, 0);
        }
Пример #56
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_TestPerfectionScoreScale_MLLoadAll]", parameters));
        }
Пример #57
0
        public void Constructor_IComparer_Null()
        {
            ListDictionary ld = new ListDictionary(null);

            BasicTests(ld);
        }
Пример #58
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int            iCountErrors    = 0;
        int            iCountTestcases = 0;
        IntlStrings    intl;
        String         strLoc = "Loc_000oo";
        ListDictionary ld;

        string [] values =
        {
            "",
            " ",
            "a",
            "aA",
            "text",
            "     SPaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "oNe",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            ld = new ListDictionary();
            Console.WriteLine("1. Contains() on empty dictionary");
            iCountTestcases++;
            Console.WriteLine("     - Contains(null)");
            try
            {
                ld.Contains(null);
                iCountErrors++;
                Console.WriteLine("Err_0001a, no exception");
            }
            catch (ArgumentNullException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("     - Contains(some_object)");
            if (ld.Contains("some_string"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0001c, empty dictionary contains some_object");
            }
            Console.WriteLine("2. add simple strings and check Contains()");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            cnt = ld.Count;
            int len = values.Length;
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", ld.Count, values.Length);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!ld.Contains(keys[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, doesn't contain \"{1}\"", i, keys[i]);
                }
            }
            Console.WriteLine("3. add intl strings check Contains()");
            strLoc = "Loc_003oo";
            iCountTestcases++;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }
            iCountTestcases++;
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != (len))
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", ld.Count, len);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!ld.Contains(intlValues[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, doesn't contain \"{1}\"", i, intlValues[i + len]);
                }
            }
            Console.WriteLine("4. case sensitivity");
            strLoc = "Loc_004oo";
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!ld.Contains(intlValues[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, doesn't contain added uppercase \"{1}\"", i, intlValues[i + len]);
                }
                iCountTestcases++;
                if (!caseInsensitive && ld.Contains(intlValuesLower[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, contains lowercase \"{1}\" - should not", i, intlValuesLower[i + len]);
                }
            }
            Console.WriteLine("5. similar_but_different_in_casing keys and Contains()");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            ld.Clear();
            string [] ks = { "Key", "kEy", "keY" };
            len = ks.Length;
            for (int i = 0; i < len; i++)
            {
                ld.Add(ks[i], "Value" + i);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {0} instead of {1}", ld.Count, len);
            }
            iCountTestcases++;
            if (ld.Contains("Value0"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, returned true when should not");
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!ld.Contains(ks[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005c_{0}, returned false when true expected", i);
                }
            }
            Console.WriteLine("6. Contains(null) for filled dictionary");
            strLoc = "Loc_006oo";
            iCountTestcases++;
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            try
            {
                ld.Contains(null);
                iCountErrors++;
                Console.WriteLine("Err_0006a, no exception");
            }
            catch (ArgumentNullException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("7. Contains() for case-insensitive comparer");
            ld     = new ListDictionary(new Co8686_InsensitiveComparer());
            strLoc = "Loc_007oo";
            iCountTestcases++;
            ld.Clear();
            len = ks.Length;
            ld.Add(ks[0], "Value0");
            for (int i = 1; i < len; i++)
            {
                try
                {
                    ld.Add(ks[i], "Value" + i);
                    iCountErrors++;
                    Console.WriteLine("Err_0007a_{0}, no exception", i);
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine("_{0}, Expected exception: {1}", i, e.Message);
                }
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0007b_{0}, unexpected exception: {1}", i, ex.ToString());
                }
            }
            if (ld.Count != 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0007c, count is {0} instead of {1}", ld.Count, 1);
            }
            iCountTestcases++;
            if (ld.Contains("Value0"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0007d, returned true when should not");
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!ld.Contains(ks[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0007e_{0}, returned false when true expected", i);
                }
            }
            iCountTestcases++;
            if (!ld.Contains("KEY"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0007f, returned false non-existing-cased key");
            }
            Console.WriteLine("10. Contains() and SpecialStructs_not_overriding_Equals");
            ld     = new ListDictionary();
            strLoc = "Loc_010oo";
            iCountTestcases++;
            Co8686_SpecialStruct s = new Co8686_SpecialStruct();
            s.Num = 1;
            s.Wrd = "one";
            Co8686_SpecialStruct s1 = new Co8686_SpecialStruct();
            s.Num = 1;
            s.Wrd = "one";
            ld.Add(s, "first");
            ld.Add(s1, "second");
            if (ld.Count != 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_0010a, count is {0} instead of {1}", ld.Count, 2);
            }
            iCountTestcases++;
            if (!ld.Contains(s))
            {
                iCountErrors++;
                Console.WriteLine("Err_0010b, returned false when true expected");
            }
            iCountTestcases++;
            if (!ld.Contains(s1))
            {
                iCountErrors++;
                Console.WriteLine("Err_0010c, returned false when true expected");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #59
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_CreditOrderLineItemLoadAll]", parameters));
        }
Пример #60
0
        //=================================================================
        //      public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return(base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_tblSubscribeLoadAll]", parameters));
        }