SWFProcessing.Swiffotron.Test.MockStore.OpenInput C# (CSharp) Method

OpenInput() public method

public OpenInput ( string id ) : Stream
id string
return Stream
        public Stream OpenInput(string id)
        {
            Stream s = null;
            try
            {
                s = new FileStream(@"store\" + id, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                /* Ignore. Pick this up when s is null in next block. */
            }

            if (s == null)
            {
                string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
                s = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"SWFProcessing.Swiffotron.Test.res.store." + id);
                if (s == null)
                {
                    s = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"SwiffotronTestExpress.res.store." + id);
                }

                if (s == null)
                {
                    throw new FileNotFoundException(@"Store does not contain " + id);
                }
            }

            return s;
        }

Usage Example

示例#1
0
 protected void CopyStoreToTestDir(MockStore store)
 {
     foreach (string commit in store.Commits)
     {
         if (store.Has(commit)) /* Well it might have been deleted */
         {
             using (Stream input = store.OpenInput(commit))
             using (FileStream output = new FileStream(TestDir + commit, FileMode.Create))
             {
                 CopyStream(input, output);
             }
         }
     }
 }
All Usage Examples Of SWFProcessing.Swiffotron.Test.MockStore::OpenInput