示例#1
0
        static void Main(string[] args)
        {
            EnumSample enumsamp = new EnumSample();

            enumsamp.OdayaGirebilir(AuthTree.Mudur);
            enumsamp.OdayaGirebilir(AuthTree.Ogrenci);
            AuthTree ogretmenVeli = (AuthTree.Veli | AuthTree.Ogretmen);

            enumsamp.OdayaGirebilir(ogretmenVeli);
            enumsamp.OdayaGirebilir(AuthTree.Ogretmen);
            enumsamp.OdayaGirebilir(AuthTree.MudurYard);
            enumsamp.OdayaGirebilir(AuthTree.Veli | AuthTree.Ogrenci);
            enumsamp.OdayaGirebilir(AuthTree.Mudur | AuthTree.Ogretmen);

            int number  = 10;
            int number2 = number++;

            Console.WriteLine((number2));
            Console.WriteLine((number));
            Console.WriteLine((++number));
            Console.WriteLine((number));

            PartialSample1 prt = new PartialSample1();

            csharpbasics.A a1 = new A(5, 6);
            csharpbasics.A a2 = new A(5, 6);
            a1 += a2;
            csharpbasics.A a3 = a1 + a2;
            BoxingUnboxing.BoxandUnboxSample();
        }
示例#2
0
        public ItemData GetFullData(String id)
        {
            var user = _userSvc.CurrentUser();
            var cry  = (CryptoService)HttpContext.Current.Session["DATA"];

            var      item  = cry.FindById(id);
            AuthLeaf iteml = item as AuthLeaf;
            AuthTree itemt = item as AuthTree;

            if (iteml != null)
            {
                return(new ItemData
                {
                    ExpireTime = iteml.ExpireTime,
                    IsFolder = false,
                    Id = iteml.Id,
                    Notes = iteml.Notes,
                    Title = iteml.Title,
                    Url = iteml.Url,
                    UserName = iteml.UserName,
                    HasAttachment = iteml.HasAttachment
                });
            }
            else if (itemt != null)
            {
                return(new ItemData
                {
                    IsFolder = true,
                    Id = itemt.Id,
                    Title = itemt.Title
                });
            }
            return(null);
        }
示例#3
0
        public bool OdayaGirebilir(AuthTree at)
        {
            AuthTree icerilenYetki = at & girebilenler;
            bool     yetki         = icerilenYetki > 0? girebilenler.HasFlag(icerilenYetki):false;

            if (yetki)
            {
                Console.WriteLine(at.ToString() + " odaya girebilir");
            }
            else
            {
                Console.WriteLine(at.ToString() + " odaya giremez");
            }

            return(yetki);
        }
示例#4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            var sampleobj = Activator.CreateInstance("ReflectionSample",
                                                     "ReflectionSample.SampleClass").Unwrap();

            var methodreturn = sampleobj.GetType()?.GetMethod("GetProperty1")?.Invoke(sampleobj, null);

            sampleobj.GetType()?.GetProperty("property1")?.SetValue(sampleobj, "deneme");
            methodreturn = sampleobj.GetType()?.GetMethod("GetProperty1")?.Invoke(sampleobj, null);
            var refas = Assembly.Load("ReflectionSample").GetType("ReflectionSample.SampleClass");

            string location = typeof(EnumSample).Assembly.Location;
            var    obj      = Activator.CreateInstance("csharpbasicsstandart",
                                                       "csharpbasics.AttributeSample");

            var        properties = obj.GetType().GetProperties();
            EnumSample enumsamp   = new EnumSample();

            enumsamp.OdayaGirebilir(AuthTree.Mudur);
            enumsamp.OdayaGirebilir(AuthTree.Ogrenci);
            AuthTree ogretmenVeli = (AuthTree.Veli | AuthTree.Ogretmen);

            enumsamp.OdayaGirebilir(ogretmenVeli);
            enumsamp.OdayaGirebilir(AuthTree.Ogretmen);
            enumsamp.OdayaGirebilir(AuthTree.MudurYard);
            enumsamp.OdayaGirebilir(AuthTree.Veli | AuthTree.Ogrenci);
            enumsamp.OdayaGirebilir(AuthTree.Mudur | AuthTree.Ogretmen);
            MessageBox.Show(enumsamp.girebilenler.ToString());
            int number  = 10;
            int number2 = number++;

            Console.WriteLine((number2));
            Console.WriteLine((number));
            Console.WriteLine((++number));
            Console.WriteLine((number));

            PartialSample1 prt = new PartialSample1();

            csharpbasics.A a1 = new A(5, 6);
            csharpbasics.A a2 = new A(5, 6);
            a1 += a2;
            csharpbasics.A a3 = a1 + a2;
            BoxingUnboxing.BoxandUnboxSample();
        }
示例#5
0
        public String UpdateItem(ItemData item)
        {
            var user     = _userSvc.CurrentUser();
            var cry      = (CryptoService)HttpContext.Current.Session["DATA"];
            var file     = (String)HttpContext.Current.Session["FILE"];
            var toUpdate = cry.FindById(item.Id);
            var parentId = item.ParentId;

            if (String.IsNullOrWhiteSpace(parentId))
            {
                parentId = toUpdate.Parent.Id;
            }
            var      parentItem = cry.FindById(parentId) as AuthTree;
            AuthTree toUpdatet  = toUpdate as AuthTree;
            AuthLeaf toUpdatel  = toUpdate as AuthLeaf;

            if (parentItem == cry.Root && toUpdatet == null)
            {
                throw new Exception("ONLY FOLDERS CAN BE ADDED TO ROOT!!");
            }
            if (parentItem.Id != toUpdate.Parent.Id)
            {
                toUpdate.Parent.Children.Remove(toUpdate);
                parentItem.Children.Add(toUpdate);
                toUpdate.Parent = parentItem;
            }
            if (toUpdatet != null)
            {
                toUpdatet.Title = item.Title;
            }
            else if (toUpdatel != null)
            {
                toUpdatel.Notes            = item.Notes;
                toUpdatel.UserName         = item.UserName;
                toUpdatel.Url              = item.Url;
                toUpdatel.Title            = item.Title;
                toUpdatel.LastModifiedTime = DateTime.UtcNow;
                toUpdatel.HasAttachment    = item.HasAttachment;
            }
            Save();
            return(item.Id);
        }
示例#6
0
        public IEnumerable <Item> LoadChildren(String id)
        {
            var      user = _userSvc.CurrentUser();
            var      cry  = (CryptoService)HttpContext.Current.Session["DATA"];
            AuthTree item = cry.FindById(id) as AuthTree;

            if (item == null)
            {
                yield break;
            }
            foreach (var sub in item.Children)
            {
                yield return(new Item
                {
                    Id = sub.Id,
                    IsFolder = sub is AuthTree,
                    Title = sub.Title
                });
            }
        }
示例#7
0
        public void CreateItem(ItemData item)
        {
            var      user     = _userSvc.CurrentUser();
            var      cry      = (CryptoService)HttpContext.Current.Session["DATA"];
            var      file     = (String)HttpContext.Current.Session["FILE"];
            var      parentId = item.ParentId;
            AuthTree ida      = cry.FindById(parentId) as AuthTree;

            if (item.IsFolder)
            {
                var newNode = new AuthTree
                {
                    Title  = item.Title,
                    Parent = ida
                };
                ida.Children.Add(newNode);
                cry.RegisterNode(newNode);
            }
            else
            {
                var newNode = new AuthLeaf
                {
                    Notes         = item.Notes,
                    ExpireTime    = item.ExpireTime,
                    Title         = item.Title,
                    Url           = item.Url,
                    UserName      = item.UserName,
                    Password      = item.Password,
                    Parent        = ida,
                    HasAttachment = item.HasAttachment
                };
                ida.Children.Add(newNode);
                cry.RegisterNode(newNode);
            }
            Save();
        }