Example #1
0
        private static List <string> GetTickers(SecurityGroupName securityGroupName)
        {
            var    ret      = new List <string>();
            string fileName = String.Empty;

            var value = securityGroupName.GetType().GetMember(securityGroupName.ToString());

            if (Attribute.IsDefined(value.FirstOrDefault(), typeof(FileNameAttribute)))
            {
                fileName = value[0].GetCustomAttribute <FileNameAttribute>().FileName;
            }

            if (File.Exists($@".\Resources\DowJonesSecurities.txt"))
            {
                Console.WriteLine("Found it");
                using (var streamReader = new StreamReader($@".\Resources\DowJonesSecurities.txt"))
                {
                    while (!streamReader.EndOfStream)
                    {
                        ret.Add(streamReader.ReadLine());
                    }
                    streamReader.Close();
                    return(ret);
                }
            }
            return(null);
        }
Example #2
0
        public static SecurityGroup GetGroup(SecurityGroupName securityGroupName)
        {
            var ret = new SecurityGroup(securityGroupName);

            ret.Tickers = GetTickers(securityGroupName);
            return(ret);
        }
Example #3
0
            /// <summary>
            /// Initializes a new instance of the <see cref="CreateServerDetails"/> class
            /// with the specified details.
            /// </summary>
            /// <param name="name">Name of the new server.</param>
            /// <param name="imageName">The image to use for the new server instance. This is
            /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
            /// <param name="flavorId">The flavor to use for the new server instance. This
            /// is specified as a flavor ID (see <see cref="Flavor.Id"/>) or a full URL.</param>
            /// <param name="adminPass">The root Password </param>
            /// <param name="keyName">the ssh keyname to add to server</param>
            /// <param name="securityGroupNames">A collection of openstack security group name</param>
            /// <param name="attachVolumeIds">A collection of voiume ids which will be attached to the instance.</param>
            /// <param name="diskConfig">The disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.</param>
            /// <param name="metadata">The metadata to associate with the server.</param>
            /// <param name="personality">A collection of <see cref="Personality"/> objects describing the paths and contents of files to inject in the target file system during the creation process. If the value is <see langword="null"/>, no files are injected.</param>
            /// <param name="accessIPv4">The behavior of this value is unspecified. Do not use.</param>
            /// <param name="accessIPv6">The behavior of this value is unspecified. Do not use.</param>
            /// <param name="networks">A collection of identifiers for networks to initially connect to the server. These are obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see></param>
            public CreateServerDetails(string name, string imageName, string flavorId, string adminPass, string keyName, string[] securityGroupNames, string[] attachVolumeIds, DiskConfiguration diskConfig, Dictionary <string, string> metadata, string accessIPv4, string accessIPv6, IEnumerable <string> networks, IEnumerable <Personality> personality)
            {
                Name        = name;
                ImageId     = imageName;
                FlavorId    = flavorId;
                DiskConfig  = diskConfig;
                Metadata    = metadata;
                AccessIPv4  = accessIPv4;
                AccessIPv6  = accessIPv6;
                Networks    = (networks == null ? null : networks.Select(i => new NewServerNetwork(i)).ToArray());
                Personality = personality != null?personality.ToArray() : null;

                KeyName             = keyName;
                SecurityGroupNames  = SecurityGroupName.GetGroupNamesFromStrings(securityGroupNames).ToArray <SecurityGroupName>();
                BlockDeviceMappings = VolumeIds.GetVolumeIdsFromStrings(attachVolumeIds).ToArray <VolumeIds>();
                AdminPass           = adminPass;
            }
        /// <summary>
        /// Searches for and returns (within a <see cref="IList"/>) the security <see cref="Group"/> associated with the specified <see cref="SecurityGroupName"/> from a list of security groups.
        /// </summary>
        /// <param name="securityGroupName">The user-friendly <see cref="SecurityGroupName"/> for which to find the associated security <see cref="Group"/>.</param>
        /// <param name="securityGroups">The list of security <see cref="Group"/> to search.</param>
        /// <returns>A <see cref="IList"/> containing the retrieved security <see cref="Group"/> or the <c>Nothing</c> security <see cref="Group"/> if not found.</returns>
        public static IList <Group> GetSecurityGroupAsList(SecurityGroupName securityGroupName, IList <Group> securityGroups)
        {
            IList <Group> groups = new List <Group>();
            string        securityGroupFullName = securityGroupName switch
            {
                SecurityGroupName.Administrator => "**EverythingSecurity**",
                SecurityGroupName.Supervisor => "**SupervisorSecurity**",
                SecurityGroupName.ViewOnly => "**ViewOnlySecurity**",
                SecurityGroupName.Nothing => "**NothingSecurity**",
                _ => "**NothingSecurity**",
            };

            for (int i = 0; i < securityGroups.Count; i++)
            {
                Group group = securityGroups[i];
                if (group.Name.Equals(securityGroupFullName, StringComparison.OrdinalIgnoreCase))
                {
                    groups.Add(group);
                    break;
                }
            }
            return(groups);
        }
Example #5
0
 private SecurityGroup(SecurityGroupName securityGroupName)
 {
     SecurityGroupName = securityGroupName;
 }