Example #1
0
        private void InitilizeSubject(InstanceTypes instanceType)
        {
            Subject = WebContext.Current.SubjectDicByType[instanceType.ToString()];
            ISubjectService service = ServiceLocator.Current.GetInstance <ISubjectService>();

            service.AttachProperties(Subject);
        }
Example #2
0
        /// <summary>
        /// The create instance.
        /// </summary>
        /// <param name="providerSettings">
        /// The provider settings.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        private Attempt <GatewayProviderBase> CreateInstance(IGatewayProviderSettings providerSettings)
        {
            var providerType = InstanceTypes.FirstOrDefault(x => x.GetCustomAttribute <GatewayProviderActivationAttribute>(false).Key == providerSettings.Key);

            return(providerSettings == null ?
                   Attempt <GatewayProviderBase> .Fail(new Exception(string.Format("Failed to find type for provider {0}", providerSettings.Name))) :
                   ActivatorHelper.CreateInstance <GatewayProviderBase>(providerType, new object[] { _gatewayProviderService, providerSettings, _runtimeCache }));
        }
 public InstanceDetailViewModel(InstanceTypes instanceType, BaseDto instance)
 {
     InitilizeSubject(instanceType);
     Instance   = instance;
     Actions    = new List <UIAction>();
     ChildLists = new List <InstanceChildListViewModel>();
     PageTitle  = string.Format("{0}: {1}", Subject.SubjectLabel, Instance.Display);
 }
 public InstanceEditViewModel(InstanceTypes instanceType, BaseDto instance)
 {
     IsEditing = true;
     Actions   = new List <UIAction>();
     InitilizeSubject(instanceType);
     Instance  = instance;
     PageTitle = string.Format("{0}: {1}", Subject.SubjectLabel, Instance.Display);
 }
Example #5
0
 public Instance(Subnet subnet, InstanceTypes instanceType, string imageId, OperatingSystem operatingSystem,
                 bool rename) : base(subnet, instanceType, imageId, operatingSystem, ResourceType.AwsEc2Instance, rename)
 {
     SourceDestCheck   = true;
     NetworkInterfaces = new List <NetworkInterface>();
     this.Tags.Add(new Tag("Name", this.LogicalId));
     this.VolumesToAttach  = new List <Volume>();
     this.SecurityGroupIds = new List <ReferenceProperty>();
 }
        /// <summary>
        /// Clears the list.
        /// </summary>
        public void Clear()
        {
            if (!SupportsClear)
            {
                throw new InvalidOperationException("This resolver does not support Clearing types");
            }

            using (new WriteLock(_lock))
            {
                InstanceTypes.Clear();
            }
        }
        /// <summary>
        /// Removes a type.
        /// </summary>
        /// <param name="value">The type to remove.</param>
        public void RemoveType(Type value)
        {
            if (!SupportsRemove)
            {
                throw new InvalidOperationException("This resolver does not support Removing types");
            }

            using (new WriteLock(_lock))
            {
                EnsureCorrectType(value);
                InstanceTypes.Remove(value);
            }
        }
Example #8
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Type InstanceType(this ElementType elementType)
        {
            Type type = elementType.GetType();

            if (InstanceTypes.ContainsKey(type))
            {
                return(InstanceTypes[type]);
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// protected method allow the inheritor to add many types at once
 /// </summary>
 /// <param name="types"></param>
 protected void AddTypes(IEnumerable <Type> types)
 {
     using (var l = new WriteLock(_lock))
     {
         foreach (var t in types)
         {
             EnsureCorrectType(t);
             if (InstanceTypes.Contains(t))
             {
                 throw new InvalidOperationException("The Type " + t + " already exists in the collection");
             }
             ;
             InstanceTypes.Add(t);
         }
     }
 }
Example #10
0
        /// <summary>
        /// Adds a Type to the end of the list.
        /// </summary>
        /// <param name="value">The object to be added.</param>
        public virtual void AddType(Type value)
        {
            EnsureAddSupport();

            EnsureResolutionNotFrozen();

            using (GetWriteLock())
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;
                _instanceTypes.Add(value);
            }
        }
        /// <summary>
        /// Adds a Type to the end of the list.
        /// </summary>
        /// <param name="value">The object to be added.</param>
        public void AddType(Type value)
        {
            if (!SupportsAdd)
            {
                throw new InvalidOperationException("This resolver does not support Adding new types");
            }

            using (var l = new WriteLock(_lock))
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;
                InstanceTypes.Add(value);
            }
        }
Example #12
0
        /// <summary>
        /// protected method allow the inheritor to add many types at once
        /// </summary>
        /// <param name="types"></param>
        protected void AddTypes(IEnumerable <Type> types)
        {
            EnsureAddSupport();

            EnsureResolutionNotFrozen();

            using (GetWriteLock())
            {
                foreach (var t in types)
                {
                    EnsureCorrectType(t);
                    if (InstanceTypes.Contains(t))
                    {
                        throw new InvalidOperationException("The Type " + t + " already exists in the collection");
                    }
                    ;
                    _instanceTypes.Add(t);
                }
            }
        }
        /// <summary>
        /// Inserts a Type at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which the object should be inserted.</param>
        /// <param name="value">The object to insert.</param>
        public void InsertType(int index, Type value)
        {
            if (!SupportsInsert)
            {
                throw new InvalidOperationException("This resolver does not support Inserting new types");
            }

            using (var l = new UpgradeableReadLock(_lock))
            {
                EnsureCorrectType(value);
                if (InstanceTypes.Contains(value))
                {
                    throw new InvalidOperationException("The Type " + value + " already exists in the collection");
                }
                ;

                l.UpgradeToWriteLock();
                InstanceTypes.Insert(index, value);
            }
        }
Example #14
0
        private int?DecideInstanceId(ConfigureParameter parameter, InstanceTypes instanceType, bool force)
        {
            // Decide the instanceId
            if (parameter.InstanceId.HasValue)
            {
                return(parameter.InstanceId.Value);
            }

            if (parameter.AutoDecideInstanceId || force)
            {
                ServiceProvider serviceProvider = ServiceProvider.GetServiceProvider(instanceType);
                if (serviceProvider == null)
                {
                    return(null);
                }
                else
                {
                    return(serviceProvider.DetectAvailableInstanceId());
                }
            }

            return(null);
        }
Example #15
0
        public LaunchConfiguration(Subnet subnet,
                                   InstanceTypes instanceType,
                                   string imageId,
                                   OperatingSystem operatingSystem,
                                   ResourceType resourceType,
                                   bool rename)
            : base(resourceType)
        {
            this.Rename       = rename;
            _availableDevices = new List <string>();
            if (subnet != null)
            {
                this.Subnet = subnet;
            }
            this.InstanceType    = instanceType;
            this.OperatingSystem = operatingSystem;
            switch (OperatingSystem)
            {
            case OperatingSystem.Windows:
                RootDeviceId = "/dev/sda1";
                break;

            case OperatingSystem.Linux:
                RootDeviceId = "/dev/xvda";
                break;

            default:
                throw new NotSupportedException(nameof(operatingSystem));
            }
            Packages = new ObservableCollection <PackageBase <ConfigSet> >();
            Packages.CollectionChanged += Packages_CollectionChanged;
            this.ImageId = imageId;
            this.PopulateAvailableDevices();

            KeyName        = new ReferenceProperty(Template.ParameterKeyPairName);
            SecurityGroups = new List <ReferenceProperty>();
        }
Example #16
0
 public InstanceListViewModel(InstanceTypes instanceType)
 {
     InitilizeSubject(instanceType);
     Title        = string.Format("{0} List", Subject.SubjectLabel);
     AllowListAdd = Subject.AllowListAdd;
 }
Example #17
0
 public InstanceViewModel(InstanceTypes instanceType)
     : base(instanceType)
 {
 }
Example #18
0
 public ListViewModel(InstanceTypes instanceType)
     : base(instanceType)
 {
 }
Example #19
0
        protected override void Seed(PCMC.ModelADO context)
        {
            //  This method will be called after migrating to the latest version.

            User ben = new User {
                ID = 2, FirstName = "Benjamin", LastName = "Aronson", Password = "******", Email = "*****@*****.**", Role = UserRole.User, Username = "******"
            };

            context.User.AddOrUpdate(
                p => p.ID,
                new User {
                ID = 1, FirstName = "Stephan", LastName = "K", Password = "******", Email = "*****@*****.**", Role = UserRole.Admin, Username = "******"
            },
                ben
                );
            context.SaveChanges();

            InstanceTypes drupal = new InstanceTypes {
                ID = 1, Name = "Drupal v8.3.0", SysUser = "******", SysPass = "******"
            };

            context.InstanceTypes.AddOrUpdate(
                p => p.ID,
                drupal
                );
            context.SaveChanges();

            ServerLocations silicon_valley = new ServerLocations {
                ID = 1, LocationName = "Silicon Valley", ServerIP = "104.207.149.59", ServerPort = "2983", ServerURL = "http://104.207.149.59/"
            };

            context.ServerLocations.AddOrUpdate(
                p => p.ID,
                silicon_valley
                );
            context.SaveChanges();

            context.Instances.AddOrUpdate(
                p => p.ID,
                new Instances
            {
                ID                = 1,
                DeleteDate        = new DateTime(2016, 8, 19),
                InstanceType      = context.InstanceTypes.Single(p => p.ID == drupal.ID),
                LocationInstalled = context.ServerLocations.Single(p => p.ID == silicon_valley.ID),
                Owner             = context.User.Single(p => p.ID == ben.ID),
                URL               = "drupal"
            }
                );
            context.SaveChanges();

            EmailTemplates Drupal_Welcome = new EmailTemplates {
                ID = 1, EmailSubject = "Welcome to Drupal on PointSaaS", InstanceType = context.InstanceTypes.Single(p => p.ID == drupal.ID), TemplateFileName = "Welcome.tpl"
            };

            context.EmailTemplates.AddOrUpdate(
                p => p.ID,
                Drupal_Welcome
                );
            context.SaveChanges();

            EmailQueue queue = new EmailQueue {
                ID       = 1, FutureTime = new DateTime(2016, 8, 19), Instance = context.Instances.Single(p => p.ID == 1), IsReady = true,
                Owner    = context.User.Single(p => p.ID == ben.ID),
                Template = context.EmailTemplates.Single(p => p.ID == Drupal_Welcome.ID)
            };

            context.EmailQueue.AddOrUpdate(
                p => p.ID,
                queue
                );
            context.SaveChanges();
        }
Example #20
0
 public Instance(Subnet subnet, InstanceTypes instanceType, string imageId, OperatingSystem operatingSystem)
     : this(subnet, instanceType, imageId, operatingSystem, true)
 {
 }
Example #21
0
 public BaseViewModel(InstanceTypes instanceType)
 {
     Subject = WebContext.Current.SubjectList[instanceType.ToString()];
 }
Example #22
0
 public Instance(Subnet subnet, InstanceTypes instanceType, string imageId,
                 OperatingSystem operatingSystem, Ebs.VolumeTypes volumeType, uint volumeSize)
     : this(subnet, instanceType, imageId, operatingSystem)
 {
     this.AddDisk(volumeType, volumeSize, this.GetRootDeviceId(), true);
 }
Example #23
0
            public static int Process(Compile args)
            {
                if (args.Files.Count() == 0)
                {
                    Console.WriteLine("Error: No input files provided");
                    return(1);
                }

                string file = args.Files.First();

                if (!File.Exists(file))
                {
                    Console.WriteLine($"File does not exists: { file }");
                    return(1);
                }

                var ctx = new GamaGlobalContext($"[module/{ file }]");

                InstanceTypes.Initialize();
                ctx.Root.Types.AddRange(InstanceTypes.All);

                var sw = new Stopwatch();

                sw.Start();

                var inputtxt = File.ReadAllText(file);
                var input    = new AntlrInputStream(inputtxt);
                var lexer    = new GamaLexer(input);
                var tokens   = new CommonTokenStream(lexer);
                var parser   = new GamaParser(tokens);
                var program  = parser.program();

                if (parser.NumberOfSyntaxErrors > 0)
                {
                    Console.WriteLine("Code contains syntax errors, aborting compilation.");
                    return(2);
                }
                var unit = new GamaNamespaceCompiler(ctx);

                unit.Visit(program);

                sw.Stop();

                if (!ctx.Module.TryVerify(LLVMVerifierFailureAction.LLVMPrintMessageAction, out string err))
                {
                    ctx.Module.Dump();
                    if (ctx.ErrorList.Count > 0)
                    {
                        foreach (var e in ctx.ErrorList)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    return(3);
                }
                else
                {
                    if (ctx.ErrorList.Count > 0)
                    {
                        foreach (var e in ctx.ErrorList)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine(ctx.Module.PrintToString());
                        Console.WriteLine($"Compilation took { sw.Elapsed.Seconds } sec, { sw.Elapsed.Milliseconds } ms");
                        ctx.Module.WriteBitcodeToFile(args.Output);
                        if (args.Link)
                        {
                        }
                    }
                }
                return(0);
            }
 public InstanceChildListViewModel(InstanceTypes instanceType)
     : base(instanceType)
 {
 }