InsertAt() public method

public InsertAt ( int index, char c ) : void
index int
c char
return void
Ejemplo n.º 1
0
		public unsafe void UnsafeConstructor ()
		{
			try {
				SecureString ss = null;
				char[] data = new char[] { 'a', 'b', 'c' };
				fixed (char* p = &data[0]) {
					ss = new SecureString (p, data.Length);
				}
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (3, ss.Length, "3");
				ss.AppendChar ('a');
				Assert.AreEqual (4, ss.Length, "4");
				ss.Clear ();
				Assert.AreEqual (0, ss.Length, "0b");
				ss.InsertAt (0, 'b');
				Assert.AreEqual (1, ss.Length, "1b");
				ss.SetAt (0, 'c');
				Assert.AreEqual (1, ss.Length, "1c");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
Ejemplo n.º 2
0
 public HBaseWriter()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"];
     SecureString pw = new SecureString();
     for(int i = 0; i < HadoopUserPassword.Length; i++){
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
     //create table and enable the hbase writer
     if (!client.ListTables().name.Contains(this.HBaseTableName))
     {
         // Create the table
         var tableSchema = new TableSchema();
         tableSchema.name = this.HBaseTableName;
         tableSchema.columns.Add(new ColumnSchema { name = "d" });
         client.CreateTable(tableSchema);
         Console.WriteLine("Table \"{0}\" created.", this.HBaseTableName);
     }
     WriterThread = new Thread(new ThreadStart(WriterThreadFunction));
     WriterThread.Start();
 }
Ejemplo n.º 3
0
        public static byte[] ToUtf8(this string text)
        {
            //Debug.Assert(sizeof(char) == 2);
             SecureString m_secString = new SecureString();
             for (int index = 0; index < text.Length; index++)
             {
            m_secString.InsertAt(index, text[index]);
             }

             if (m_secString != null) {
            char[] vChars = new char[m_secString.Length];
            IntPtr p = Marshal.SecureStringToGlobalAllocUnicode (m_secString);
            for (int i = 0; i < m_secString.Length; ++i)
               vChars [i] = (char)Marshal.ReadInt16 (p, i * 2);
            Marshal.ZeroFreeGlobalAllocUnicode (p);

            byte[] pb = StrUtil.Utf8.GetBytes (vChars);
            Array.Clear (vChars, 0, vChars.Length);

            return pb;
             }
             else {
            return StrUtil.Utf8.GetBytes (string.Empty);
             }
        }
Ejemplo n.º 4
0
 //static SecureEdit()
 //{
 //   // On Windows 98 / ME, an ANSI character must be used as
 //   // password char!
 //   if(Environment.OSVersion.Platform == PlatformID.Win32Windows)
 //      m_chPasswordChar = '\u00D7';
 //}
 /// <summary>
 /// Construct a new <c>SecureEdit</c> object. You must call the
 /// <c>Attach</c> member function to associate the secure edit control
 /// with a text box.
 /// </summary>
 public SecureEdit(string masterKey)
 {
     try
      {
     m_secString = new SecureString();
     for (int index = 0; index < masterKey.Length; index++)
     {
        m_secString.InsertAt(index, masterKey[index]);
     }
      }
      catch (NotSupportedException)
      {
      } // Windows 98 / ME
 }
Ejemplo n.º 5
0
 public HBaseReader()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     SecureString pw = new SecureString();
     for (int i = 0; i < HadoopUserPassword.Length; i++)
     {
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
 }
Ejemplo n.º 6
0
		public void DefaultConstructor ()
		{
			try {
				SecureString ss = new SecureString ();
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (0, ss.Length, "0");
				ss.AppendChar ('a');
				Assert.AreEqual (1, ss.Length, "1");
				ss.Clear ();
				Assert.AreEqual (0, ss.Length, "0b");
				ss.InsertAt (0, 'b');
				Assert.AreEqual (1, ss.Length, "1b");
				ss.SetAt (0, 'c');
				Assert.AreEqual (1, ss.Length, "1c");
				Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
Ejemplo n.º 7
0
		public void InsertAt_UsedLikeAppendChar () // #350820
		{
			SecureString ss = new SecureString ();
			ss.AppendChar ('T');
			Assert.AreEqual (1, ss.Length, "AppendChar");
			ss.InsertAt (1, 'e');
			Assert.AreEqual (2, ss.Length, "InsertAt");
		}
Ejemplo n.º 8
0
		public void InsertAt_BiggerThanLength ()
		{
			SecureString ss = new SecureString ();
			ss.InsertAt (1, 'a');
		}
Ejemplo n.º 9
0
		public void InsertAt_Negative ()
		{
			SecureString ss = new SecureString ();
			ss.InsertAt (-1, 'a');
		}