Exemple #1
0
        public static void commit(NcDBContext db, string[] query)
        {
            var ns = from m in db.Ncs select m;
            // Somehow this fixes certain LINQ errors.
            string qa = query[0];
            string qb = query[1];
            string qc = query[2];

            ns = ns.Where(s => s.A.Equals(qa) && s.B.Equals(qb) && s.C.Equals(qc));
            List <Nc> preld = ns.ToList();

            if (preld.Count < 1)
            {
                Nc n = new Nc();
                n.A     = qa;
                n.B     = qb;
                n.C     = qc;
                n.Count = 1;
                db.Ncs.Add(n);
                db.SaveChanges();
            }
            else
            {
                preld[0].Count          += 1;
                db.Entry(preld[0]).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Exemple #2
0
 public void GetParameters()
 {
     KaTb.Text      = K.ToString() + ";";
     tetanaTb.Text  = Tn.ToString() + ";";
     tetasaTb.Text  = Ts.ToString() + ";";
     tetacaTb.Text  = Tc.ToString() + ";";
     NcaTb.Text     = Nc.ToString() + ";";
     LaTb.Text      = L.ToString() + ";";
     lowerkaTb.Text = k.ToString() + ";";
     IaTb.Text      = i.ToString() + ";";
 }
Exemple #3
0
        public byte[] Encode()
        {
            Encoding encoding;

            if (!string.IsNullOrEmpty(Charset))
            {
                encoding = Encoding.GetEncoding(Charset);
            }
            else
            {
                encoding = Encoding.UTF8;
            }

            using (var memory = new MemoryStream()) {
                byte[] buf;

                buf = Encoding.ASCII.GetBytes("username=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(UserName);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",realm=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(Realm);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",nonce=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(Nonce);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",cnonce=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(CNonce);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",nc=");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Nc.ToString("X8"));
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes(",qop=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Qop);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",digest-uri=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(DigestUri.ToString());
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",response=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Response);
                memory.Write(buf, 0, buf.Length);
                buf = new byte[] { (byte)'"' };
                memory.Write(buf, 0, buf.Length);

                if (MaxBuf > 0)
                {
                    buf = Encoding.ASCII.GetBytes(",maxbuf=");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(MaxBuf.ToString());
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Charset))
                {
                    buf = Encoding.ASCII.GetBytes(",charset=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Charset);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Algorithm))
                {
                    buf = Encoding.ASCII.GetBytes(",algorithm=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Algorithm);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Cipher))
                {
                    buf = Encoding.ASCII.GetBytes(",cipher=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Cipher);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(AuthZid))
                {
                    buf = Encoding.ASCII.GetBytes(",authzid=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(AuthZid);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                return(memory.ToArray());
            }
        }