void ReleaseDesignerOutlets()
        {
            if (ContentConstraint != null)
            {
                ContentConstraint.Dispose();
                ContentConstraint = null;
            }

            if (RepositoryDescription != null)
            {
                RepositoryDescription.Dispose();
                RepositoryDescription = null;
            }

            if (RepositoryImage != null)
            {
                RepositoryImage.Dispose();
                RepositoryImage = null;
            }

            if (RepositoryName != null)
            {
                RepositoryName.Dispose();
                RepositoryName = null;
            }

            if (RepositoryOwner != null)
            {
                RepositoryOwner.Dispose();
                RepositoryOwner = null;
            }
        }
예제 #2
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context       = context;
     Images         = new RepositoryImage(context);
     Advertisements = new RepositoryAdvertisement(context);
     Categories     = new RepositoryCategory(context);
     Comments       = new RepositoryComment(context);
 }
예제 #3
0
        private void HandleOutput()
        {
            var    formatter = new XmlSerializer(typeof(RepositoryImage));
            string path      = (outputPath ?? string.Empty) + DateTime.Now.Ticks;

            if (numberOfChangesetsPerFile != int.MaxValue)
            {
                var numberOfFiles = changesets.Count() / numberOfChangesetsPerFile;
                var remainder     = changesets.Count() % numberOfChangesetsPerFile;

                Debug.WriteLine("Starting Serialization at: " + DateTime.Now);

                int i;
                for (i = 0; i < numberOfFiles; i++)
                {
                    var filePath   = path + "_" + i.ToString("000000") + ".xml";
                    var output     = new FileStream(filePath, FileMode.Create);
                    var repository = new RepositoryImage(source)
                    {
                        Changesets = changesets.GetRange(i * numberOfChangesetsPerFile, numberOfChangesetsPerFile).ToArray()
                    };
                    formatter.Serialize(output, repository);
                    output.Close();
                }

                if (remainder > 0)
                {
                    var filePath   = path + "_" + i.ToString("000000") + ".xml";
                    var output     = new FileStream(filePath, FileMode.Create);
                    var repository = new RepositoryImage(source)
                    {
                        Changesets = changesets.GetRange(i * numberOfChangesetsPerFile, remainder).ToArray()
                    };
                    formatter.Serialize(output, repository);
                    output.Close();
                }
            }
            else
            {
                path += ".xml";
                var output = new FileStream(path, FileMode.Create);

                Debug.WriteLine("Starting Serialization at: " + DateTime.Now);

                var repository = new RepositoryImage(source)
                {
                    Changesets = changesets.ToArray()
                };
                formatter.Serialize(output, repository);
                output.Close();
            }

            Debug.WriteLine("Finished Serialization at: " + DateTime.Now);
        }
예제 #4
0
        public void Bind(string name, string description, string repoOwner, UIImage logoImage, string logoUri)
        {
            RepositoryName.Text          = name;
            RepositoryOwner.Text         = repoOwner;
            RepositoryDescription.Hidden = string.IsNullOrWhiteSpace(description);
            RepositoryDescription.Text   = description ?? string.Empty;
            ContentConstraint.Constant   = RepositoryDescription.Hidden ? 0 : DefaultContentConstraint;

            if (logoUri == null)
            {
                RepositoryImage.Image = logoImage;
            }
            else
            {
                RepositoryImage.SetImage(new NSUrl(logoUri), logoImage);
            }
        }
        public void Bind(string name, string description, string repoOwner, Avatar logoUri)
        {
            RepositoryName.Text          = name;
            RepositoryOwner.Text         = repoOwner;
            RepositoryDescription.Hidden = string.IsNullOrWhiteSpace(description);
            RepositoryDescription.Text   = description ?? string.Empty;
            ContentConstraint.Constant   = RepositoryDescription.Hidden ? 0 : DefaultContentConstraint;

            var uri = logoUri.ToUri(64);

            if (uri == null)
            {
                RepositoryImage.Image = Images.RepoPlaceholder;
            }
            else
            {
                RepositoryImage.SetImage(new NSUrl(uri.AbsoluteUri), Images.RepoPlaceholder);
            }
        }
예제 #6
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            RepositoryName.TextColor            = Theme.CurrentTheme.MainTitleColor;
            RepositoryDescription.TextColor     = Theme.CurrentTheme.MainTextColor;
            RepositoryImage.Layer.MasksToBounds = true;
            RepositoryImage.Layer.CornerRadius  = RepositoryImage.Bounds.Height / 2f;
            DefaultContentConstraint            = ContentConstraint.Constant;

            this.WhenAnyValue(x => x.ViewModel)
            .Where(x => x != null)
            .Subscribe(x =>
            {
                RepositoryName.Text          = x.Name;
                RepositoryOwner.Text         = x.Owner;
                RepositoryDescription.Hidden = string.IsNullOrWhiteSpace(x.Description);
                RepositoryDescription.Text   = x.Description ?? string.Empty;
                ContentConstraint.Constant   = RepositoryDescription.Hidden ? 0 : DefaultContentConstraint;
                RepositoryImage.SetAvatar(x.Avatar);
            });
        }
예제 #7
0
 //public Game(RepositoryImage serviceImg)
 public Game()
 {
     //_serviceImg = serviceImg;
     _serviceImg = SimpleIoc.Default.GetInstance <RepositoryImage>();
 }
예제 #8
0
        private (FargateService, Amazon.CDK.AWS.ServiceDiscovery.IService) CreateService(string id,
                                                                                         string serviceName,
                                                                                         string branch,
                                                                                         IVpc vpc,
                                                                                         Cluster cluster,
                                                                                         PrivateDnsNamespace cloudMapNamespace,
                                                                                         string appMeshVirtualNodeName,
                                                                                         Mesh mesh,
                                                                                         IRole taskExecutionRole,
                                                                                         RepositoryImage envoyImage,
                                                                                         ContainerImage containerImage)
        {
            var taskDefinition = new TaskDefinition(this, $"{id}_{serviceName}-{branch}-task-definiton", new TaskDefinitionProps
            {
                Compatibility      = Compatibility.FARGATE,
                MemoryMiB          = "512",
                Cpu                = "256",
                ProxyConfiguration = new AppMeshProxyConfiguration(new AppMeshProxyConfigurationConfigProps()
                {
                    ContainerName = "envoy",
                    Properties    = new AppMeshProxyConfigurationProps()
                    {
                        AppPorts = new double[1] {
                            5000
                        },
                        ProxyIngressPort = 15000,
                        ProxyEgressPort  = 15001,
                        IgnoredUID       = 1337,
                        EgressIgnoredIPs = new string[2] {
                            "169.254.170.2", "169.254.169.254"
                        }
                    }
                }),
                Family        = $"{id}_{serviceName}-task-definition",
                ExecutionRole = taskExecutionRole
            });
            var envoyContainer = taskDefinition.AddContainer("envoy", new ContainerDefinitionOptions
            {
                User        = "******",
                Image       = envoyImage,
                Essential   = true,
                Environment = new Dictionary <string, string>
                {
                    { "APPMESH_VIRTUAL_NODE_NAME", $"mesh/{mesh.MeshName}/virtualNode/{appMeshVirtualNodeName}" }
                },
                HealthCheck = new Amazon.CDK.AWS.ECS.HealthCheck()
                {
                    Command     = new string[] { "CMD-SHELL", "curl -s http://localhost:9901/server_info | grep state | grep -q LIVE" },
                    Interval    = Duration.Seconds(5),
                    Timeout     = Duration.Seconds(2),
                    StartPeriod = Duration.Seconds(10),
                    Retries     = 3
                },
                MemoryLimitMiB = 500,
                Logging        = new AwsLogDriver(new AwsLogDriverProps()
                {
                    StreamPrefix = $"{id}_{serviceName}-{branch}-envoy",
                    LogRetention = RetentionDays.ONE_DAY
                }),
            });
            var container = taskDefinition.AddContainer($"{serviceName}-container", new ContainerDefinitionOptions()
            {
                Image   = containerImage,
                Logging = new AwsLogDriver(new AwsLogDriverProps()
                {
                    StreamPrefix = $"{id}_{serviceName}-{branch}-service",
                    LogRetention = RetentionDays.ONE_DAY
                }),
                Essential   = true,
                Environment = new Dictionary <string, string>
                {
                    { "BRANCH", branch },
                    { "APPMESH_NAMESPACE", cloudMapNamespace.PrivateDnsNamespaceName }
                }
            });

            container.AddPortMappings(new Amazon.CDK.AWS.ECS.PortMapping()
            {
                ContainerPort = 5000
            });
            container.AddContainerDependencies(new ContainerDependency()
            {
                Condition = ContainerDependencyCondition.HEALTHY,
                Container = envoyContainer
            });
            // Cloudmap will append the namespace to the dns entry in R53.
            // We're explicitly checking for master here because for service to service lookups to go via the envoy proxy, the DNS name must resolve.
            // see https://github.com/aws/aws-app-mesh-roadmap/issues/65
            // i.e I want the ping service to call http://pong-service.{namespace}:5000/ and for this to be routed correctly by the proxy.
            // If you create the fargate task with cloudmap service integration with a more specific (branched) DNS name then pong-service.{namespace} r53 entry will never be created
            // and routing doesn't work through envoy.
            var dnsName = $"{serviceName}-service{(branch == "master" ? "" : "-" + branch)}";
            var sg      = new SecurityGroup(this, $"{id}_{serviceName}-{branch}-sg", new SecurityGroupProps()
            {
                AllowAllOutbound  = true,
                SecurityGroupName = $"{id}_{serviceName}-{branch}-sg",
                Vpc = vpc,
            });

            sg.AddIngressRule(Peer.AnyIpv4(), new Port(new PortProps()
            {
                Protocol = Amazon.CDK.AWS.EC2.Protocol.TCP, FromPort = 5000, ToPort = 5000, StringRepresentation = "tcp:5000:5000"
            }), "allow access from outside.");
            var fargateService = new Amazon.CDK.AWS.ECS.FargateService(this, $"{serviceName}-{branch}-service", new FargateServiceProps
            {
                ServiceName    = $"{serviceName}-{branch}-service",
                AssignPublicIp = true,
                Cluster        = cluster,
                TaskDefinition = taskDefinition,
                VpcSubnets     = new SubnetSelection()
                {
                    Subnets = vpc.PublicSubnets
                },
                CloudMapOptions = new CloudMapOptions()
                {
                    Name              = dnsName,
                    DnsRecordType     = DnsRecordType.A,
                    CloudMapNamespace = cloudMapNamespace
                },
                SecurityGroup = sg
            });

            return(fargateService, fargateService.CloudMapService);
        }