Example #1
0
		/// <summary>
		/// Create a new <i>Service Description Table</i> instance.
		/// </summary>
		/// <param name="section">The section which is currently parsed.</param>
		public SDT(Section section) : base(section)
		{
			// Get the size of the service entry region
			int offset = 8, length = section.Length - 3 - offset - 4;

			// Minimum size
			if ( length < 0 ) return;

			// Construct
			TransportStreamIdentifier = Tools.MergeBytesToWord(section[1], section[0]);
			OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[6], section[5]);

			// Create helper
			ArrayList services = new ArrayList();

			// Process
			for ( ServiceEntry entry ; null != (entry = ServiceEntry.Create(this, offset, length)) ; )
				if ( entry.IsValid )
				{
					// Remember
					services.Add(entry);

					// Correct
					offset += entry.Length;
					length -= entry.Length;
				}

			// Usefull
			m_IsValid = (0 == length);

			// Convert
			if ( m_IsValid ) Services = (ServiceEntry[])services.ToArray(typeof(ServiceEntry));
		}
Example #2
0
		public static IEnumerable<Section> Get(IEnumerable<Assembly> testAssemblies)
		{
			var categories = new Dictionary<string, Section>();
			foreach (var asm in testAssemblies)
			{
				foreach (var type in asm.ExportedTypes)
				{
					#if PCL
					var section = type.GetTypeInfo().GetCustomAttribute<SectionAttribute>(false);
					#else
					var section = type.GetCustomAttribute<SectionAttribute>(false);
					#endif
					if (section != null)
					{
						if (section.Requires != null && !Platform.Instance.Supports(section.Requires))
							continue;

						Section category;
						if (!categories.TryGetValue(section.Category, out category))
							categories.Add(section.Category, category = new Section { Text = section.Category });

						var testType = type;
						category.Add(new SectionItem { Creator = () => Activator.CreateInstance(testType) as Control, Text = section.Name });
					}
				}
			}
			foreach (var category in categories.Values)
				category.Sort((x, y) => string.Compare(x.Text, y.Text, StringComparison.CurrentCultureIgnoreCase));
			return categories.Values.OrderBy(r => r.Text);
		}
Example #3
0
 //returns the cost of the newly added section
 public void AddSection(Section s)
 {
     this.sections.Add(s);
     s.attributes.height = this.sections.Count-1;
     s.attributes.myTower = this;
     StressCheck();
 }
        public LastfmPreferences (LastfmSource source)
        {
            var service = ServiceManager.Get<PreferenceService> ();
            if (service == null) {
                return;
            }

            this.source = source;

            service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters;
            source_page = new Banshee.Preferences.SourcePage (source) {
                (account_section = new Section ("lastfm-account", Catalog.GetString ("Account"), 20) {
                    (username_preference = new SchemaPreference<string> (LastfmSource.LastUserSchema,
                        Catalog.GetString ("_Username")) {
                        ShowLabel = false
                    }),
                    new VoidPreference ("lastfm-signup")
                }),
                (prefs_section = new Section ("lastfm-settings", Catalog.GetString ("Preferences"), 30))
            };

            scrobbler = ServiceManager.Get<Banshee.Lastfm.Audioscrobbler.AudioscrobblerService> ();
            if (scrobbler != null) {
                reporting_preference = new Preference<bool> ("enable-song-reporting",
                    Catalog.GetString ("_Enable Song Reporting"), null, scrobbler.Enabled);
                reporting_preference.ValueChanged += root => scrobbler.Enabled = reporting_preference.Value;
                prefs_section.Add (reporting_preference);
            }
        }
 public MultipleChoiceEntryElement (string caption, params string[] options): base(caption, new RadioGroup(-1)) {
     var section = new Section(caption);
     foreach(var s in options) {
         section.Add(new RadioEntryElement(s));
     }
     Add(section);
 }
        public List<ArticleInfo> ScrapePage(Section section, int page)
        {
            var builder = new UriBuilder(section.Host);
            builder.Path += section.RelativeUrl;
            var url = builder.ToString().AddQueryParameterToUrl("page", page);

            var docNode = Utilities.DownloadPage(url);
            var articleDivs = docNode.SelectNodes("//div[@class='category-headline-item']");

            var result = new List<ArticleInfo>();

            foreach (var articleDiv in articleDivs)
            {
                try
                {
                    result.Add(ParseArticleInfoDiv(articleDiv));
                }
                catch (CommonParsingException e)
                {
                }
                catch (Exception e)
                {
                    e.Data["articleDiv"] = articleDiv.OuterHtml;
                    _log.Error("An error occurred while parsing article info div.", e);
                }
            }

            return result;
        }
Example #7
0
        public ActionResult Edit(string id, Section section)
        {
            RavenSession.Store(section);
              RavenSession.SaveChanges();

              return RedirectToAction("Index");
        }
        private async Task LoadLanguages()
        {
            var lRepo = new LanguageRepository();
            var langs = await lRepo.GetLanguages();

            var sec = new Section();

            langs.Insert(0, new Language("All Languages", null));
            sec.AddAll(langs.Select(x =>
            {
                var el = new StringElement(x.Name) { Accessory = UITableViewCellAccessory.None };
                el.Clicked.Subscribe(_ => _languageSubject.OnNext(x));
                return el;
            }));

            Root.Reset(sec);

            if (SelectedLanguage != null)
            {
                var el = sec.Elements.OfType<StringElement>().FirstOrDefault(x => string.Equals(x.Caption, SelectedLanguage.Name));
                if (el != null)
                    el.Accessory = UITableViewCellAccessory.Checkmark;

                var indexPath = el?.IndexPath;
                if (indexPath != null)
                    TableView.ScrollToRow(indexPath, UITableViewScrollPosition.Middle, false);
            }
        }
		/// <summary>
		/// Parses the timeout sleep interval settings.
		/// </summary>
		/// <param name="section">The section.</param>
		/// <returns></returns>
		private TimeSpan ParseTimeoutSleepIntervalSettings(Section section)
		{
			TimeSpan timeSpan = _defaultSleepInterval;

			if (section.Settings.ContainsKey("Timeout"))
			{
				int interval;
				if (int.TryParse(section.Settings["Timeout"].Value, out interval))
				{
					timeSpan = TimeSpan.FromMilliseconds(interval);
				}
				else
				{
					UnityResolver.UnityContainer.Resolve<ILogger>().LogEvent(() =>
						Config.AppEvents.GainWinServicesExactTarget.ExactTargetWarning,
						string.Format("Can't parse timeout setting (='{1}') for {0}. {2} msec  will be used by default.",
						GetType().Name, section.Settings["Timeout"].Value, _defaultSleepInterval.TotalMilliseconds));
				}
			}
			else
			{
				UnityResolver.UnityContainer.Resolve<ILogger>().LogEvent(() =>
					Config.AppEvents.GainWinServicesExactTarget.ExactTargetWarning,
					string.Format("Can't read timeout setting for {0}. {1} msec  will be used by default.",
					GetType().Name, _defaultSleepInterval.TotalMilliseconds));
			}

			return timeSpan;
		}
Example #10
0
        /// <summary>
        /// Create a new <i>Program Association Table</i> instance.
        /// </summary>
        /// <param name="section">The section which is currently parsed.</param>
        public PAT(Section section)
            : base(section)
        {
            // Get position size of the program list
            int offset = 5, length = section.Length - 3 - offset - 4;

            // Minimum size
            if (length < 0) return;

            // Construct
            TransportStreamIdentifier = Tools.MergeBytesToWord(section[1], section[0]);

            // Process all
            for (; length >= 4; offset += 4, length -= 4)
            {
                // Load items
                ushort number = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]);
                ushort pid = (ushort)(0x1fff&Tools.MergeBytesToWord(section[offset + 3], section[offset + 2]));

                // Remember
                if (0 == number)
                {
                    // The NIT
                    NetworkInformationTable = pid;
                }
                else
                {
                    // Some program
                    ProgramIdentifier[number] = pid;
                }
            }

            // Usefull
            m_IsValid = (0 == length);
        }
Example #11
0
        /// <summary>
        /// Erzeugt eine neue Tabelle.
        /// </summary>
        /// <param name="section">Der Bereich, in den die Tabelle eingebettet ist.</param>
        public TOT( Section section )
            : base( section )
        {
            // Load length
            int length = section.Length - 7;

            // Check for minimum length required
            if (length < 7) 
                return;

            // Load the time
            Time = Tools.DecodeTime( section, 0 );

            // Correct
            length -= 7;

            // Load the length of the descriptors
            int deslen = Tools.MergeBytesToWord( section[6], section[5] ) & 0x0fff;

            // Validate
            if (deslen > length)
                return;

            // Create my descriptors
            Descriptors = Descriptor.Load( this, 7, deslen );

            // Done
            m_IsValid = (deslen == length);
        }
Example #12
0
        internal ConfigurationService()
        {
            var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            _configPath = Path.Combine(appData, AppFolderName);
            _configFileName = Path.Combine(_configPath, ConfigFileName);

            if(!Directory.Exists(_configPath))
            {
                try
                {
                    Directory.CreateDirectory(_configPath);
                }
                catch(Exception exc)
                {
                    if(exc.IsCritical())
                    {
                        throw;
                    }
                    LoggingService.Global.Error(exc);
                }
            }

            _configuration            = LoadConfig(ConfigFileName, "Configuration");
            _rootSection              = _configuration.RootSection;
            _guiSection               = _rootSection.GetCreateSection("Gui");
            _globalSection            = _rootSection.GetCreateSection("Global");
            _viewsSection             = _rootSection.GetCreateSection("Tools");
            _providersSection         = _rootSection.GetCreateSection("Providers");
            _repositoryManagerSection = _rootSection.GetCreateSection("RepositoryManager");
        }
Example #13
0
 /// <summary>
 /// Gets a list of Instrument objects filtered by a section
 /// </summary>
 /// <param name="selectedSection">A section to filter instruments by</param>
 /// <returns></returns>
 //public List<Instrument> GetInstruments(Section selectedSection)
 //{
 //    using (dbconn = new SqlConnection(Music.Properties.Settings.Default.orchestraConnection))
 //    {
 //        dbconn.Open();
 //        dbcomm = new SqlCommand(String.Format("select Instrument, Type from Instruments where Type = '{0}' order by Type asc",selectedSection.ToString()), dbconn);
 //        dbreader = dbcomm.ExecuteReader();
 //        List<Instrument> instruments = new List<Instrument>();
 //        while (dbreader.Read())
 //        {
 //            string instrumentName = dbreader["Instrument"].ToString();
 //            Section instrumentType;
 //            if (Enum.TryParse<Section>(dbreader["Type"].ToString(), true, out instrumentType))
 //                instruments.Add(new Instrument(instrumentName, instrumentType));
 //            else
 //                instruments.Add(new Instrument());
 //        }
 //        dbconn.Close();
 //        return instruments;
 //    }
 //}
 /// <summary>
 /// Gets a list of Instrument objects filtered by an array of Sections
 /// </summary>
 /// <param name="selectedSection">An array to filter instruments by</param>
 /// <returns></returns>
 public List<Instrument> GetInstruments(Section[] selectedSection)
 {
     try
     {
         using (dbconn = new SqlConnection(Music.Properties.Settings.Default.orchestraConnection))
         {
             dbconn.Open();
             //This command creates a sql string that checks for instruments of a type contained in the parameter list which is created by using a string join and some string formats
             dbcomm = new SqlCommand(String.Format("select Instrument, Type from Instruments where Type in({0}) order by Instrument asc", String.Join(",", selectedSection.Select(x => String.Format("'{0}'", x.ToString())).ToArray())), dbconn);
             dbreader = dbcomm.ExecuteReader();
             List<Instrument> instruments = new List<Instrument>();
             while (dbreader.Read())
             {
                 string instrumentName = dbreader["Instrument"].ToString();
                 Section instrumentType;
                 //This sneaky little section tries to parse the instrument value of the instrument by using the Enum.TryParse which returns a bool, if false there is a bad type and a default instrument replaces it
                 if (Enum.TryParse<Section>(dbreader["Type"].ToString(), true, out instrumentType))
                     instruments.Add(new Instrument(instrumentName, instrumentType));
                 else
                     instruments.Add(new Instrument());
             }
             return instruments;
         }
     }
     catch
     {
         throw new ArgumentException("Something has gone horribly, horribly wrong. Most likely my SQL instance is unreachable or down.");
     }
 }
Example #14
0
		/// <summary>
		/// Populates the page with sessions, grouped by time slot
		/// that are marked as 'favorite'
		/// </summary>
		protected override void PopulateTable()
		{
			// get the sessions from the database
			var sessions = BL.Managers.SessionManager.GetSessions ();
			var favs = BL.Managers.FavoritesManager.GetFavorites();
			// extract IDs from Favorites query
			List<string> favoriteIDs = new List<string>();
			foreach (var f in favs) favoriteIDs.Add (f.SessionKey);

			// build list, matching the Favorite.SessionKey with actual
			// Session.Key rows - which might have moved if the data changed
			var root = 	new RootElement ("Favorites") {
						from s in sessions
							where favoriteIDs.Contains(s.Key)
							group s by s.Start.Ticks into g
							orderby g.Key
							select new Section (new DateTime (g.Key).ToString ("dddd HH:mm")) {
							from hs in g
							   select (Element) new SessionElement (hs)
			}};	
			
			if(root.Count == 0) {
				var section = new Section("No favorites") {
					new StyledStringElement("Touch the star to favorite a session") 
				};
				root.Add(section);
			}
			Root = root;
		}	
    public void OnDestroy()
    {
        if (_section != null)
            _section.Destroy();

        _section = null;
    }
        public void ResetTest()
        {
            var objectFile = new ObjectFileMock();
            Context context = new Context(objectFile);

            Section section = new Section("Test");
            var symbol = new Symbol(SymbolType.Public, "test");
            var relocation = new Relocation(symbol, section, 0, 0, RelocationType.Default32);

            context.SymbolTable.Add(symbol);
            context.RelocationTable.Add(relocation);
            context.Section = section;
            context.Address = 123456789;
            Assert.AreEqual(symbol, context.SymbolTable[0]);
            Assert.AreEqual(relocation, context.RelocationTable[0]);
            Assert.AreEqual(section, context.Section);
            Assert.AreEqual((Int128)123456789, context.Address);

            context.Reset();

            // These have not changed
            Assert.AreEqual(symbol, context.SymbolTable[0]);
            Assert.AreEqual(relocation, context.RelocationTable[0]);

            // These are reset
            Assert.AreEqual(null, context.Section);
            Assert.AreEqual((Int128)0, context.Address);
        }
 public override void Initialize()
 {
     sectionCompletion = new Section(Document);
     bullet = new Bullet(Document);
     directives = new Directives(Document);
     base.Initialize();
 }
Example #18
0
 public static async Task<Response<List<Image>>> GetGallery(Section? section = null, Sort? sort = null, Window? window = null, bool? showViral = null, int? page = null)
 {
     string uri = "gallery";
     if (section != null)
     {
         uri += "/" + section.ToString().ToLower();
         if(sort != null)
         {
             uri += "/" + sort.ToString().ToLower();
             if(window != null)
             {
                 uri += "/" + window.ToString().ToLower();
                 if (showViral != null)
                 {
                     uri += "/" + showViral.ToString();
                     if (page != null)
                     {
                         uri += "/" + page;
                     }
                 }
             }
         }
     }
     return await NetworkHelper.GetRequest<List<Image>>(uri);
 }
Example #19
0
        public ActionResult Create(Section section)
        {
            RavenSession.Store(section);
              RavenSession.SaveChanges();

              return RedirectToAction("Index");
        }
        /// <summary>
        /// Creates a topic.
        /// </summary>
        public Topic(Section section, string fixUrl)
        {
            mTopicDoc = new Document();
            mTopicDoc.AppendChild(mTopicDoc.ImportNode(section, true, ImportFormatMode.KeepSourceFormatting));
            mTopicDoc.FirstSection.Remove();

            Paragraph headingPara = (Paragraph)mTopicDoc.FirstSection.Body.FirstChild;
            if (headingPara == null)
                ThrowTopicException("The section does not start with a paragraph.", section);

            mHeadingLevel = headingPara.ParagraphFormat.StyleIdentifier - StyleIdentifier.Heading1;
            if ((mHeadingLevel < 0) || (mHeadingLevel > 8))
                ThrowTopicException("This topic does not start with a heading style paragraph.", section);

            mTitle = headingPara.GetText().Trim();
            if (mTitle == "")
                ThrowTopicException("This topic heading does not have text.", section);

            // We actually remove the heading paragraph because <h1> will be output in the banner.
            headingPara.Remove();

            mTopicDoc.BuiltInDocumentProperties.Title = mTitle;

            FixHyperlinks(section.Document, fixUrl);
        }
	private void Core()
	{
		var rootStyles = new RootElement ("Add New Styles");

		var styleHeaderElement = new Section ("Style Header");
		var manualEntryRootElement = new RootElement ("Manual Entry");
		styleHeaderElement.Add (manualEntryRootElement);

		var quickFillElement = new Section ("Quick Fill");
		var womenTops = new RootElement ("Womens Tops");
		var womenOutwear = new RootElement ("Womens Outerwear");
		var womenSweaters = new RootElement ("Womens Sweaters");
		quickFillElement.AddAll (new [] { womenTops, womenOutwear, womenSweaters });

		rootStyles.Add (new [] { styleHeaderElement, quickFillElement });

		// DialogViewController derives from UITableViewController, so access all stuff from it
		var rootDialog = new DialogViewController (rootStyles);
		rootDialog.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Bordered, null);

		EventHandler handler = (s, e) => {
			if(_popover != null)
				_popover.Dismiss(true);
		};

		rootDialog.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, handler), true);
		rootDialog.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Create", UIBarButtonItemStyle.Bordered, null), true);

		NavigationPopoverContentViewController = new UINavigationController (rootDialog);
	}
Example #22
0
    //**************************************
    //��3��ȷ��һλ���ڲ�����ͬһ�졢ͬһʱ�̽����ſ�
    public void AgreeToTeach(Section s)
    {
        bool isSameTime = true;

          for (int i = 0; i < Teaches.Count; i++)
          {
          if (Teaches[i].OfferedIn == s.OfferedIn)
          {
              if (Teaches[i].DayOfWeek == s.DayOfWeek)
              {
                  if (Teaches[i].TimeOfDay == s.TimeOfDay)
                  {
                      isSameTime = false;
                  }
                  else continue;
              }
              else continue;
          }
          else continue;
          }

          if (isSameTime)
          {
          Teaches.Add(s);
          // We need to link this bidirectionally.
          s.Instructor = this;
          }
          else
          {
          Console.WriteLine("һλ���ڲ�����ͬһ���ͬһʱ�̽������ſΣ�");
          }
    }
Example #23
0
    //**************************************
    //
    public void AgreeToTeach(Section s)
    {
        //��ϰ14.3
          bool theSameTime = true;

          for (int i = 0; i < Teaches.Count; i++)
          {

          if (Teaches[i].OfferedIn == s.OfferedIn)
          {
              if (Teaches[i].DayOfWeek == s.DayOfWeek)
              {
                  if (Teaches[i].TimeOfDay == s.TimeOfDay)
                  {
                      theSameTime = false;
                  }
                  else continue;
              }
              else continue;
          }
          else continue;
          }

          if(theSameTime){
          Teaches.Add(s);
          // We need to link this bidirectionally.
          s.Instructor = this;
          }
          else
          {
          Console.WriteLine("ͬһ�졢ͬһʱ������Ͽ�ʱ���ͻ��");
          }
    }
Example #24
0
        private void AppendBulletedList(Section section)
        {
            Paragraph paragraph = null;

            paragraph = section.AddParagraph();

            //Append Text
            paragraph.AppendText("Bulleted List");

            paragraph.ApplyStyle(BuiltinStyle.Heading3);

            paragraph = section.AddParagraph();
            for (int i = 0; i < 5; i++)
            {
                paragraph = section.AddParagraph();
                paragraph.AppendText("Item" + i.ToString());

                if (i == 0)
                {
                    paragraph.ListFormat.ApplyBulletStyle();
                }
                else
                {
                    paragraph.ListFormat.ContinueListNumbering();
                }

                paragraph.ListFormat.ListLevelNumber = 1;
            }
        }
Example #25
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            HeaderView.SetImage(null, Images.Avatar);
            Title = ViewModel.Name;

            ViewModel.Bind(x => x.User, x =>
            {
                var name = x.FirstName + " " + x.LastName;
                HeaderView.SubText = string.IsNullOrWhiteSpace(name) ? x.Username : name;
                HeaderView.SetImage(new Avatar(x.Avatar).ToUrl(128), Images.Avatar);
                RefreshHeaderView();

                var followers = new StyledStringElement("Followers", () => ViewModel.GoToFollowersCommand.Execute(null), Images.Heart);
                var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.Execute(null), Images.Event);
                var organizations = new StyledStringElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), Images.Group);
                var repos = new StyledStringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.Execute(null), Images.Repo);
                var members = new StyledStringElement("Members", () => ViewModel.GoToMembersCommand.Execute(null), Images.Team);
                var midSec = new Section(new UIView(new CGRect(0, 0, 0, 20f))) { events, organizations, members, followers };
                Root = new RootElement(Title) { midSec, new Section { repos } };
            });
//          if (!ViewModel.IsLoggedInUser)
//              NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu());
        }
Example #26
0
 public void RegisterDot(Section sc, int damage)
 {
     if(dotRegistry.ContainsKey(sc)) {
         dotRegistry.Remove(sc);
     }
     dotRegistry.Add(sc, new Dot(DOT_DURATION, damage/DOT_DURATION));
 }
Example #27
0
        public void TestJsonProperty()
        {
            // Arrange
             var section = new Section
             {
                 TypeName = typeof (SimpleSection).AssemblyQualifiedName
             };
             section.Parameters.Add("Complex", new Parameter
             {
                 Name = "Complex",
                 Translator = "Json",
                 TypeName = typeof(ComplexProperty).AssemblyQualifiedName,
                 Values = new List<ParameterValue>
                 {
                     new ParameterValue
                     {
                         Value = "{ \"Name\": \"Test\", \"Valid\": true }"
                     }
                 }
             });

             // Act
             var service = Configure.With(settings => settings.AddJsonTranslator().AddSection(section));
             var result = service.GetSection<SimpleSection>();

             // Assert
             Assert.IsNotNull(result);
             Assert.IsNotNull(result.Complex);
             Assert.AreEqual("Test", result.Complex.Name);
        }
Example #28
0
 public void RemoveDot(Section sc)
 {
     if(dotRegistry.ContainsKey(sc)) {
         dotRegistry.Remove(sc);
         sc.DotFinished();
     }
 }
Example #29
0
    //
    public void AgreeToTeach(Section s)
    {
        Teaches.Add(s);

        // We need to link this bidirectionally.
        s.Instructor = this;
    }
Example #30
0
 public override void ApplyDamage(Section s, int power)
 {
     CombatLog.addLine("CRIT STRIKE!");
     base.ApplyDamage (s, power + power * critStrikeBonusPercentage / 100);
     s.attributes.material.SetSectionEffect(new DefaultSectionEffect(appliedSection));
     Destruct();		//Destroy this effect - One time use... unless we want it destroyed at the end of the turn...
 }