Ejemplo n.º 1
0
        public override void SetOptions()
        {
            base.Image = ButtonImage.Large;
            string path = FormatResourceName("Commands/Images/Large/blue/laptop.png");

            base.LargeImageStream = ThisAssembly.GetManifestResourceStream(path);
        }
 // Loads all the strategies from all the embedded XML resources. Also builds a list of strategy identifiers
 // in the format ProviderId:StrategyName.
 private void LoadStrategies()
 {
     foreach (KeyValuePair <string, string> algoProvider in _algoProviders)
     {
         _atdlStrategyProvider.Load(algoProvider.Key, ThisAssembly.GetManifestResourceStream(algoProvider.Value));
     }
 }
Ejemplo n.º 3
0
            /// <summary>
            /// Open a manifest file from this assembly
            /// </summary>
            /// <param name="path">Type path to the file</param>
            /// <param name="name">File name (with extension)</param>
            /// <returns>Manifest file's stream</returns>
            /// <exception cref="Debug.ExceptionLog">When a <see cref="System.IO.FileNotFoundException"/> is encountered, it is caught and rethrown as a this type of exception</exception>
            public static Stream Open(string path, string name)
            {
                string manifest_path = string.Format("{0}{1}{2}", BasePath, path.Replace('\\', '.'), name);
                Stream s             = null;

                try { s = ThisAssembly.GetManifestResourceStream(manifest_path); }
                catch (FileNotFoundException) { throw new Debug.ExceptionLog("Manifest not found! {0}", manifest_path); }
                return(s);
            }
Ejemplo n.º 4
0
        private static string[] ReadLinesFromBuiltInInput(string name)
        {
            string text;

            using (var stream = ThisAssembly.GetManifestResourceStream(name))
                using (var streamReader = new StreamReader(stream))
                {
                    text = streamReader.ReadToEnd();
                }
            return(text.Split(NewLineSeparators, StringSplitOptions.RemoveEmptyEntries));
        }
Ejemplo n.º 5
0
        protected byte[] GetResourceBytes(string resourceName)
        {
            byte[] bytes = null;

            using (Stream stream = ThisAssembly.GetManifestResourceStream($"{TestLogResourceNameRoot}.{resourceName}"))
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    bytes = memoryStream.ToArray();
                }
            }
            return(bytes);
        }
Ejemplo n.º 6
0
        protected string GetResourceText(string resourceName)
        {
            string text = null;

            using (Stream stream = ThisAssembly.GetManifestResourceStream($"{TestLogResourceNameRoot}.{resourceName}"))
            {
                if (stream == null)
                {
                    return(string.Empty);
                }

                using (StreamReader reader = new StreamReader(stream))
                {
                    text = reader.ReadToEnd();
                }
            }
            return(text);
        }
        // This method loops around all the strategy files we have embedded in this project and
        // pulls out the providerID value for the first strategy in the file.  This is used to identify
        // the provider thereafter.
        private Dictionary <string, string> GetProviders()
        {
            Dictionary <string, string> providers = new Dictionary <string, string>();

            foreach (string resource in GetEmbeddedResources("*.xml"))
            {
                XDocument document;

                using (XmlReader reader = XmlReader.Create(ThisAssembly.GetManifestResourceStream(resource)))
                {
                    document = XDocument.Load(reader);
                }

                XAttribute providerId = (from e in document.Descendants("{http://www.fixprotocol.org/FIXatdl-1-1/Core}Strategy")
                                         select e).First().Attribute("providerID");

                providers.Add(providerId.Value, resource);
            }

            return(providers);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieves an icon from resources.
        /// Icon must be specified by resource name,
        /// for convenience .ico extension is optional.
        /// </summary>
        public static Icon GetIconFromResource(string IconName)
        {
            // load the icon from resources
            Stream iconStream;
            String tempStr = String.Format("{0}.{1}", ThisAssembly.GetName().Name, IconName);

            if (DisplayResolution == DisplayResolution.QVGA)
            {
                iconStream = ThisAssembly.GetManifestResourceStream(tempStr + ".ico");
            }
            else
            {
                iconStream = ThisAssembly.GetManifestResourceStream(tempStr + "32.ico");
            }

            Icon theIcon = new Icon(iconStream);

            iconStream.Close();


            return(theIcon);
        }
Ejemplo n.º 9
0
 internal static Stream GetDocumentTemplate()
 => ThisAssembly.GetManifestResourceStream("DocumentTemplate.pt");