Exemplo n.º 1
0
        public void AnCorrectInput()
        {
            var header = new HeaderContent().Match("Accept: asd");

            Assert.True(header.IsSuccesful());
            Assert.Equal(" asd", header.RemainingText());
        }
Exemplo n.º 2
0
        public static int AddItem(TestItem aTestItem, HeaderContent aHeaderContent, string aHeaderPath)
        {
            var nameToID            = aHeaderContent.NameToID;
            var sortedHeaderResults = aHeaderContent.SortedHeaderResults;

            var normalizedID = IDNormalizer.CopyNormalizeHexaID(aTestItem.ID);

            // Check Name Unique
            if (nameToID.ContainsKey(aTestItem.Name))
            {
                return(Constants.kDuplicateID);
            }

            // Check ID Unique
            var insertedItem = new HeaderItem {
                ID = normalizedID, Name = aTestItem.Name
            };

            var foundIndex = aHeaderContent.GetPosition(insertedItem.ID, aHeaderPath);

            if (foundIndex == Constants.kDuplicateID)
            {
                return(foundIndex);
            }

            sortedHeaderResults[aHeaderPath].Insert(foundIndex, insertedItem);
            nameToID[aTestItem.Name] = normalizedID;

            return(foundIndex);
        }
Exemplo n.º 3
0
        public void WriteRead()
        {
            var ci = Repository.Instance.New <ContentItem>();

            Assert.AreEqual(ci.Id, Guid.Empty, "Content item id not initialised to empty guid");

            var hc = new HeaderContent();

            hc.Title      = "Header A";
            hc.Image.Url  = "/abc.gif";
            hc.HeaderBody = "xyz";
            ci.SetContent(hc);
            ci.Path = "rt-a";
            Assert.AreEqual(ci.Title, "Header A", "Title not built on SetContent");
            Assert.AreEqual(((HeaderSummary)ci.GetSummary()).Image.Url, "/abc.gif", "Summary not built on SetContent");

            Repository.Instance.Set(ci);

            var cont = Repository.Instance.GetByPath(typeof(HeaderContent), new List <string> {
                "rt-a"
            }).FirstOrDefault();

            Assert.IsNotNull(cont, "Get by path");

            var itemId = new ItemId(cont);
            var cont2  = Repository.Instance.Get <ContentItem>(new ItemId[] { itemId }).FirstOrDefault();

            Assert.IsNotNull(cont2, "Get by Id");
            Assert.AreEqual(cont2.Id, cont.Id, "Get right item by Id");
        }
Exemplo n.º 4
0
        public void InputWithMiddleLine()
        {
            var header = new HeaderContent().Match("Accept-Language:");

            Assert.True(header.IsSuccesful());
            Assert.Equal("", header.RemainingText());
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            HeaderContent headerContent = db.HeaderContents.Find(id);

            db.HeaderContents.Remove(headerContent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Id,Photo,NavItem")] HeaderContent headerContent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(headerContent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(headerContent));
 }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "Id,Photo,NavItem")] HeaderContent headerContent)
        {
            if (ModelState.IsValid)
            {
                db.HeaderContents.Add(headerContent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(headerContent));
        }
Exemplo n.º 8
0
 public LayoutDto BuildDto()
 {
     return(new LayoutDto(
                Title?.Trim() ?? string.Empty,
                Description?.Trim() ?? string.Empty,
                Uri?.Trim() ?? string.Empty,
                Author?.Trim() ?? string.Empty,
                Language?.Trim() ?? string.Empty,
                GoogleTagsCode?.Trim() ?? string.Empty,
                HeaderContent?.Trim() ?? string.Empty,
                FooterContent?.Trim() ?? string.Empty));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Automatically loads the data from the RC file
        /// </summary>
        /// <param name="aRcFile"></param>
        /// <param name="aShowGhostFile"></param>
        public StringResourceContext(RcFile aRcFile, bool aShowGhostFile)
        {
            RcFile         = aRcFile;
            mShowGhostFile = aShowGhostFile;

            var rcFilePath = RcFile.FilePath;

            mCodePage = CodePageExtractor.GetCodePage(rcFilePath);

            mHeaderContentBuilder = new HeaderContentBuilder(rcFilePath, mCodePage);
            mHeaderContentBuilder.Build();
            mHeaderContent = mHeaderContentBuilder.GetResult();

            HeaderContent = mHeaderContent;

            mRCFileContentBuilder = new RCFileContentBuilder(rcFilePath, mCodePage, mHeaderContent);
            mRCFileContentBuilder.Build();
            mRCFileContent = mRCFileContentBuilder.GetResult();

            mWriteRCPath  = Path.GetTempFileName();
            mRCFileWriter = new RCFileWriter(mRCFileContent, rcFilePath, mShowGhostFile);

            var headerNames = HeaderNamesExtractor.ExtractHeaderNames(RcFile.FilePath, mCodePage);

            if (!headerNames.Any())
            {
                return;
            }

            var rcFileDirectory = Path.GetDirectoryName(RcFile.FilePath);
            var headerPath      = Path.Combine(rcFileDirectory, headerNames.FirstOrDefault(headerName => headerName.ToLower().Equals("resource.h") &&
                                                                                           File.Exists(Path.Combine(rcFileDirectory, headerName)))
                                               ?? headerNames.FirstOrDefault(
                                                   headerName => headerName.ToLower().Contains("resource") &&
                                                   File.Exists(Path.Combine(rcFileDirectory, headerName))
                                                   ) ?? headerNames.FirstOrDefault(
                                                   headerName => File.Exists(Path.Combine(rcFileDirectory, headerName))
                                                   ) ?? headerNames.First());

            if (!File.Exists(headerPath))
            {
                File.Create(headerPath);
            }
            DefaultHeaderFile = headerPath;

            mIDGenerator = new IDGenerator();
            mIDGenerator.RemoveExistingFromHeader(mHeaderContent, headerPath);

            mWriteHeaderPath = Path.GetTempFileName();
            mHeaderWriter    = new HeaderWriter(headerPath);
        }
Exemplo n.º 10
0
        // GET: Admin/HeaderContent/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HeaderContent headerContent = db.HeaderContents.Find(id);

            if (headerContent == null)
            {
                return(HttpNotFound());
            }
            return(View(headerContent));
        }
Exemplo n.º 11
0
 public ProxyClient(IClientLink link)
     : base(link)
 {
     HeaderContent.Add(@" _   _               _                    _____           _   ");
     HeaderContent.Add(@"| \ | | _   _   ___ | |  ___   __ _  _ __|_   _|___  ___ | |_ ");
     HeaderContent.Add(@"|  \| || | | | / __|| | / _ \ / _` || '__| | | / _ \/ __|| __|");
     HeaderContent.Add(@"| |\  || |_| || (__ | ||  __/| (_| || | _  | ||  __/\__ \| |_ ");
     HeaderContent.Add(@"|_| \_| \__,_| \___||_| \___| \__,_||_|(_) |_| \___||___/ \__|");
     HeaderContent.Add(@" ____                                                         ");
     HeaderContent.Add(@"|  _ \  _ __  ___ __  __ _   _                                ");
     HeaderContent.Add(@"| |_) || '__|/ _ \\ \/ /| | | |                               ");
     HeaderContent.Add(@"|  __/ | |  | (_) |>  < | |_| |                               ");
     HeaderContent.Add(@"|_|    |_|   \___//_/\_\ \__, |                               ");
     HeaderContent.Add(@"                         |___/                                ");
 }
Exemplo n.º 12
0
        internal WorkerClient(IClientLink link)
            : base(link)
        {
            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            HeaderContent.Add(@" _   _               _                    _____           _   ");
            HeaderContent.Add(@"| \ | | _   _   ___ | |  ___   __ _  _ __|_   _|___  ___ | |_ ");
            HeaderContent.Add(@"|  \| || | | | / __|| | / _ \ / _` || '__| | | / _ \/ __|| __|");
            HeaderContent.Add(@"| |\  || |_| || (__ | ||  __/| (_| || | _  | ||  __/\__ \| |_ ");
            HeaderContent.Add(@"|_| \_| \__,_| \___||_| \___| \__,_||_|(_) |_| \___||___/ \__|");
            HeaderContent.Add(@"__        __            _                                     ");
            HeaderContent.Add(@"\ \      / /___   _ __ | | __ ___  _ __                       ");
            HeaderContent.Add(@" \ \ /\ / // _ \ | '__|| |/ // _ \| '__|                      ");
            HeaderContent.Add(@"  \ V  V /| (_) || |   |   <|  __/| |                         ");
            HeaderContent.Add(@"   \_/\_/  \___/ |_|   |_|\_\\___||_|                         ");
            HeaderContent.Add(@"                                                              ");
        }
Exemplo n.º 13
0
        public static void EditValue(string aCurrentName, string aNewValue,
                                     RCFileContent aRCFileContent, HeaderContent aHeaderContent)
        {
            if (!aHeaderContent.NameToID.ContainsKey(aCurrentName))
            {
                return;
            }

            var stringTableContent         = aRCFileContent.StringTableContent;
            var stringTableDeterminedIndex = StringTableIndexCalculator.CalculateIndex(aHeaderContent.NameToID[aCurrentName]);

            foreach (var rcItem in stringTableContent[stringTableDeterminedIndex])
            {
                if (rcItem.Name == aCurrentName)
                {
                    rcItem.Value = aNewValue;
                    return;
                }
            }
        }
Exemplo n.º 14
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            PaneToggleButtonGrid     = (WGrid)GetTemplateChild("PaneToggleButtonGrid");
            ContentTopPadding        = (WGrid)GetTemplateChild("ContentTopPadding");
            HeaderContent            = (ContentControl)GetTemplateChild("HeaderContent");
            NavigationViewBackButton = (Button)GetTemplateChild("NavigationViewBackButton");

            // HeaderContent is set to a MinHeight of 48 so we have to collapse it if we
            // don't want it to take up any space
            HeaderContent.Visibility = _windowHeader.Visibility;

            // Read comment on MarginPropertyChanged
            var currentMargin = HeaderContent.Margin;

            HeaderContentMargin = new WThickness(
                0,
                0,
                currentMargin.Right,
                currentMargin.Bottom);

            HeaderContent.Margin = HeaderContentMargin.Value;
            HeaderContent.RegisterPropertyChangedCallback(ContentControl.MarginProperty, MarginPropertyChanged);
        }
Exemplo n.º 15
0
        public override bool Equals(object obj)
        {
            Group <T> that = obj as Group <T>;

            return((that != null) && (HeaderContent.Equals(that.HeaderContent)));
        }
Exemplo n.º 16
0
        private void InitialiseControls()
        {
            //<div class="dialog">
            //    <div class="content">
            //        <div class="t">
            //        </div>
            //        <div class="hd">
            //        </div>
            //        <div class="bd">
            //            </div>
            //    </div>
            //    <div class="b">
            //      <div></div>
            //    </div>
            //</div>
            this.Controls.Clear();

            HtmlGenericControl divDialog = new HtmlGenericControl("div");

            divDialog.ID = "_divDialog";
            divDialog.Attributes.Add("class", "dialog");
            this.Controls.Add(divDialog);


            HtmlGenericControl divContent = new HtmlGenericControl("div");

            divContent.ID          = "_divContent";
            divContent.Style.Value = "background:transparent url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "ControlsAjaxNotti.WindowStatic.dialog2-blue-800x1600.png") + ") no-repeat right top";
            divContent.Attributes.Add("class", "content");
            divDialog.Controls.Add(divContent);



            HtmlGenericControl divt = new HtmlGenericControl("div");

            divt.ID          = "_divt";
            divt.Style.Value = "background:transparent url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "ControlsAjaxNotti.WindowStatic.dialog2-blue-800x1600.png") + ") no-repeat top left";
            divt.Attributes.Add("class", "t");
            divContent.Controls.Add(divt);


            HtmlGenericControl divHeader = new HtmlGenericControl("div");

            divHeader.ID = "_divHeader";
            divHeader.Attributes.Add("class", "hd");
            divContent.Controls.Add(divHeader);


            HtmlGenericControl TituloHeader = new HtmlGenericControl("h2");

            TituloHeader.ID = "_TituloHeader";
            divHeader.Controls.Add(TituloHeader);



            HtmlGenericControl divBody = new HtmlGenericControl("div");

            divBody.ID = "_divBody";
            divBody.Attributes.Add("class", "bd");
            divContent.Controls.Add(divBody);


            HtmlGenericControl divb = new HtmlGenericControl("div");

            divb.ID          = "_divb";
            divb.Style.Value = "background :transparent url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "ControlsAjaxNotti.WindowStatic.dialog2-blue-800x1600.png") + ") no-repeat bottom right";
            divb.Attributes.Add("class", "b");
            divDialog.Controls.Add(divb);

            HtmlGenericControl divVacio = new HtmlGenericControl("div");

            divVacio.ID          = "_divVacio";
            divVacio.Style.Value = "background:transparent url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "ControlsAjaxNotti.WindowStatic.dialog2-blue-800x1600.png") + ") no-repeat bottom left";
            divVacio.InnerHtml   = "&nbsp;";
            divb.Controls.Add(divVacio);


            BodyContent.InstantiateIn(divBody);

            if (HeaderContent != null)
            {
                HeaderContent.InstantiateIn(TituloHeader);
            }
        }