コード例 #1
0
        public void Solve()
        {
            long mask     = 0;
            int  minflips = Bits + 1;
            long maxvalue = 1;

            maxvalue <<= Bits;
            var flippedOutlets = new HashSet <long>(Outlets);
            int numBits        = 0;

            while (mask < maxvalue)
            {
                if (numBits < minflips)
                {
                    flippedOutlets = new HashSet <long>(Outlets.Select(x => x ^ mask));
                    if (flippedOutlets.IsSubsetOf(Devices) && flippedOutlets.IsSupersetOf(Devices))
                    {
                        minflips = numBits;
                    }
                }
                for (long j = 1; (j & mask) != 0; j <<= 1)
                {
                    numBits--;
                }
                numBits++;
                mask++;
            }
            if (minflips <= Bits)
            {
                NumFlips = minflips;
            }
        }
コード例 #2
0
        public void GenerateCodeTypeDeclaration(CodeDomProvider provider, CodeGeneratorOptions generatorOptions,
                                                string wrapperName, out CodeTypeDeclaration ctd, out string ns)
        {
            var registerAtt = new CodeTypeReference(wrapperName + ".Foundation.RegisterAttribute");

            ctd = new System.CodeDom.CodeTypeDeclaration()
            {
                IsPartial = true,
            };

            if (Outlets.Any(o => o.IsDesigner) || Actions.Any(a => a.IsDesigner))
            {
                AddWarningDisablePragmas(ctd, provider);
            }

            var dotIdx = CliName.LastIndexOf('.');

            if (dotIdx > 0)
            {
                ns       = CliName.Substring(0, dotIdx);
                ctd.Name = CliName.Substring(dotIdx + 1);
            }
            else
            {
                ctd.Name = CliName;
                ns       = null;
            }
            if (IsRegisteredInDesigner)
            {
                AddAttribute(ctd.CustomAttributes, registerAtt, ObjCName);
            }

            GenerateActionsOutlets(provider, ctd, wrapperName);
        }
コード例 #3
0
        public NuGetListPackagesNode(Workspace workspace) : base(workspace)
        {
            Settings = Inlets.Create <ISettings>(nameof(Settings));
            Repo     = Outlets.Create <string>(nameof(Repo));

            Settings.OnNext(NuGet.Configuration.Settings.LoadDefaultSettings("."));
        }
コード例 #4
0
        public async Task <IHttpActionResult> PutOutlets(int id, Outlets outlets)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != outlets.outlet_id)
            {
                return(BadRequest());
            }
            outlets.opening_status  = true;
            db.Entry(outlets).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OutletsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(long id, [Bind("OutletID,OutletName")] Outlets outlets)
        {
            if (id != outlets.OutletID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(outlets);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OutletsExists(outlets.OutletID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(outlets));
        }
コード例 #6
0
 public void CreateOutlet(Outlets outlets)
 {
     if (outlets == null)
     {
         throw new ArgumentNullException(nameof(outlets));
     }
     _context.Outlets.Add(outlets);
 }
コード例 #7
0
        public void RemoveOutlet(Outlet outlet)
        {
            var realm = RealmManager.SharedInstance.GetRealm(null);

            realm.Write(() =>
            {
                Outlets.Remove(outlet);
            });
        }
コード例 #8
0
        public async Task <IHttpActionResult> GetOutlets(int id)
        {
            Outlets outlets = await db.Outlets.FindAsync(id);

            if (outlets == null)
            {
                return(NotFound());
            }

            return(Ok(outlets));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("OutletID,OutletName")] Outlets outlets)
        {
            if (ModelState.IsValid)
            {
                _context.Add(outlets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(outlets));
        }
コード例 #10
0
        public async Task <IHttpActionResult> PostOutlets(Outlets outlets)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Outlets.Add(outlets);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = outlets.outlet_id }, outlets));
        }
コード例 #11
0
        protected override Action <TMessage> FindReceiver(IInlet <TMessage> inletSendingMessage)
        {
            var receivers = Outlets.Select((outlet, index) => new Tuple <int, Action <TMessage> >(index, outlet.FindReceiver())).Where(t => t.Item2 != null).ToList();

            if (!receivers.Any())
            {
                return(null);
            }

            var result = TieBreaker.ResolveTie(receivers.Select(s => s.Item1));

            return(receivers.Single(s => s.Item1 == result).Item2);
        }
コード例 #12
0
        public void AddOutlet(Outlet outlet)
        {
            var realm = RealmManager.SharedInstance.GetRealm(null);
            var item  = Outlets.Where(o => o.Type.Equals(outlet.Type, StringComparison.OrdinalIgnoreCase) && o.Handle.Equals(outlet.Handle, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (item == null) //prevent adding the same outlet twice.
            {
                realm.Write(() =>
                {
                    Outlets.Add(outlet);
                });
            }
        }
コード例 #13
0
        public async Task <IHttpActionResult> DeleteOutlets(int id)
        {
            Outlets outlets = await db.Outlets.FindAsync(id);

            if (outlets == null)
            {
                return(NotFound());
            }

            db.Outlets.Remove(outlets);
            await db.SaveChangesAsync();

            return(Ok(outlets));
        }
コード例 #14
0
ファイル: NSObjectInfo.cs プロジェクト: yayanyang/monodevelop
        public void GenerateCodeTypeDeclaration(CodeDomProvider provider, CodeGeneratorOptions generatorOptions,
                                                string wrapperName, out CodeTypeDeclaration ctd, out string ns)
        {
            var registerAtt = new CodeTypeReference(wrapperName + ".Foundation.RegisterAttribute");
            var connectAtt  = new CodeTypeReference(wrapperName + ".Foundation.ConnectAttribute");
            var exportAtt   = new CodeTypeReference(wrapperName + ".Foundation.ExportAttribute");

            ctd = new System.CodeDom.CodeTypeDeclaration()
            {
                IsPartial = true,
            };

            if (Outlets.Any(o => o.IsDesigner) || Actions.Any(a => a.IsDesigner))
            {
                AddWarningDisablePragmas(ctd, provider);
            }

            var dotIdx = CliName.LastIndexOf('.');

            if (dotIdx > 0)
            {
                ns       = CliName.Substring(0, dotIdx);
                ctd.Name = CliName.Substring(dotIdx + 1);
            }
            else
            {
                ctd.Name = CliName;
                ns       = null;
            }
            AddAttribute(ctd.CustomAttributes, registerAtt, ObjCName);

            foreach (var a in Actions)
            {
                if (a.IsDesigner)
                {
                    GenerateAction(exportAtt, ctd, a, provider, generatorOptions);
                }
            }

            foreach (var o in Outlets)
            {
                if (o.IsDesigner)
                {
                    AddOutletProperty(connectAtt, ctd, o.CliName, new CodeTypeReference(o.CliType));
                }
            }
        }
コード例 #15
0
ファイル: Node.cs プロジェクト: misupov/turbina
 private void SetupAttributtedPins()
 {
     foreach (var propertyInfo in GetType().GetRuntimeProperties())
     {
         var propertyTypeInfo = propertyInfo.PropertyType.GetTypeInfo();
         if (propertyTypeInfo.IsGenericType && propertyTypeInfo.GetGenericTypeDefinition() == typeof(Inlet <>))
         {
             var designerPropertiesAttributes = propertyInfo.GetCustomAttributes <DesignerPropertiesAttribute>();
             var basicInlet = Inlets.Create(propertyInfo.Name);
             basicInlet.SetAttribute("type", propertyTypeInfo.GenericTypeArguments[0].AssemblyQualifiedName);
             var inlet = CastInlet(basicInlet, propertyTypeInfo.GenericTypeArguments[0]);
             propertyInfo.SetValue(this, inlet);
         }
         if (propertyTypeInfo.IsGenericType && propertyTypeInfo.GetGenericTypeDefinition() == typeof(Outlet <>))
         {
             var designerPropertiesAttributes = propertyInfo.GetCustomAttributes <DesignerPropertiesAttribute>();
             var nonTypedOutlet = Outlets.Create(propertyInfo.Name);
             nonTypedOutlet.SetAttribute("type", propertyTypeInfo.GenericTypeArguments[0].AssemblyQualifiedName);
             var outlet = CastOutlet(nonTypedOutlet, propertyTypeInfo.GenericTypeArguments[0]);
             propertyInfo.SetValue(this, outlet);
         }
     }
 }
コード例 #16
0
        public JObject ToJObject()
        {
            var returnObj = new JObject();

            returnObj["name"]                 = Name;
            returnObj["userDisplayName"]      = UserDisplayName;
            returnObj["title"]                = Title;
            returnObj["uuid"]                 = UUID;
            returnObj["borderColor"]          = BorderColor;
            returnObj["backgroundColor"]      = BackgroundColor;
            returnObj["companyName"]          = CompanyName;
            returnObj["companyNameTextColor"] = CompanyNameTextColor;

            JArray outletsArray = new JArray();

            foreach (var outlet in Outlets.Where(c => !c.Omitted))
            {
                var jobjectOutlet = outlet.ToJObject();
                outletsArray.Add(jobjectOutlet);
            }
            returnObj["outlets"] = outletsArray;
            return(returnObj);
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: maniargaurav/CouponAPI
        public static void OutletsFetcher()
        {
            var storeName = "";
            var startDate = "";
            var rowKey = "";
            var endDate = "";
            var eventDescription = "";

            // Retrieve the storage account from the connection string.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ConnectionString);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("Outlets");

            HtmlWeb htmlWeb = new HtmlWeb();
            HtmlDocument htmlDocument = htmlWeb.Load("http://www.premiumoutlets.com/outlets/sales.asp?id=71");

            string html = htmlDocument.DocumentNode.OuterHtml;

            IEnumerable<HtmlNode> listItems = htmlDocument.DocumentNode.SelectNodes("//*[contains(@class,'StoreEvents')]");

            var storeEvents = "";
            foreach (var item in listItems)
            {
                storeEvents = item.InnerHtml;
            }

            string splitStr = "<div style='border-top: 1px solid #E2E2E2; margin:8px 0 6px 0;padding:0;position:relative;'></div>";
            string[] colCoupons = storeEvents.Split(new string[] { splitStr }, StringSplitOptions.None);

            foreach (var x in colCoupons)
            {
                rowKey = Guid.NewGuid().ToString();
                var coupon = x.Replace("<h4 class='cap mb-10'>", "").Replace("</h4>", "").Replace("<br>", "");
                storeName = coupon.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[0];
                var eventDate = coupon.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[1];
                var eventTemp = coupon.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                List<string> eventDescription_li = new List<string>(eventTemp);
                eventDescription_li.RemoveRange(0, 2);
                eventDescription = string.Join("\n", eventDescription_li.ToArray());

                try
                {

                    if (eventDate.Split(' ').Count() == 5)
                    {
                        startDate = (DateTime.Parse(eventDate.Split(' ')[0] + " "
                            + eventDate.Split(' ')[1] + " " + eventDate.Split(' ')[4])).ToString().Split(' ')[0];
                        endDate = (DateTime.Parse(eventDate.Split(' ')[0] + " "
                            + eventDate.Split(' ')[3] + " " + eventDate.Split(' ')[4])).ToString().Split(' ')[0];
                    }
                    else if (eventDate.Split(' ').Count() == 6)
                    {
                        startDate = (DateTime.Parse(eventDate.Split(' ')[0] + " "
                            + eventDate.Split(' ')[1] + " " + eventDate.Split(' ')[5])).ToString().Split(' ')[0];
                        endDate = (DateTime.Parse(eventDate.Split(' ')[3] + " "
                            + eventDate.Split(' ')[4] + " " + eventDate.Split(' ')[5])).ToString().Split(' ')[0];
                    }
                    else
                    {
                        startDate = (DateTime.Parse(eventDate.Split(' ')[0] + " "
                            + eventDate.Split(' ')[1] + " " + eventDate.Split(' ')[6])).ToString().Split(' ')[0];
                        endDate = (DateTime.Parse(eventDate.Split(' ')[4] + " "
                            + eventDate.Split(' ')[5] + " " + eventDate.Split(' ')[6])).ToString().Split(' ')[0];
                    }
                }
                catch (Exception e)
                {
                    continue;
                }

                Console.WriteLine(storeName);
                Console.WriteLine(startDate);
                Console.WriteLine(endDate);
                Console.WriteLine(eventDescription);
                //Console.ReadLine();

                // Create a new customer entity.
                Outlets product1 = new Outlets("Outlets", rowKey);
                product1.StoreName = storeName;
                product1.StartDate = startDate;
                product1.EndDate = endDate;
                product1.Event = eventDescription;

                // Create the TableOperation that inserts the customer entity.
                TableOperation insertOperation = TableOperation.Insert(product1);

                // Execute the insert operation.
                table.Execute(insertOperation);
            }
        }
コード例 #18
0
 public void CreateOutlet(Outlets outlets)
 {
     throw new NotImplementedException();
 }