public void AddPackage()
        {
            BasicPackage package = new BasicPackage("mypackageNew1")
            {
                Description     = "mydescription",
                Url             = "http://myurl.test/",
                IsMaster        = true,
                SelectedVersion = new PackageVersion("2.4")
            };

            package.Versions.Add(new PackageVersion("1.0"));
            package.Versions.Add(new PackageVersion("2.3"));
            package.Versions.Add(new PackageVersion("2.4"));
            package.Dependencies.Add(new Dependency("mypackage2.myfeature1"));
            package.Dependencies.Add(new Dependency("mypackage2.myfeature2"));
            package.Dependencies.Add(new Dependency("mypackage3.myfeature1"));
            package.Features.Add(new Feature("myfeature1"));
            package.Features.Add(new Feature("myfeature2"));

            string             pkgdir = IO.Path.Combine("Testdata", "newpackagefiles");
            string             repdir = IO.Path.Combine("Testdata", "packagerepository");
            IPackageRepository rep    = new DirectoryPackageRepository("myrep", repdir);

            rep.AddPackage(package, pkgdir);
            rep.Refresh();

            Assert.IsTrue(IO.Directory.Exists(IO.Path.Combine(repdir, "mypackageNew1")), "Package dir does not exist.");
            Assert.IsTrue(IO.File.Exists(IO.Path.Combine(repdir, "mypackageNew1", "mytemplate.cshtml")), "Package files do not exist.");
            Assert.IsTrue(IO.File.Exists(IO.Path.Combine(repdir, "mypackageNew1", "package.wpdef")), "Package definition file does not exist.");
            Assert.IsNotNull(rep.GetPackage("mypackageNew1"), "New package not found in repository.");
        }
Exemplo n.º 2
0
 public StateObject(IDbHelper dbHelper)
 {
     Machine   = new Machine();
     DataItems = new List <DataItem>();
     Package   = new BasicPackage();
     DbHelper  = dbHelper;
 }
        public void Refresh()
        {
            BasicPackage       package = new BasicPackage("mypackageNew1");
            string             pkgdir  = IO.Path.Combine("Testdata", "newpackagefiles");
            string             repdir  = IO.Path.Combine("Testdata", "packagerepository");
            IPackageRepository rep     = new DirectoryPackageRepository("myrep", repdir);

            Assert.IsNull(rep.GetPackage("mypackageNew1"));
            rep.AddPackage(package, pkgdir);
            rep.Refresh();
            Assert.IsNotNull(rep.GetPackage("mypackageNew1"));
        }
        public void SetSite()
        {
            // Create the package
            IVsPackage package = new BasicPackage() as IVsPackage;

            Assert.IsNotNull(package, "The object does not implement IVsPackage");

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the package
            Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

            // Unsite the package
            Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
        }
Exemplo n.º 5
0
        public void CompileSimpleWithLayout()
        {
            BasicPackage pkg    = new BasicPackage("mycoolpackage");
            string       tpldir = IO.Path.Combine("Testdata", "razortemplates", "simplewithlayout");
            string       outpath;

            if (!PathExtensions.GetTempPath(out outpath))
            {
                throw new Exception("Could not get temp path.");
            }
            outpath = IO.Path.Combine(outpath, "result.html");
            Template.CompileFile(tpldir, "hellopackage", pkg, outpath);
            string viewcontent     = IO.File.ReadAllText(outpath);
            string expectedcontent = string.Format("<html>{0}\t<head>{0}\t\t<title>Simple Template with layout</title>{0}\t</head>{0}\t<body>{0}\t\t{0}Hello mycoolpackage!{0}\t</body>{0}</html>", Environment.NewLine);

            Assert.AreEqual(expectedcontent, viewcontent);
        }
Exemplo n.º 6
0
        public void AddPackage()
        {
            IPackageRepository rep1 = new DirectoryPackageRepository("myrep1", IO.Path.Combine("Testdata", "packagerepository"));
            IPackageRepository rep2 = new DirectoryPackageRepository("myrep2", IO.Path.Combine("Testdata", "packagerepository2"));
            IPackageRepository rep  = new MultiPackageRepository("myrep", rep1, rep2);

            BasicPackage package = new BasicPackage("mypackageNew1");

            string tmpdir = null;

            if (!PathExtensions.GetTempPath(out tmpdir))
            {
                throw new Exception("Could not get tmpdir.");
            }

            Assert.Throws <NotImplementedException>(
                delegate {
                rep.AddPackage(package, tmpdir);
            }
                );
        }
Exemplo n.º 7
0
        public void DeserializePackage()
        {
            string       packagestring = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Package xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n  <Name>mypackage1</Name>\r\n  <Description>mydescription</Description>\r\n  <Url>http://myurl.test/</Url>\r\n  <IsMaster>true</IsMaster>\r\n  <Versions>\r\n    <Version>\r\n      <Name>1.0</Name>\r\n    </Version>\r\n    <Version>\r\n      <Name>2.3</Name>\r\n    </Version>\r\n    <Version>\r\n      <Name>2.4</Name>\r\n    </Version>\r\n  </Versions>\r\n  <Dependencies>\r\n    <Dependency>\r\n      <Name>mypackage2.myfeature1</Name>\r\n      <Version>\r\n        <Name>*</Name>\r\n      </Version>\r\n      <IsOptional>false</IsOptional>\r\n    </Dependency>\r\n    <Dependency>\r\n      <Name>mypackage2.myfeature2</Name>\r\n      <Version>\r\n        <Name>*</Name>\r\n      </Version>\r\n      <IsOptional>false</IsOptional>\r\n    </Dependency>\r\n    <Dependency>\r\n      <Name>mypackage3.myfeature1</Name>\r\n      <Version>\r\n        <Name>*</Name>\r\n      </Version>\r\n      <IsOptional>false</IsOptional>\r\n    </Dependency>\r\n  </Dependencies>\r\n  <SelectedVersion>\r\n    <Name>2.4</Name>\r\n  </SelectedVersion>\r\n  <Features>\r\n    <Feature>\r\n      <Name>myfeature1</Name>\r\n      <Enabled>false</Enabled>\r\n    </Feature>\r\n    <Feature>\r\n      <Name>myfeature2</Name>\r\n      <Enabled>false</Enabled>\r\n    </Feature>\r\n  </Features>\r\n</Package>";
            IPackage     package       = WaldiSerializer.DeserializePackage(packagestring);
            BasicPackage expected      = new BasicPackage("mypackage1")
            {
                Description     = "mydescription",
                Url             = "http://myurl.test/",
                IsMaster        = true,
                SelectedVersion = new PackageVersion("2.4")
            };

            expected.Versions.Add(new PackageVersion("1.0"));
            expected.Versions.Add(new PackageVersion("2.3"));
            expected.Versions.Add(new PackageVersion("2.4"));
            expected.Dependencies.Add(new Dependency("mypackage2.myfeature1"));
            expected.Dependencies.Add(new Dependency("mypackage2.myfeature2"));
            expected.Dependencies.Add(new Dependency("mypackage3.myfeature1"));
            expected.Features.Add(new Feature("myfeature1"));
            expected.Features.Add(new Feature("myfeature2"));
            Assert.AreEqual(expected as IPackage, package as IPackage);
        }
Exemplo n.º 8
0
        public void RentACar()
        {
            Console.WriteLine("Your choices are: \n");
            IPackage basic = new BasicPackage();

            Console.WriteLine("1-" + basic.ToString());
            IPackage gold = new GoldDecorator(basic);

            Console.WriteLine("2-" + gold.ToString());
            IPackage platinum = new PlatinumDecorator(basic);

            Console.WriteLine("3-" + platinum.ToString());
            Console.WriteLine("4-Abort");

            Console.WriteLine("What do you wish for?");
            int input = Convert.ToInt32(Console.ReadLine());

            switch (input)
            {
            case 1:
                userRequest.ApplyCarRentalRequest(new RentCarRequest(basic));
                break;

            case 2:
                userRequest.ApplyCarRentalRequest(new RentCarRequest(gold));
                break;

            case 3:
                userRequest.ApplyCarRentalRequest(new RentCarRequest(platinum));
                break;

            case 4:
                break;

            default:
                Console.WriteLine("Invalid command");
                break;
            }
        }
        public void IsIVsPackage()
        {
            BasicPackage package = new BasicPackage();

            Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
        }
 public void CreateInstance()
 {
     BasicPackage package = new BasicPackage();
 }
Exemplo n.º 11
0
 public void RemoveBasicPackage(BasicPackage basicPackage)
 {
     _context.BasicPackages.Remove(basicPackage);
 }
Exemplo n.º 12
0
 public void AddBasicPackage(BasicPackage basicPackage)
 {
     _context.BasicPackages.Add(basicPackage);
 }
Exemplo n.º 13
0
        private byte[] PrepareSendData(StateObject state)
        {
            byte[] result = null;
            switch (state.Package.CID)
            {
            case FuncCode.Ensure:
                _logManager.Info($"{MessageType.Send} => 确认报文");
                var package = new EnsurePackage
                {
                    PID       = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID       = SocketHelper.HostToNetwork(FuncCode.Ensure),
                    ST        = 0,
                    UID       = 0,
                    VER       = SocketHelper.HostToNetwork((ushort)0x1000),
                    IPAddress = "".PadRight(20, '\0'),
                    Port      = SocketHelper.HostToNetwork((uint)0)
                };
                result = SocketHelper.StructToBytes(package);
                _logManager.Info($"{MessageType.Send} => {PrintReceivebytes(result)}");
                break;

            case FuncCode.Redirect:
                _logManager.Info($"{MessageType.Send} => 重定向报文");
                var package2 = new EnsurePackage
                {
                    PID       = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID       = SocketHelper.HostToNetwork(FuncCode.Redirect),
                    ST        = 0,
                    UID       = 0,
                    VER       = SocketHelper.HostToNetwork((ushort)0x1000),
                    IPAddress = "127.0.0.1".PadRight(20, '\0'),
                    Port      = SocketHelper.HostToNetwork((uint)11000)
                };
                result = SocketHelper.StructToBytes(package2);
                break;

            case FuncCode.Close:
                _logManager.Info($"{MessageType.Send} => 关闭报文");
                var package3 = new EnsurePackage
                {
                    PID       = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID       = SocketHelper.HostToNetwork(FuncCode.Close),
                    ST        = 0,
                    UID       = 0,
                    VER       = SocketHelper.HostToNetwork((ushort)0x1000),
                    IPAddress = "".PadRight(20, '\0'),
                    Port      = SocketHelper.HostToNetwork((uint)0)
                };
                result = SocketHelper.StructToBytes(package3);
                break;

            case FuncCode.Login:
                _logManager.Info($"{MessageType.Login}{state.Machine.MachineCode} => 登录报文");
                var package4 = new LoginPackage
                {
                    PID      = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID      = SocketHelper.HostToNetwork(FuncCode.Login),
                    ST       = 0,
                    UID      = Convert.ToByte(state.UserName),
                    VER      = SocketHelper.HostToNetwork((ushort)0x1000),
                    Password = state.Password.PadRight(8, '\0')
                };
                result = SocketHelper.StructToBytes(package4);
                _logManager.Info($"{MessageType.Send} => {PrintReceivebytes(result)}");
                break;

            case FuncCode.EnumAllData:
                _logManager.Info($"{MessageType.RequireDataItem}{state.Machine.MachineCode} => 枚举请求报文");
                var package5 = new BasicPackage
                {
                    PID = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID = SocketHelper.HostToNetwork(FuncCode.EnumAllData),
                    ST  = 0,
                    UID = Convert.ToByte(state.UserName),
                    VER = SocketHelper.HostToNetwork((ushort)0x1000)
                };
                result = SocketHelper.StructToBytes(package5);
                break;

            case FuncCode.RequestForPush:
                _logManager.Info($"{MessageType.RequireDataItem}{state.Machine.MachineCode} => 推送请求报文");
                var package6 = new RequestPushPackage
                {
                    PID = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID = SocketHelper.HostToNetwork(FuncCode.RequestForPush),
                    UID = state.UserName,
                    ST  = 0,
                    VER = SocketHelper.HostToNetwork((ushort)0x1000),
                    RV  = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }
                };
                result = SocketHelper.StructToBytes(package6);
                _logManager.Info($"{MessageType.Send} => {PrintReceivebytes(result)}");
                break;

            case FuncCode.NullCommandReply:
                _logManager.Info($"{MessageType.KeepAlive}{state.Machine.MachineCode} => 心跳包回复报文");
                var package7 = new BasicPackage
                {
                    PID = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID = SocketHelper.HostToNetwork(FuncCode.NullCommandReply),
                    ST  = 0,
                    UID = Convert.ToByte(state.UserName),
                    VER = SocketHelper.HostToNetwork((ushort)0x1000)
                };
                result = SocketHelper.StructToBytes(package7);
                _logManager.Info($"{MessageType.Send} => {PrintReceivebytes(result)}");
                break;

            case FuncCode.PushDataReply:
                _logManager.Info($"{MessageType.Send}{state.Machine.MachineCode} => 推送回复报文");
                var package8 = new BasicPackage
                {
                    PID = SocketHelper.HostToNetwork((ushort)0x0000),
                    CID = SocketHelper.HostToNetwork(FuncCode.PushDataReply),
                    ST  = 0,
                    UID = Convert.ToByte(state.UserName),
                    VER = SocketHelper.HostToNetwork((ushort)0x1000)
                };
                result = SocketHelper.StructToBytes(package8);
                _logManager.Info($"{MessageType.Send} => {PrintReceivebytes(result)}");
                break;
            }
            return(result);
        }
Exemplo n.º 14
0
 public Package(Reducer <State> rootReducer)
 {
     package = new BasicPackage(rootReducer);
     Middleware();
 }
Exemplo n.º 15
0
        private PackageList GetPackages()
        {
            BasicPackage p1 = new BasicPackage("package1")
            {
                Description = "mydescription_package1",
                IsMaster    = false,
                Url         = "http://myurl_package1.com"
            };

            p1.Versions.Add(new PackageVersion("1.1"));
            p1.Versions.Add(new PackageVersion("1.2"));

            BasicPackage p2 = new BasicPackage("package2")
            {
                Description = "mydescription_package2",
                IsMaster    = false,
                Url         = "http://myurl_package2.com"
            };

            p2.Versions.Add(new PackageVersion("2.1"));
            p2.Versions.Add(new PackageVersion("2.2"));
            p2.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p2.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });

            BasicPackage p3 = new BasicPackage("package3")
            {
                Description = "mydescription_package3",
                IsMaster    = false,
                Url         = "http://myurl_package3.com"
            };

            p3.Versions.Add(new PackageVersion("3.1"));
            p3.Versions.Add(new PackageVersion("3.2"));
            p3.Versions.Add(new PackageVersion("3.3"));
            p3.Dependencies.Add(new Dependency("package2.feature1")
            {
                Version = new PackageVersion("2.2")
            });
            p3.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p3.Dependencies.Add(new Dependency("package4.feature2")
            {
                Version = new PackageVersion("4.4")
            });
            p3.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });
            p3.Features.Add(new Feature("feature2")
            {
                Description = "description_feature2",
                Url         = "http://myurl_feature2.com/feat",
                Enabled     = false
            });

            BasicPackage p4 = new BasicPackage("package4")
            {
                Description = "mydescription_package4",
                IsMaster    = false,
                Url         = "http://myurl_package4.com"
            };

            p4.Versions.Add(new PackageVersion("4.1"));
            p4.Versions.Add(new PackageVersion("4.4"));
            p4.Dependencies.Add(new Dependency("package2.feature1")
            {
                Version = new PackageVersion("2.2")
            });
            p4.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p4.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });
            p4.Features.Add(new Feature("feature2")
            {
                Description = "description_feature2",
                Url         = "http://myurl_feature2.com/feat",
                Enabled     = false
            });

            PackageList packages = new PackageList();

            packages.Add(p1);
            packages.Add(p2);
            packages.Add(p3);
            packages.Add(p4);
            return(packages);
        }
Exemplo n.º 16
0
        public ActionResult Create(GigFormViewModel gigFormViewModel, HttpPostedFileBase upload)
        {
            // CHECK IF MODEL IS VALID
            if (!ModelState.IsValid)
            {
                return(View(gigFormViewModel));
            }

            var userId = User.Identity.GetUserId();
            // CREATE NEW GIG

            //Create a Basic Selling Package
            var basicPackage = new BasicPackage(gigFormViewModel);

            unitOfWork.BasicPackageRepository.AddBasicPackage(basicPackage);

            //Create an Advanced Selling Package
            var advancedPackage = new AdvancedPackage(gigFormViewModel);

            unitOfWork.AdvancedPackageRepository.AddAdvancedPackage(advancedPackage);

            //Create a Premium Selling Package
            var premiumPackage = new PremiumPackage(gigFormViewModel);

            unitOfWork.PremiumPackageRepository.AddPremiumPackage(premiumPackage);

            //Get the user Id in order to bind everything together
            var infleuncer = unitOfWork.InfluencerRepository.GetInfluencerForUser(userId);

            if (infleuncer == null)
            {
                return(HttpNotFound());
            }

            // Create a Gig
            var gig = new Gig(gigFormViewModel, userId, infleuncer.ID);


            //IF THERE IS NEW FILE UPLOADED
            if (upload != null && upload.ContentLength > 0)
            {
                //WE WILL CREATE A NEW FILE WITH THE TYPE OF AVATAR (THIS IS WHAT I NEED HERE)
                var background = FileUpload.GiveGigBackground(System.IO.Path.GetFileName(upload.FileName), upload.ContentType, null, FileType.Photo, gig.ID);

                //BLACK MAGIC
                using (var reader = new System.IO.BinaryReader(upload.InputStream))
                {
                    background.Content = reader.ReadBytes(upload.ContentLength);
                }

                // GIVE INFLUENCER THE LIST OF FILES WITH THE AVATAR FILE
                gig.FileUploads = new List <FileUpload> {
                    background
                };
            }

            unitOfWork.GigsRepository.AddGig(gig);

            unitOfWork.Complete();

            // WHEN EVERYTHING IS DONE GO TO INDEX
            return(RedirectToAction("Index"));
        }