Esempio n. 1
0
        /// <summary>
        /// Deletes the specified id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public void Delete(Guid id)
        {
            var repository = new ObjectRepository<Speaker>();
              repository.DeleteBy(id);

              RedirectToAction("Index");
        }
        protected override void Given()
        {
            var guid = Guid.NewGuid();
             	        _initialPerson = new Person
                          {
                              Age = 19,
                              Name = "Hugo"
                          };

            var memoryDb = new ObjectRepository();
            var cloner = new JsonCloner(memoryDb);

            cloner.Save(_initialPerson, guid);
            _clonedObject = cloner.Load<Person>(guid);
        }
Esempio n. 3
0
        public PdfDocument()
        {
            m_Fonts = new List<PdfFont>();
              m_Meta = new PdfMeta();
              m_Info = new PdfInfo();
              m_OutLines = new PdfOutlines();
              m_Root = new PdfRoot();
              m_PageTree = new PdfPageTree();
              m_Trailer = new PdfTrailer();
              m_ObjectRepository = new ObjectRepository();
              m_ResourceRepository = new ResourceRepository();

              m_Root.Info = m_Info;
              m_Root.Outlines = m_OutLines;
              m_Root.PageTree = m_PageTree;
              m_Trailer.Root = m_Root;

              m_PageSize = PdfPageSize.Default();
        }
Esempio n. 4
0
        public ActionResult Create(Speaker model)
        {
            try
              {
            var repository = new ObjectRepository<Speaker>();
            if (0 < (repository.Find(s => s.Name == model.Name)).Count())
            {
              throw new WebException("The speaker already exists.");
            }
            model.Id = Guid.NewGuid();
            repository.Save(model);

            return RedirectToAction("Index");
              }
              catch
              {
            return View();
              }
        }
Esempio n. 5
0
 /// <summary>
 /// Returns true if <paramref name="b"/> is of same type as the <see cref="YamlNode"/> and
 /// its Tag is same as the node. It returns true for <paramref name="skip"/> if they
 /// both already appeared in the node trees and were compared.
 /// </summary>
 /// <param name="b">Node to be compared.</param>
 /// <param name="repository">Node repository holds the nodes that already appeared and 
 /// the corresponding node in the other node tree.</param>
 /// <param name="skip">true if they already appeared in the node tree and were compared.</param>
 /// <returns>true if they are equal to each other.</returns>
 internal bool EqualsSub(YamlNode b, ObjectRepository repository, out bool skip)
 {
     YamlNode a = this;
     bool identity;
     if ( repository.AlreadyAppeared(a, b, out identity) ) {
         skip = true;
         return identity;
     }
     skip = false;
     if ( a.GetType() != b.GetType() || a.Tag != b.Tag )
         return false;
     return true;
 }
Esempio n. 6
0
 /// <summary>
 /// Returns true if <paramref name="b"/> is of same type as the <see cref="YamlNode"/> and
 /// its content is also logically same.
 /// </summary>
 /// <param name="b">Node to be compared.</param>
 /// <param name="repository">Node repository holds the nodes that already appeared and 
 /// the corresponding node in the other node tree.</param>
 /// <returns>true if they are equal to each other.</returns>
 internal abstract bool Equals(YamlNode b, ObjectRepository repository);
Esempio n. 7
0
 /// <summary>
 /// Returns true if <paramref name="obj"/> is of same type as the <see cref="YamlNode"/> and
 /// its content is also logically same.
 /// </summary>
 /// <remarks>
 /// Two <see cref="YamlNode"/>'s are logically equal when the <see cref="YamlNode"/> and its child nodes
 /// have the same contents (<see cref="YamlNode.Tag"/> and <see cref="YamlScalar.Value"/>) 
 /// and their node graph topology is exactly same as the other.
 /// </remarks>
 /// <example>
 /// <code>
 /// var a1 = new YamlNode("a");
 /// var a2 = new YamlNode("a");
 /// var a3 = new YamlNode("!char", "a");
 /// var b  = new YamlNode("b");
 /// 
 /// Assert.IsTrue(a1 != a2);        // different objects
 /// Assert.IsTrue(a1.Equals(a2));   // different objects having same content
 /// 
 /// Assert.IsFalse(a1.Equals(a3));  // Tag is different
 /// Assert.IsFalse(a1.Equals(b));   // Value is different
 /// 
 /// var s1 = new YamlMapping(a1, new YamlSequence(a1, a2));
 /// var s2 = new YamlMapping(a1, new YamlSequence(a2, a1));
 /// var s3 = new YamlMapping(a2, new YamlSequence(a1, a2));
 /// 
 /// Assert.IsFalse(s1.Equals(s2)); // node graph topology is different
 /// Assert.IsFalse(s1.Equals(s3)); // node graph topology is different
 /// Assert.IsTrue(s2.Equals(s3));  // different objects having same content and node graph topology
 /// </code>
 /// </example>
 /// <param name="obj">Object to be compared.</param>
 /// <returns>True if the <see cref="YamlNode"/> logically equals to the <paramref name="obj"/>; otherwise false.</returns>
 public override bool Equals(object obj)
 {
     if ( obj == null || !( obj is YamlNode ) )
         return false;
     var repository = new ObjectRepository();
     return Equals((YamlNode)obj, repository);
 }
 internal override bool Equals(YamlNode b, ObjectRepository repository)
 {
     bool skip;
     if(! base.EqualsSub(b, repository, out skip) )
         return false;
     if(skip)
         return true;
     YamlScalar aa = this;
     YamlScalar bb = (YamlScalar)b;
     if ( NativeObjectAvailable ) {
         return bb.NativeObjectAvailable &&
                (aa.NativeObject == null ?
                                             bb.NativeObject==null :
                                                                       aa.NativeObject.Equals(bb.NativeObject) );
     } else {
         if ( ShorthandTag() == "!!str" ) {
             return aa.Value == bb.Value;
         } else {
             // Node with non standard tag is compared by its identity.
             return false;
         }
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Edits the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public ActionResult Edit(Guid id)
 {
     var repository = new ObjectRepository<Speaker>();
       var model = repository.Find(s => s.Id == id);
       return View(model);
 }
Esempio n. 10
0
 /// <summary>
 /// Detailses the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public ActionResult Details(Guid id)
 {
     var repository = new ObjectRepository<Speaker>();
       var model = repository.Find(m => m.Id == id).First();
       return View(model);
 }
Esempio n. 11
0
 /// <summary>
 /// Indexes this instance.
 /// </summary>
 /// <returns></returns>
 public ActionResult Index()
 {
     var repository = new ObjectRepository<Speaker>();
       var model = repository.GetAll();
       return View(model);
 }
Esempio n. 12
0
        public ActionResult Edit(Guid id, Speaker speaker)
        {
            try
              {
            var repository = new ObjectRepository<Speaker>();
            repository.Save(speaker);

            return RedirectToAction("Index");
              }
              catch
              {
            return View();
              }
        }
Esempio n. 13
0
 public MoneyColumnMetadataJsModel(ObjectRepository repository, MoneyColumnMetadataModel model)
 {
     _repository = repository;
     _model      = model;
 }
Esempio n. 14
0
 public static Mock <ISubtextContext> SetupRepository(this Mock <ISubtextContext> context,
                                                      ObjectRepository repository)
 {
     context.Setup(c => c.Repository).Returns(repository);
     return(context);
 }