Beispiel #1
0
        internal void Create(EMap m)
        {
            // Name ve Root bilgileri Before üzerinden yükleniyor.
            // Güncelleme bu bilgiler Instruction kısmı için düzenleniyor.
            // Kullandığımız entity'in Name ve Root bilgileri alınmalı.

            DEntity d = new DEntity();
            Envoy   e = new Envoy();

            d.TargetLocation = m.ExternalLocation;

            d = e.Before(new EMap(), d);
            e.CreateIfNotThere(d);
            UpdateList(d.TargetLocation);

            if (!IsThereAny(m.Entity))
            {
                if (l.Count > 0)
                {
                    m.Id = l[l.Count - 1].Id + 1;
                }
                else
                {
                    m.Id = 1;
                }

                DataAccess.Insert insert = new DataAccess.Insert
                                               (m, d);
            }
        }
        internal void Add(string ExternalLocation, string categoryName)
        {
            DEntity d = new DEntity();

            d.TargetLocation = ExternalLocation;
            d = e.Before(new ECategory(), d);
            e.CreateIfNotThere(d);
            UpdateList(ExternalLocation);

            if (!IsThereAny(categoryName))
            {
                ECategory c = new ECategory();
                c.Name = categoryName;
                if (s.Count > 0)
                {
                    c.Id = s[s.Count - 1].Id + 1;
                }
                else
                {
                    c.Id = 1;
                }
                DataAccess.Insert insert = new DataAccess.Insert
                                               (c, d);
            }
        }
        internal void Create(string ExternalLocation, Type t)
        {
            DEntity d = new DEntity();

            d.TargetLocation = ExternalLocation;
            //
            d = e.Before(new EStatus(), d);
            e.CreateIfNotThere(d);
            UpdateList(ExternalLocation);

            EStatus state = IsThereAny(t.Name);

            if (state is null)
            {
                EStatus status = new EStatus();
                status.Entity = t.Name;
                status.Recent = 0;
                if (s.Count > 0)
                {
                    status.Id = s[s.Count - 1].Id + 1;
                }
                else
                {
                    status.Id = 1;
                }

                DataAccess.Insert add = new DataAccess.Insert(status, d);
            }
        }
        public void Add(TEntity e)
        {
            if (WorkOnTheMap == true)
            {
                BringInstruction();
            }

            Envoy   envoy = new Envoy();
            DEntity d     = new DEntity();

            if (!(_categoryProperty is null))
            {
                d.CategorizeName = CategoryProperty;
            }

            d.Name           = SetName;
            d.Root           = SetRoot;
            d.TargetLocation = ExternalLocation;

            sa.Create(ExternalLocation, e.GetType());

            sa.UpdateList(ExternalLocation);

            EStatus st = sa.IsThereAny(e.GetType().Name);

            if (AutomaticIdOnAdd)
            {
                e.GetType().GetProperty(envoy.FindKey(e)).SetValue(e, st.Recent + 1);
            }

            bool IsAdded  = false;
            bool IsDefine = false;

            if (CheckBeforeAdding) // Eklemeden önce kategori kontrol etme durumu
            {
                ca.UpdateList(ExternalLocation);
                if (ca.IsThereAny(d.CategorizeName) == true)
                {
                    d = envoy.Before(e, d);
                    envoy.CreateIfNotThere(d);
                    envoy.DataInsert(e, d);

                    IsAdded  = true;
                    IsDefine = true;
                }
                else
                {
                    // Şarta bağlı kılınarak ekleme durumu tanımlanmış.
                    // Ancak hangi property üzerinden çalışılacağı söylenmediğinde,
                    // Ekleme yapılmaz. Çünkü seçenek açıktır ve durum verilmemiştir.
                }
            }
            else
            {
                d = envoy.Before(e, d);
                envoy.CreateIfNotThere(d);
                envoy.DataInsert(e, d);

                IsAdded  = true;
                IsDefine = true;
            }

            if (CategoryMapOption && IsDefine) // Haritaya kategorileri ekleyen kısım
            {
                if (!string.IsNullOrWhiteSpace(d.CategorizeName))
                {
                    ca.Add(ExternalLocation, d.CategorizeName);
                }
            }

            // Define hakkında;
            // CheckBeforeAdding açık olmasına rağmen, listede bulunamadığında, CategoryMapOption açık olduğunda
            // Yine de Map'e ekleme oluşuyor. Kısaca; CBE bloğunda ki else kısmı burayı etkilemiyor.
            // Bunu düzeltmek için,
            // Kontrol kapalıysa ve kontrol sonrasında kategori listede bulunmuşsa, map'e ekleme işlemi gerçekleşiyor.

            if (IsAdded && AutomaticIdOnAdd)
            {
                sa.Add(ExternalLocation, e.GetType());
            }
        }