Example #1
0
        public void GetHandler5_ForDerivedType()
        {
            var data = new DataB() as DataBase;


            /**
             * hier wird der Rückgabewert explizit angegeben.
             * Da ein IHandler'DataB nicht in ein IHandler'DataBase umgewandelt werden kann, (Kontravarianz)
             * kann die Methode kein Objekt vom Typ IHandler'DataBase zurückgeben.
             *
             * Der Rückgabewert liegt im GetHandler2 implizit vor.
             * var data = new DataB() as DataBase;
             * var handler = _repo.GetHandlerForType_2(data);
             *
             * ist gleichbedeutend zu
             * var data = new DataB() as DataBase;
             * IHandler<DataBase> handler = _repo.GetHandlerForType_2<DataBase>(data);
             * Die Methode muss also ein IHandler<DataBase> zurück geben, was nicht möglich ist,
             * da ein IHandler<DataB> konkreter ist als IHandler<DataBase> aber die Implementierung den konkreten Typ
             * DataB benötigt. Ansonsten könnte man die DoSomething()-Signatur auch in DoSomething(DataBase db) ändern.
             *
             *
             * Als Eingabeparameter ist ein DataBase erlaubt.
             */
            IHandler <DataB> handler = _repo.GetHandlerForType_5 <IHandler <DataB>, DataB>(data);


            Assert.IsNotNull(handler);
        }
Example #2
0
        public void GetHandler1_ForConcreteType()
        {
            var data    = new DataB();
            var handler = _repo.GetHandlerForType_1(data);

            Assert.IsNotNull(handler);
        }
Example #3
0
        public void GetHandler3_ForDerivedType()   // DAS funktioniert
        {
            var     data    = new DataB() as DataBase;
            dynamic handler = _repo.GetHandlerForType_3(data);

            Assert.IsNotNull((object)handler);
        }
Example #4
0
        public void GetHandler4_ForConcreteType()
        {
            var    data    = new DataB();
            object handler = _repo.GetHandlerForType_4(data);

            Assert.IsNotNull(handler);
        }
Example #5
0
        public void GetHandler5_ForConcreteType()
        {
            var data = new DataB();
            IHandler <DataB> handler = _repo.GetHandlerForType_5 <IHandler <DataB>, DataB>(data);

            Assert.IsNotNull(handler);
        }
Example #6
0
        public void GetHandler4_ForDerivedType()
        {
            var    data    = new DataB() as DataBase;
            object handler = _repo.GetHandlerForType_4(data);

            Assert.IsNotNull(handler);
        }
Example #7
0
        /// <summary>
        /// 데이터 비트를 인덱스 번호로 변환
        /// </summary>
        /// <param name="eDataB">데이터 비트</param>
        /// <returns>인덱스</returns>
        public static DataB DataBitToIndex(DataB eDataB)
        {
            DataB eIdx = DataB.IdxData8;

            switch (eDataB)
            {
            case DataB.Data5:
                eIdx = DataB.IdxData5;
                break;

            case DataB.Data6:
                eIdx = DataB.IdxData6;
                break;

            case DataB.Data7:
                eIdx = DataB.IdxData7;
                break;

            case DataB.Data8:
                eIdx = DataB.IdxData8;
                break;
            }

            return(eIdx);
        }
Example #8
0
    /// <summary>
    /// heap y stack
    /// Garbage collector -> Daemon
    /// </summary>
    // Start is called before the first frame update
    void Start()
    {
        //Debug.Log(characterData.level);

        //Debug.Log(characterObject.level);

        FDataA dataA;

        dataA.X = 1;
        Debug.Log(dataA.X);
        FDataA dataAClon;

        dataAClon = dataA;
        dataA.X   = 2;
        Debug.Log(dataA.X);
        Debug.Log(dataAClon.X);

        DataB dataB = new DataB();

        dataB.X = 1;
        Debug.Log(dataB.X);
        DataB dataBClon = dataB;

        dataB.X = 2;

        Debug.Log(dataB.X);
        Debug.Log(dataBClon.X);
    }
Example #9
0
        /// <summary>
        /// 인덱스 번호를 데이터 비트로 변환
        /// </summary>
        /// <param name="nIdx">인덱스</param>
        /// <returns>데이터 비트</returns>
        public static DataB IndexToDataBit(int nIdx)
        {
            DataB dataB = DataB.Data8;

            switch (nIdx)
            {
            case (int)DataB.IdxData5:
                dataB = DataB.Data5;
                break;

            case (int)DataB.IdxData6:
                dataB = DataB.Data6;
                break;

            case (int)DataB.IdxData7:
                dataB = DataB.Data7;
                break;

            case (int)DataB.IdxData8:
                dataB = DataB.Data8;
                break;
            }

            return(dataB);
        }
Example #10
0
        public void GetHandler2_ForDerivedType()
        {
            var data = new DataB() as DataBase;
            IHandler <DataBase> handler = _repo.GetHandlerForType_2 <DataBase>(data);

            Assert.IsNotNull(handler);
        }
Example #11
0
        public void GetHandler3_ForConcreteType()   // DAS funktioniert
        {
            var data    = new DataB();
            var handler = _repo.GetHandlerForType_3(data);

            Assert.IsNotNull((object)handler);
        }
Example #12
0
        public void GetHandler1_ForDerivedType()
        {
            var data    = new DataB() as DataBase;
            var handler = _repo.GetHandlerForType_1(data);

            Assert.IsNotNull(handler);
            handler.DoSomething(data);
        }
Example #13
0
 private async void ReloadData(object o, string f)
 {
     if (f.ToLower().Contains("scrivener.sqlite"))
     {
         log.Debug("{0} requested db reload.", o.ToString());
         await DataB.LoadAll();
     }
 }
Example #14
0
        public void GetHandler4_ForConcreteType()
        {
            var    data    = new DataB();
            object handler = _repo.GetHandlerForType_4(data);

            Assert.IsNotNull(handler);
            //handler.DoSomething(data);    GEHT NICHT !
        }
Example #15
0
        public void GetHandler2_ForConcreteType()   // DAS funktioniert
        {
            var data    = new DataB();
            var handler = _repo.GetHandlerForType_2(data);

            Assert.IsNotNull(handler);
            handler.DoSomething(data);
        }
Example #16
0
        public ActionResult EditPage(PageViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (DataB db = new DataB())
            {
                //Get page id
                int id = model.Id;

                //initialize
                string slug = "home";

                //get the page
                PageDtO dto = db.pages.Find(id);

                //dto the title
                dto.Title = model.Title;

                //check for slug and set it if need be
                if (model.Slug != "home")
                {
                    if (string.IsNullOrWhiteSpace(model.Slug))
                    {
                        slug = model.Title.Replace(" ", "-").ToLower();
                    }
                    else
                    {
                        slug = model.Slug.Replace(" ", "-").ToLower();
                    }
                }

                //Make sure title and slug are unique
                //x => x.Id != id is more or less equivalent to
                //SomeFunction (x) { return x.Id != id; }
                if (db.pages.Where(x => x.Id != id).Any(x => x.Title == model.Title) ||
                    db.pages.Where(x => x.Id != id).Any(x => x.Slug == slug))
                {
                    ModelState.AddModelError("", "That title or slug already exists.");
                    return(View(model));
                }

                //DTO the slug body and sidebar
                dto.Slug       = slug;
                dto.Body       = model.Body;
                dto.HasSideBar = model.HasSideBar;

                //Save
                db.SaveChanges();
            }

            TempData["SM"] = "You have edited the page!";

            //redirect
            return(RedirectToAction("EditPage"));
        }
Example #17
0
 /// <summary>
 /// Moves rows from view A to B
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void MoveSelectedFromViewAToB_Click(object sender, EventArgs e)
 {
     if (ViewA.SelectedRows.Count == 0 || DataA.Rows.Count == 0)
     {
         return;                                                            //No row selected, or data table is empty
     }
     DataB.ImportRow(DataA.Rows[ViewA.SelectedRows[0].Index]);
     DataA.Rows.RemoveAt(ViewA.SelectedRows[0].Index);
 }
Example #18
0
 /// <exception cref="System.Exception"></exception>
 protected override void Store()
 {
     var objectA = new DataA();
     var objectB = new DataB();
     objectA._val = objectB;
     objectB._val = objectA;
     Store(objectB);
     // just to show that the descend to "_val" actually is
     // recognized - this one doesn't show up in the result
     Store(new DataC());
 }
Example #19
0
        // GET: Admin/Pages
        public ActionResult Index()
        {
            List <PageViewModel> ListofPages;

            using (DataB db = new DataB())
            {
                //initialize the list
                ListofPages = db.pages.ToArray().OrderBy(x => x.Sort).Select(x => new PageViewModel(x)).ToList();
            }
            return(View(ListofPages));
        }
Example #20
0
        /// <exception cref="System.Exception"></exception>
        protected override void Store()
        {
            var objectA = new DataA();
            var objectB = new DataB();

            objectA._val = objectB;
            objectB._val = objectA;
            Store(objectB);
            // just to show that the descend to "_val" actually is
            // recognized - this one doesn't show up in the result
            Store(new DataC());
        }
Example #21
0
        public ActionResult EditSideBar()
        {
            SideBarViewModel model;

            using (DataB db = new DataB())
            {
                SideBarDtO dto = db.sidebar.Find(1);

                model = new SideBarViewModel(dto);
            }
            return(View(model));
        }
Example #22
0
        public ActionResult AddPage(PageViewModel model)
        {
            //check model state
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (DataB db = new DataB())
            {
                //declare the slug
                string slug;

                //init page DtO
                PageDtO dto = new PageDtO();

                //DtO Title
                dto.Title = model.Title;

                //Check for and set slug if need be
                if (string.IsNullOrWhiteSpace(model.Slug))
                {
                    slug = model.Title.Replace(" ", "-").ToLower();
                }
                else
                {
                    slug = model.Slug.Replace(" ", "-").ToLower();
                }

                //Make sure title and slug are unique on /Admin/Pages/AddPage
                //notice a a model is returned in View()
                //thus the fields will remain filled out
                if (db.pages.Any(x => x.Title == model.Title) || db.pages.Any(x => x.Slug == slug))
                {
                    ModelState.AddModelError("", "That title or slug already exists.");
                    return(View(model));
                }

                //Save DtO
                db.pages.Add(dto);
                db.SaveChanges();
            }

            //tempdata persists after redirection and viewback
            TempData["SM"] = "Successfully added a new page!!!";


            //Redirect
            return(RedirectToAction("AddPage"));
        }
Example #23
0
        public ActionResult EditSideBar(SideBarViewModel model)
        {
            using (DataB db = new DataB())
            {
                SideBarDtO dto = db.sidebar.Find(1);

                dto.Body = model.Body;

                db.SaveChanges();
            }

            TempData["SM"] = "You made a successful edit to the sidebar!!!";

            return(RedirectToAction("EditSidebar"));
        }
Example #24
0
        private void Calculate()
        {
            if (DiffValueTextBlock == null)
            {
                return;
            }
            DiffValueStatus = DataB > DataA ? CompareValueType.Up : DataB < DataA ? CompareValueType.Down : CompareValueType.NoChange;

            double c = DataB - DataA;

            if (c != 0)
            {
                DiffValue = Math.Round(c / DataA * 100, 1);
                if (DataA == 0)
                {
                    DiffValue = 100;
                }
            }

            switch (DiffValueStatus)
            {
            case CompareValueType.Up:
                DiffValueTextBlock.Foreground = UPColor;
                break;

            case CompareValueType.Down:
                DiffValueTextBlock.Foreground = DownColor;
                break;

            case CompareValueType.NoChange:
                DiffValueTextBlock.Foreground = NoChangeColor;
                break;
            }
            string popupText = PopupText;

            popupText = popupText.Replace("{a}", $"{DataA.ToString()}");
            popupText = popupText.Replace("{b}", $"{DataB.ToString()}");

            string diffvalueText = DiffValue > 0 ? $"+{DiffValue.ToString()}%" : DiffValue == 0 ? $"{Application.Current.Resources["Lang_Nochange"]}" : $"{DiffValue.ToString()}%";

            if (DataA == DataB)
            {
                diffvalueText = $"{Application.Current.Resources["Lang_Nochange"]}";
            }
            popupText           = popupText.Replace("{diffvalue}", diffvalueText);
            PopupTextBlock.Text = popupText;
        }
	public static int Main ()
	{
		DataA[] d1 = new DataA[] { new DataA () { Key = 1, Text = "Foo" }};
		DataB[] d2 = new DataB[] { new DataB () { Key = 2, Value = "Second" }};
		
		var e = from a in d1
			join b in d2 on a.Key equals b.Key into ab
			from x in ab.DefaultIfEmpty ()
			select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };

		var res = e.ToList ();
		if (res.Count != 1)
			return 1;
		
		if (res [0].a != "<empty>")
			return 2;
			
		if (res [0].b != "Foo")
			return 3;
			
		// Explicitly typed
		e = from a in d1
			join DataB b in d2 on a.Key equals b.Key into ab
			from x in ab.DefaultIfEmpty ()
			select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };
			
		foreach (var o in e)
			Console.WriteLine (o);
			
		res = e.ToList ();
		if (res.Count != 1)
			return 10;
		
		if (res [0].a != "<empty>")
			return 11;
			
		if (res [0].b != "Foo")
			return 12;
			
		// FIXME: Used same name
		//var e2 = from a in d1
		//	join a in d2 on a.Key equals a.Key into ab
		//	select a;
		
		Console.WriteLine ("OK");
		return 0;
	}
Example #26
0
        //GET: Admin/Pages/DeletePage/id
        public ActionResult DeletePage(int id)
        {
            using (DataB db = new DataB())
            {
                //Get page
                PageDtO dto = db.pages.Find(id);

                //Remove page
                db.pages.Remove(dto);

                //Save
                db.SaveChanges();

                //redirect
                return(RedirectToAction("Index"));
            }
        }
Example #27
0
        //GET: Admin/Pages/PageDetails/id
        public ActionResult PageDetails(int id)
        {
            PageViewModel model;

            using (DataB db = new DataB())
            {
                //Get the page
                PageDtO dto = db.pages.Find(id);

                //confirm page exists
                if (dto == null)
                {
                    return(Content("The Page doesn't exist!!!"));
                }

                //initialize the pageviewmodel by 1 parameter constructor
                model = new PageViewModel(dto);
            }

            return(View(model));
        }
Example #28
0
        public void ReorderPages(int[] id)
        {
            using (DataB db = new DataB())
            {
                //Set initial count
                int count = 1;

                //Declare PageDtO
                PageDtO dto;

                //Set sorting for each page
                foreach (var pageId in id)
                {
                    dto      = db.pages.Find(pageId);
                    dto.Sort = count;

                    db.SaveChanges();

                    count++;
                }
            }
        }
Example #29
0
        public ActionResult EditPage(int id)
        {
            PageViewModel model;

            using (DataB db = new DataB())
            {
                //Get the page
                PageDtO dto = db.pages.Find(id);

                //confirm that the page exists
                if (dto == null)
                {
                    return(Content("The page does not exist"));
                }

                //no need to initialize all fields because
                //of the handy 1 parameter constructor in the
                //PageViewModel Class!
                model = new PageViewModel(dto);
            }

            return(View(model));
        }
Example #30
0
        protected override Result DoFlush()
        {
            Result rc = BitmapStorage.Flush();

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = DataA.Flush();
            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = DataB.Flush();
            if (rc.IsFailure())
            {
                return(rc);
            }

            return(Result.Success);
        }
Example #31
0
 /// <summary>
 /// 是否包含键值B,且B集合中也包含A
 /// </summary>
 /// <param name="keyA"></param>
 /// <param name="keyB"></param>
 /// <returns></returns>
 public bool ContainsKeyBA(TKeyB keyB, TKeyA keyA)
 {
     return(DataB.ContainsKey(keyB) && DataB[keyB].ContainsKey(keyA));;
 }
Example #32
0
 public void InitMethod()
 {
     DataB.Drop();
 }