/// <summary>
        /// Get the <see cref="DemoValue"/> entity with the given identifier.
        /// </summary>
        /// <param name="identifier">The <see cref="DemoValue"/> identifier.</param>
        /// <param name="filters">The parameters for entity selection.</param>
        /// <returns>The <see cref="DemoValue"/> entitie with the given identifier.</returns>
        public DemoValue GetDemoValue(Guid identifier, IDictionary <string, string> filters = null)
        {
            DemoValue entity = default(DemoValue);

            using (IEntityContext context = DependencyInjection.Get <IEntityContext>())
            {
                using (IDemoValueRepository repository = DependencyInjection.Get <IDemoValueRepository>(InjectionParameter.Create("context", context)))
                {
                    IQueryOver <DemoValue, DemoValue> query =
                        repository
                        .Query()
                        .Where(x => x.ID == identifier);

                    entity = query.List().SingleOrDefault();

                    // The next line is just for demo purposes.
                    //set.ForEach(item => item.AddCollectionReference(Corporation.Metadata.SUBSIDUARIES_PROPERTY, item.Subsiduaries.Select(e => e.ID.ToString()).ToList()));
                }

                context.Commit();
            }

            return(entity);
        }
Example #2
0
        static void Main(string[] args)
        {
            Hashtable  ht        = new Hashtable();
            BaseEntity search111 = new BaseEntity()
            {
                Id = 111
            };
            BaseEntity search222 = new BaseEntity()
            {
                Id = 222
            };

            Console.WriteLine(search111.GetHashCode());
            Console.WriteLine(search222.GetHashCode());
            ht.Add(search111, 100);
            ht.Add(search222, 200);


            if (ht.ContainsKey(new BaseEntity()
            {
                Id = 111
            }))
            {
                Console.WriteLine("contains");
            }
            else
            {
                Console.WriteLine("not contains");
            }
            return;

            Console.WriteLine(System.Web.Mvc.HttpVerbs.Get);
            return;

            string path_ = @"E:\Source\Repos\nopCommerce_3.80_Beta_Source\Libraries\Nop.Core\Html\1.txt";

            File.WriteAllText(path_, "1231\n123\n12\r1123" + Environment.NewLine + "helo\r\n");
            string value_ = File.ReadAllText(path_);

            return;

            string text   = @"<b>Hellosdf>>>>sdfsdf</b>123";
            var    result = Regex.Replace(text, "(<[^>]*>)([^<]*)", "$2");

            Console.WriteLine("result: " + result);

            foreach (Match item in Regex.Matches(text, "(<[^>]*>)([^<]*)"))
            {
                Console.WriteLine("group1: " + item.Groups[1].Value);
                Console.WriteLine("group2: " + item.Groups[2].Value);
            }
            return;

            DemoValue value = new DemoValue();

            value.MyProperty = 123;

            DemoClass classV = new DemoClass(value);

            Console.WriteLine(classV.MyProperty);


            return;

            //Console.WriteLine("\nReflection.Parameterinfo");
            //Type Mytype = Type.GetType("Nop.Core.Tests.Program");
            //Console.WriteLine(Mytype);

            ////Get and display the method.
            //MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
            //Console.Write("\nMymethodbase = " + Mymethodbase);

            ////Get the ParameterInfo array.
            //ParameterInfo[] Myarray = Mymethodbase.GetParameters();

            ////Get and display the ParameterInfo of each parameter.
            //foreach (ParameterInfo Myparam in Myarray)
            //{
            //    Console.Write("\nFor param eter # " + Myparam.Position
            //       + ", the ParameterType is - " + Myparam.ParameterType + ", " + Myparam.GetType());
            //}
            //return;

            //Demo1(22);
            //Demo1<string>(22);
            //Console.WriteLine();
            //return;
            string an2 = @"C:\Users\Administrator\Source\Repos\_nopcommerceLocalDemo\Tests\Nop.Core.Tests\bin\Debug\Nop.Core.dll";
            string an1 = @"E:\Source\Repos\nopCommerce_3.80_Beta_Source\Libraries\Nop.Core\bin\Debug\Autofac.dll";

            Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
            AssemblyName an = AssemblyName.GetAssemblyName(an1);

            Assembly.Load(an);
            Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
            Console.WriteLine(an);
            Console.WriteLine(an.FullName);
            return;

            foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
            {
                Console.WriteLine(item.FullName);
            }
            Console.WriteLine("================");
            System.Web.Compilation.BuildManager.AddReferencedAssembly(Assembly.Load(an));


            Console.WriteLine(Guid.NewGuid().ToString("N"));
            Console.WriteLine(Guid.NewGuid().ToString());
            var path  = AppDomain.CurrentDomain.BaseDirectory + ("\\global.asax");
            var path2 = AppDomain.CurrentDomain.BaseDirectory + ("\\global2.asax");

            File.Copy(path, path2, true);

            var shadowCopiedPlug = new FileInfo(path);

            Console.WriteLine(shadowCopiedPlug.CreationTime);
            shadowCopiedPlug = new FileInfo(path2);
            Console.WriteLine(shadowCopiedPlug.CreationTime);

            return;

            foreach (var item in Environment.NewLine)
            {
                Console.WriteLine((int)item);
            }

            Nop.Core.Data.DataSettings setting = new Data.DataSettings();
            Console.WriteLine(setting.DataProvider == null);
            return;

            long x = 123123;

            Console.WriteLine((x is int) ? "is int" : "not int");

            Console.WriteLine(System.ComponentModel.TypeDescriptor.GetConverter(typeof(int)));
            string[] arr2 = new string[1];
            Console.WriteLine(arr2.Any());
            return;

            TestClass t = new TestClass();

            // Get the type and PropertyInfo.
            Type         myType = t.GetType();
            PropertyInfo pinfo  = myType.GetProperty("Caption");

            pinfo.SetValue(t, "HEllo WORK", new object[1]);
            Console.WriteLine(pinfo.GetValue(t));
            return;

            string str = "\"Helo&quot;";

            using (var sw = new StringWriter())
                using (var xwr = new XmlTextWriter(sw))
                {
                    xwr.WriteString(str);
                    Console.WriteLine(sw.ToString());
                }

            return;


            BaseEntity1 be1  = new BaseEntity1();
            BaseEntity1 be11 = new BaseEntity1();

            Console.WriteLine(be1.GetHashCode());
            Console.WriteLine(be11.GetHashCode());
            return;

            BaseEntity2 be2 = new BaseEntity2();
            Dictionary <BaseEntity1, int> dic = new Dictionary <BaseEntity1, int>();

            dic.Add(be1, 1);
            dic.Add(be11, 2);
        }
Example #3
0
 public DemoClass(DemoValue value)
 {
     this._value = value;
 }
Example #4
0
        static void Main2(string[] args)
        {
            IEnumerable <int> array = new List <int> {
                1, 2, 3
            };
            Type arrT  = array.GetType();
            Type arrT2 = arrT.GetElementType();

            Console.WriteLine(arrT);
            Console.WriteLine(arrT2);
            Console.WriteLine("The element type of {0} is {1}.", array, arrT2);
            return;

            var builder = new ContainerBuilder();

            builder.RegisterType <ConsoleOutput>().AsSelf().As <IOutput>().InstancePerRequest();
            builder.RegisterType <TodayWriter>().As <IDateWriter>().InstancePerMatchingLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);;

            builder.RegisterType <MyComponent>();
            builder.Register(c => new MyComponent());
            var container = builder.Build();

            using (var scopeContainer = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag))
            {
                //var myComponent = scopeContainer.Resolve<MyComponent>();
                var myComponent = scopeContainer.Resolve <ConsoleOutput>();
            }


            return;

            using (var scope = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag))
            {
                IOutput output;
                try
                {
                    output = scope.Resolve <IOutput>();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return;

            // Create the scope, resolve your IDateWriter,
            // use it, then dispose of the scope.
            using (var scope = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag))
            {
                var writer = scope.Resolve <IDateWriter>();
                writer.WriteDate();
            }

            return;

            var demoC = TypeDescriptor.GetConverter(typeof(int?));

            Console.WriteLine(demoC);


            var _inputValues = new NameValueCollection();

            _inputValues.Add("a", "123123");
            _inputValues.Add("a", "hello");
            _inputValues.Add("a", "hello22");
            _inputValues.Add("sdfs", "sdfsfewr");

            Console.WriteLine(_inputValues["a"]);

            foreach (string item in _inputValues.Keys)
            {
                Console.WriteLine(item);
                string[] values = _inputValues.GetValues(item);
                foreach (var v in values)
                {
                    Console.WriteLine(v);
                }
                Console.WriteLine();
            }

            return;

            Console.WriteLine(3 / (float)2);
            return;

            List <int> all   = new List <int>();
            List <int> child = new List <int>();

            all.AddRange(child);
            Console.WriteLine(all.Count);
            return;

            double price    = 200;
            double percent  = 40;
            var    resultxx = price - (price) / (100 + percent) * percent;

            Console.WriteLine(resultxx);
            return;

            List <Pet> pets =
                new List <Pet> {
                new Pet {
                    Name = "Barley", Age = 8
                },
                new Pet {
                    Name = "Boots", Age = 4
                },
                new Pet {
                    Name = "Whiskers", Age = 1
                }
            };


            List <Pet> pets2 = new List <Pet>();

            foreach (Pet pet in pets2.DefaultIfEmpty())
            {
                Console.WriteLine(pet.Name);
            }

            return;


            var a = new int[] { 1, 3, 4, 5, 7, 99, 123123 };

            DemoValue[] b =
            {
                new DemoValue {
                    MyProperty = 3
                },
                new DemoValue {
                    MyProperty = 7
                },
                new DemoValue {
                    MyProperty = 99
                },
                new DemoValue {
                    MyProperty = 13212
                },
                new DemoValue {
                    MyProperty = 567
                },
            };



            var resultff = from b1 in b
                           join a1 in a
                           on b1.MyProperty equals a1
                           //select b1;
                           into ab
                           //from sm in ab.DefaultIfEmpty()
                           from sm in ab.DefaultIfEmpty()
                           select sm;

            var query = from ax in resultff
                        select ax;

            foreach (var item in resultff)
            {
                Console.WriteLine(item.GetType() + " " + item);
            }

            return;

            var             caching   = System.Runtime.Caching.MemoryCache.Default;
            int             cacheTime = 10;
            CacheItemPolicy policy    = new CacheItemPolicy();

            policy.AbsoluteExpiration = DateTime.Now + TimeSpan.FromMinutes(cacheTime);
            caching.Add(new System.Runtime.Caching.CacheItem("123", null), policy);

            if (caching.Contains("123"))
            {
                if (caching["123"] == null)
                {
                    Console.WriteLine("is null");
                }
            }

            return;

            File.WriteAllText(@"unicode2.txt", ToUnichar("01F6"), Encoding.Unicode);

            return;

            char cc = 'δΈ­';

            Console.WriteLine(CharUnicodeInfo.GetUnicodeCategory(cc));

            Console.WriteLine(typeof(Nop.Data.EfDataProviderManager));
            Console.WriteLine(typeof(Nop.Data.EfDataProviderManager).Name);

            return;

            Hashtable  ht        = new Hashtable();
            BaseEntity search111 = new BaseEntity()
            {
                Id = 111
            };
            BaseEntity search222 = new BaseEntity()
            {
                Id = 222
            };

            Console.WriteLine(search111.GetHashCode());
            Console.WriteLine(search222.GetHashCode());
            ht.Add(search111, 100);
            ht.Add(search222, 200);


            if (ht.ContainsKey(new BaseEntity()
            {
                Id = 111
            }))
            {
                Console.WriteLine("contains");
            }
            else
            {
                Console.WriteLine("not contains");
            }
            return;

            Console.WriteLine(System.Web.Mvc.HttpVerbs.Get);
            return;

            string path_ = @"E:\Source\Repos\nopCommerce_3.80_Beta_Source\Libraries\Nop.Core\Html\1.txt";

            File.WriteAllText(path_, "1231\n123\n12\r1123" + Environment.NewLine + "helo\r\n");
            string value_ = File.ReadAllText(path_);

            return;

            string text   = @"<b>Hellosdf>>>>sdfsdf</b>123";
            var    result = Regex.Replace(text, "(<[^>]*>)([^<]*)", "$2");

            Console.WriteLine("result: " + result);

            foreach (Match item in Regex.Matches(text, "(<[^>]*>)([^<]*)"))
            {
                Console.WriteLine("group1: " + item.Groups[1].Value);
                Console.WriteLine("group2: " + item.Groups[2].Value);
            }
            return;

            DemoValue value = new DemoValue();

            value.MyProperty = 123;

            DemoClass classV = new DemoClass(value);

            Console.WriteLine(classV.MyProperty);


            return;

            //Console.WriteLine("\nReflection.Parameterinfo");
            //Type Mytype = Type.GetType("Nop.Core.Tests.Program");
            //Console.WriteLine(Mytype);

            ////Get and display the method.
            //MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
            //Console.Write("\nMymethodbase = " + Mymethodbase);

            ////Get the ParameterInfo array.
            //ParameterInfo[] Myarray = Mymethodbase.GetParameters();

            ////Get and display the ParameterInfo of each parameter.
            //foreach (ParameterInfo Myparam in Myarray)
            //{
            //    Console.Write("\nFor param eter # " + Myparam.Position
            //       + ", the ParameterType is - " + Myparam.ParameterType + ", " + Myparam.GetType());
            //}
            //return;

            //Demo1(22);
            //Demo1<string>(22);
            //Console.WriteLine();
            //return;
            string an2 = @"C:\Users\Administrator\Source\Repos\_nopcommerceLocalDemo\Tests\Nop.Core.Tests\bin\Debug\Nop.Core.dll";
            string an1 = @"E:\Source\Repos\nopCommerce_3.80_Beta_Source\Libraries\Nop.Core\bin\Debug\Autofac.dll";

            Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
            AssemblyName an = AssemblyName.GetAssemblyName(an1);

            Assembly.Load(an);
            Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
            Console.WriteLine(an);
            Console.WriteLine(an.FullName);
            return;

            foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
            {
                Console.WriteLine(item.FullName);
            }
            Console.WriteLine("================");
            System.Web.Compilation.BuildManager.AddReferencedAssembly(Assembly.Load(an));


            Console.WriteLine(Guid.NewGuid().ToString("N"));
            Console.WriteLine(Guid.NewGuid().ToString());
            var path  = AppDomain.CurrentDomain.BaseDirectory + ("\\global.asax");
            var path2 = AppDomain.CurrentDomain.BaseDirectory + ("\\global2.asax");

            File.Copy(path, path2, true);

            var shadowCopiedPlug = new FileInfo(path);

            Console.WriteLine(shadowCopiedPlug.CreationTime);
            shadowCopiedPlug = new FileInfo(path2);
            Console.WriteLine(shadowCopiedPlug.CreationTime);

            return;

            foreach (var item in Environment.NewLine)
            {
                Console.WriteLine((int)item);
            }

            Nop.Core.Data.DataSettings setting = new Data.DataSettings();
            Console.WriteLine(setting.DataProvider == null);
            return;

            long x = 123123;

            Console.WriteLine((x is int) ? "is int" : "not int");

            Console.WriteLine(System.ComponentModel.TypeDescriptor.GetConverter(typeof(int)));
            string[] arr2 = new string[1];
            Console.WriteLine(arr2.Any());
            return;

            TestClass t = new TestClass();

            // Get the type and PropertyInfo.
            Type         myType = t.GetType();
            PropertyInfo pinfo  = myType.GetProperty("Caption");

            pinfo.SetValue(t, "HEllo WORK", new object[1]);
            Console.WriteLine(pinfo.GetValue(t));
            return;

            string str = "\"Helo&quot;";

            using (var sw = new StringWriter())
                using (var xwr = new XmlTextWriter(sw))
                {
                    xwr.WriteString(str);
                    Console.WriteLine(sw.ToString());
                }

            return;


            BaseEntity1 be1  = new BaseEntity1();
            BaseEntity1 be11 = new BaseEntity1();

            Console.WriteLine(be1.GetHashCode());
            Console.WriteLine(be11.GetHashCode());
            return;

            BaseEntity2 be2 = new BaseEntity2();
            Dictionary <BaseEntity1, int> dic = new Dictionary <BaseEntity1, int>();

            dic.Add(be1, 1);
            dic.Add(be11, 2);
        }