示例#1
0
    /// <summary>
    /// Reads the collection.
    /// </summary>
    /// <returns>The collection with data that was written.</returns>
    public MainModel Read()
    {
      MainModel result;

      string path = Path.Combine(this.dataDirectory, entitiesNameV1 + ".xml");

      if (!File.Exists(path))
      {
          return null;
      }

      using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
      {
        result = stream.Deserialize<MainModel>();
      }

      return result;
    }
        /// <summary>
        /// Creates a new PlanetLab manager history instance for the specified folder.
        /// </summary>
        /// <param name="slice">The PlanetLab slice.</param>
        public PlManagerHistory(PlSlice slice)
        {
            // Validate the arguments.
            if (null == slice) throw new ArgumentNullException("slice");

            try
            {
                // If the file exists.
                if (File.Exists(CrawlerConfig.Static.PlanetLabHistoryFileName))
                {
                    // Load from file the list of runs.
                    using (FileStream file = new FileStream(CrawlerConfig.Static.PlanetLabHistoryFileName, FileMode.Open))
                    {
                        file.Deserialize<PlManagerHistory>(this);
                    }
                }
            }
            catch
            {
                // Catch all exceptions.
            }
        }
示例#3
0
        /// <summary>
        /// This event has fired when Configure Menu Item clicked
        /// </summary>
        private void ConfigureMenuItemClicked(object sender, EventArgs e)
        {
            // Get current solution
            IVsSolution  solution            = GetService(typeof(IVsSolution)) as IVsSolution;
            uint         itemId              = VSConstants.VSITEMID_NIL;
            IVsHierarchy hierarchy           = solution.GetSelectedHierarchy(out itemId);
            ProjectItem  selectedProjectItem = hierarchy.GetSelectedProjectItem(itemId);

            // Get paths and file names...
            string selectedItemName       = selectedProjectItem.Name;
            string fullpath               = Path.GetDirectoryName(selectedProjectItem.Properties.Item("FullPath").Value.ToString());
            string svcMapFilePath         = string.Concat(fullpath, Path.DirectorySeparatorChar, selectedItemName, ProxyMgrConstants.SvcmapFileExtension);
            ProxyEntryInformation context = null;

            // Read svcmap file
            if (File.Exists(svcMapFilePath))
            {
                using (System.IO.FileStream file = File.Open(svcMapFilePath, FileMode.Open, FileAccess.Read))
                {
                    context = file.Deserialize <ProxyEntryInformation>();
                }
            }

            // Check context
            if (context == null)
            {
                LogWriter.WriteLine(string.Format("[ WARNING ] {0} file not found.", svcMapFilePath));
                context = new ProxyEntryInformation()
                {
                    ServiceName = selectedItemName, ShowMissingMap = false
                };
            }

            context.IsAddContext = false;

            // Show input entry window
            this.ShowProxyEntry(context);
        }
示例#4
0
        public static List<GestureToken> GetOnTheFlyGestureDefinition(Assembly assembly, string resourceName)
        {
            Stream stream = new FileStream(resourceName, FileMode.Open, FileAccess.Read);
                if (stream != null)
                    return stream.Deserialize();
                else

                    return null;
        }
 /// <summary>
 /// Opens the history run with the specified identifier.
 /// </summary>
 /// <param name="id">The history identifier.</param>
 /// <returns>The manager history run.</returns>
 public PlManagerHistoryRun Open(PlManagerHistoryId id)
 {
     // Open the history from the file.
     using (FileStream file = new FileStream(id.FileName, FileMode.Open))
     {
         // Deserialize the history run.
         return file.Deserialize<PlManagerHistoryRun>();
     }
 }