public void SaveStream(System.IO.Stream stream)
 {
     using(Stream conStream= Console.OpenStandardOutput())
     {
         stream.CopyTo(conStream);
     }
 }
Esempio n. 2
0
 public static Object[] sortFactsByTemplate(System.Collections.Generic.IList<Object> facts)
 {
     Object[] sorted = new object[facts.Count];
     facts.CopyTo(sorted, 0);
     Arrays.sort(sorted, TEMPLATECOMP);
     return sorted;
 }
        public void Decrypt(System.IO.Stream input, System.IO.Stream output, string password)
        {
            if(input == null)
                throw new System.ArgumentNullException("input");
            if(output == null)
                throw new System.ArgumentNullException("output");
            if(string.IsNullOrEmpty(password))
                throw new System.ArgumentException("Must not be null or empty.", "password");

            byte[] hashedPassword = HashAlgorithm.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password));

            // Create a decrytor to perform the stream transform.
            ICryptoTransform encryptor = Algorithm.CreateDecryptor(hashedPassword.Take(32).ToArray(), hashedPassword.Skip(48).ToArray());

            using (MemoryStream msEncrypt = new MemoryStream())
            {
                using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                {
                    input.CopyTo(csEncrypt);
                    csEncrypt.FlushFinalBlock();
                    msEncrypt.Position = 0;
                    msEncrypt.CopyTo(output);
                }
            }
        }
 public void SaveStream(System.IO.Stream stream)
 {
     using (Stream conStream = client.OpenWrite(url))
     {
         stream.CopyTo(conStream);
     }
 }
Esempio n. 5
0
        public System.IO.Stream UploadImage(System.IO.Stream messageBody, String catalog, string id)
        {
            Common.Logon.CheckAdminCredential(scope, credential);

            if (!FileExtensionIsCorrect(id))
                return MakeTextAnswer("Bad file extension. Only supported jpg and png formats");
            String rootFolder = Common.Solution.GetSolutionFolder(scope);
            String fileSystemFolder = String.Format(@"{0}\filesystem", rootFolder);
            if (!System.IO.Directory.Exists(fileSystemFolder))
                System.IO.Directory.CreateDirectory(fileSystemFolder);
            String imagesFolder = String.Format(@"{0}\images", fileSystemFolder);
            if (!System.IO.Directory.Exists(imagesFolder))
                System.IO.Directory.CreateDirectory(imagesFolder);
            String catalogFolder = String.Format(@"{0}\{1}", imagesFolder, catalog);
            if (!System.IO.Directory.Exists(catalogFolder))
                System.IO.Directory.CreateDirectory(catalogFolder);

            String fileName = String.Format(@"{0}\{1}", catalogFolder, id);
            if (System.IO.File.Exists(fileName))
                System.IO.File.Delete(fileName);
            using (System.IO.Stream file = System.IO.File.OpenWrite(fileName))
            {
                messageBody.CopyTo(file);
            }

            return MakeTextAnswer("ok");
        }
 public string Save(System.IO.FileInfo file)
 {
     string destinationFilePath = Path.Combine(storageFolder.FullName, file.Name);
     file.CopyTo(destinationFilePath);
     string destinationUrl = storageBaseAdddress + file.Name;
     return destinationUrl;
 }
		public void Speak (System.IO.Stream stream)
		{
			if (stream == null)
			{
				Debug.WriteLine ("Cannot playback empty stream!");
				return;
			}

			// Save the stream to a file and play it.
			string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "temp.mp3");

			using (stream)
			using (var file = File.Open (path, FileMode.Create, FileAccess.Write, FileShare.None))
			{
				stream.CopyTo (file);
			}

			// The AVAudioPlayer instance has to be class scope, otherwise it will stop playing as soon
			// as it gets collected.
			this.player = AVAudioPlayer.FromUrl (NSUrl.FromFilename (path));
			this.player.FinishedPlaying += (sender, e) => {
				player = null;
			};
			this.player.PrepareToPlay ();
			this.player.Play ();
		}
 public PhonyUploadFile(string Filename, System.IO.Stream ContentStream, string MIMEtype)
 {
     _fileName = Filename;
     ContentStream.CopyTo( _inputStream );
     _contentType = MIMEtype;
      
 }
Esempio n. 9
0
 public static Object[] sortFacts(System.Collections.Generic.IList<Object> facts)
 {
     Object[] sorted = new object[facts.Count];
     facts.CopyTo(sorted,0);
     Arrays.sort(sorted, COMPARATOR);
     return sorted;
 }
 public void SaveStream(System.IO.Stream stream)
 {
     using (Stream conStream = File.Open(fileName, FileMode.Create))
     {
         stream.CopyTo(conStream);
     }
 }
 public Windows.UI.Xaml.Media.Imaging.BitmapImage GetBitmapSource(System.IO.Stream stream)
 {
     Windows.UI.Xaml.Media.Imaging.BitmapImage bitmapSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
     Windows.Storage.Streams.InMemoryRandomAccessStream ras = new Windows.Storage.Streams.InMemoryRandomAccessStream();
     stream.CopyTo(System.IO.WindowsRuntimeStreamExtensions.AsStreamForRead(ras));
     bitmapSource.SetSource(ras);
     return bitmapSource;
 }
Esempio n. 12
0
 public void UploadFile(string path, System.IO.Stream stream)
 {
     CreateDirectoryIfNotExists(path);
     using (var file = File.Create(path))
     {
         stream.CopyTo(file);
     }
 }
Esempio n. 13
0
 public void ArrayCopy()
 {
     var array = new[] { "1", "2", "3" };
     var newArray = new string[2];
     array.CopyTo(newArray, 1);
     AssertEquals(newArray[0], "2");
     AssertEquals(newArray[1], "3");
 }         
Esempio n. 14
0
 public StreamMediaDataSource(System.IO.Stream data)
 {
     using (var stream = new System.IO.MemoryStream())
     {
         data.CopyTo(stream);
         _data = stream.ToArray();
     }
 }
Esempio n. 15
0
        public static string BuildMultiColumnFilter(string filterExpression, System.Collections.Specialized.StringCollection coloumns)
        {
            string[] coloumnNames = new string[coloumns.Count];

                coloumns.CopyTo(coloumnNames, 0);

                return BuildMultiColumnFilter(filterExpression, coloumnNames);
        }
 public static System.Drawing.Point[] MapPoints(this System.Windows.Forms.IWin32Window ctrl, System.Drawing.Point[] points, System.Windows.Forms.IWin32Window newWin = null)
 {
     System.Drawing.Point[] pts = new System.Drawing.Point[points.Length];
     points.CopyTo(pts, 0);
     for (int i = 0; i < pts.Length; i++)
         MapWindowPoints(ctrl == null ? IntPtr.Zero : ctrl.Handle, newWin == null ? IntPtr.Zero : newWin.Handle, ref pts[i], 1);
     return pts;
 }
 // This method reads bytes from an input stream (i.e. an "upload")
 public override object ReadFromStream(Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
 {
     // Create an in-memory buffer
     var ms = new MemoryStream();
     // Copy the request message body content to the in-memory buffer
     readStream.CopyTo(ms);
     // Deliver a byte array to the controller
     return ms.ToArray();
 }
Esempio n. 18
0
        public void Copy()
        {
            string[] someArray = new[] { "the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog" };

            string[] someOtherArray = new string[someArray.Length];

            someArray.CopyTo(someOtherArray,0);

            someOtherArray[4].ShouldBe(_);
        }
 /// <summary>
 /// Create a <see cref="LazilyPersistentVector">LazilyPersistentVector</see> from an ICollection of items.
 /// </summary>
 /// <param name="coll">The collection of items.</param>
 /// <returns>A <see cref="LazilyPersistentVector">LazilyPersistentVector</see>.</returns>
 public static IPersistentVector create(System.Collections.ICollection coll)
 {
     if (!(coll is ISeq) && coll.Count <= 32)
     {
         object[] array = new object[coll.Count];
         coll.CopyTo(array, 0);
         return createOwning(array);
     }
     return PersistentVector.create(RT.seq(coll));
 }
Esempio n. 20
0
        public void Save(string id, System.IO.Stream stream)
        {
            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            using (var file = new FileStream(Path.Combine(path, id), FileMode.OpenOrCreate)) {
                stream.CopyTo(file);
                file.Close();
            }
        }
Esempio n. 21
0
		protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
		{
			Debug.Assert(file == this.PrimaryFile);
			
			_stream = new MemoryStream();
			stream.CopyTo(_stream);
			stream.Position = 0;
			
			if (designer == null) {
				// initialize designer on first load
				designer = new DesignSurface();
				this.UserContent = designer;
				InitPropertyEditor();
			}
			this.UserContent=designer;
			if (outline != null) {
				outline.Root = null;
			}
			using (XmlTextReader r = new XmlTextReader(stream)) {
				XamlLoadSettings settings = new XamlLoadSettings();
				settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
				settings.CustomServiceRegisterFunctions.Add(
					delegate(XamlDesignContext context) {
						context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile));
						context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
						context.Services.AddService(typeof(IEventHandlerService), new CSharpEventHandlerService(this));
						context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
						context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
					});
				settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
				try{
					settings.ReportErrors=UpdateTasks;
					designer.LoadDesigner(r, settings);
					
					designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu");
					
					if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) {
						outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
					}
					
					propertyGridView.PropertyGrid.SelectedItems = null;
					designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
					designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged;
				}
				catch
				{
					this.UserContent=new WpfDocumentError();
				}
			}
		}
        public void CreateProjectSourceFile(System.IO.Stream stream)
        {
            string dirPath = Path.GetDirectoryName(fullPath);
            if(!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            stream.Seek(0, SeekOrigin.Begin);
            using (FileStream fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write))
            {
                stream.CopyTo(fileStream);
            }
        }
Esempio n. 23
0
        public void PutArtifact(ArtifactInfo info, System.IO.Stream stream)
        {
            var jss = new JsonSerializer<ArtifactObject>();

            long ctr = client.IncrementValue(fileNameCounterKey);

            string fileName = filePrefix + "/" + ctr + ".artifact";

            client.AddItemToList(artifactListKey, jss.Serialize(info));

            using(var fs = File.Create(fileName))
            {
                stream.CopyTo(fs);
            }
        }
Esempio n. 24
0
    public UnitComponent PflongeOnUnit(System.Array newextensions)
    {
        if (ComponentExtendsTheOptionalstateOrder)
        {
            UNIT = this.gameObject.GetComponent<UnitScript>();
            StateExtensions = new System.Enum[newextensions.Length];
            newextensions.CopyTo(StateExtensions, 0);
            this.ID = UNIT.Options.RegisterUnitComponent(this, StateExtensions);

            SignIn();

            return this;
        }
        else
            return PflongeOnUnit();
    }
Esempio n. 25
0
 public static string SaveFile(string fileName, System.IO.Stream stream)
 {
     try
     {
         var splits = fileName.Split('.');
         var ext = splits.Last();
         var FileName = Guid.NewGuid().ToString() + "." + ext;
         var upload = System.IO.Path.Combine(System.Configuration.ConfigurationManager.AppSettings["UploadFolderPath"] + FileName);
         var fileStream = System.IO.File.Create(upload);
         stream.CopyTo(fileStream);
         fileStream.Flush();
         fileStream.Close();
         return FileName;
     }
     catch (Exception e)
     {
         return null;
     }
 }
Esempio n. 26
0
    public ListBoxForm(string title, string message, System.Collections.IList items, object selectedItem)
    {
      InitializeComponent();
      m_checkedListBox.Visible = false;

      if (!string.IsNullOrEmpty(title))
        Text = title;
      if (!string.IsNullOrEmpty(message))
        m_lblMessage.Text = message;

      if (items != null)
      {
        object[] list = new object[items.Count];
        items.CopyTo(list, 0);
        m_list.Items.AddRange(list);
        m_list.DoubleClick += OnDoubleClickList;

        if (selectedItem != null)
          m_list.SelectedItem = selectedItem;
      }
    }
		public async void Speak (System.IO.Stream stream)
		{
			if (stream == null)
			{
				Debug.WriteLine ("Cannot playback empty stream!");
				return;
			}

			// Copy stream into a file and play it with MediaPlayer.
			string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "temp.mp3");

			using (stream)
			{
				using (var file = File.Open (path, FileMode.Create, FileAccess.Write, FileShare.None))
				{
					stream.CopyTo (file);
				}
			}

			var player = MediaPlayer.Create (Forms.Context, Android.Net.Uri.FromFile (new Java.IO.File (path)));
			player.Start();
		}
Esempio n. 28
0
    public ListBoxForm(string title, string message, System.Collections.IList items, object selectedItem)
    {
      InitializeComponent();
      m_checkedListBox.Visible = false;

      if (!string.IsNullOrEmpty(title))
        Text = title;
      if (!string.IsNullOrEmpty(message))
        m_lblMessage.Text = message;

      if (items != null)
      {
        object[] list = new object[items.Count];
        items.CopyTo(list, 0);
        m_list.Items.AddRange(list);
        m_list.DoubleClick += OnDoubleClickList;

        if (selectedItem != null)
          m_list.SelectedItem = selectedItem;

        var graphics = CreateGraphics();
        int max_width = 0;
        foreach (var item in items)
        {
          string s = item.ToString();
          var width = (int)(graphics.MeasureString(s, this.Font).Width+0.5F);
          if (width > max_width)
            max_width = width;
        }
        max_width += 12; //padding
        if (max_width > m_list.ClientSize.Width)
        {
          int increase_amount = max_width - m_list.ClientSize.Width;
          this.Width += increase_amount;
        }
      }
    }
Esempio n. 29
0
    public ListBoxForm(string title, string message, System.Collections.IList items, IList<bool> itemState)
    {
      InitializeComponent();
      m_list.Visible = false;
      m_checkedListBox.Visible = true;

      if (!string.IsNullOrEmpty(title))
        Text = title;
      if (!string.IsNullOrEmpty(message))
        m_lblMessage.Text = message;
      if (items != null)
      {
        object[] list = new object[items.Count];
        items.CopyTo(list, 0);
        m_checkedListBox.Items.AddRange(list);
        if (itemState != null && itemState.Count == items.Count)
        {
          for (int i = 0; i < items.Count; i++)
          {
            m_checkedListBox.SetItemChecked(i, itemState[i]);
          }
        }
      }
    }
Esempio n. 30
0
 public static ActionResult AddRouteValues(this ActionResult result, System.Collections.Specialized.NameValueCollection nameValueCollection)
 {
     // Copy all the values from the NameValueCollection into the route dictionary
     if (nameValueCollection.AllKeys.Any(m => m == null))  //if it has a null, the CopyTo extension will crash!
     {
         var filtered = new System.Collections.Specialized.NameValueCollection(nameValueCollection);
         filtered.Remove(null);
         filtered.CopyTo(result.GetRouteValueDictionary());
     }
     else
         nameValueCollection.CopyTo(result.GetRouteValueDictionary());
     return result;
 }