public static SpecialNamingBase GetNamingProcessor(NamingApproach approach, string namingCode)
        {
            const string ns = "RadaCode.InDoc.Data.DocumentNaming.SpecialNamings.Namings";
            var dataAssembly = typeof(RadaCode.InDoc.Data.DocumentNaming.SpecialNamings.SpecialNamingBase).Assembly;

            var classes = SpecialNamingsFactory.GetAllClasses(ns, dataAssembly);

            var res = new List<string>();
            foreach (var inst in classes.Select(namingClass => string.Format("{0}.{1}", ns, namingClass)).Select(toCreate => dataAssembly.GetType(toCreate)).Select(type => Activator.CreateInstance(type, approach)).Where(inst => ((SpecialNamingBase)inst).SpecialCode == namingCode))
            {
                return inst as SpecialNamingBase;
            }

            throw new Exception(string.Format("No class found that is able to process {0} code", namingCode));
        }
Example #2
0
        public static SpecialNamingBase GetNamingProcessor(NamingApproach approach, string namingCode)
        {
            const string ns           = "RadaCode.InDoc.Data.DocumentNaming.SpecialNamings.Namings";
            var          dataAssembly = typeof(RadaCode.InDoc.Data.DocumentNaming.SpecialNamings.SpecialNamingBase).Assembly;

            var classes = SpecialNamingsFactory.GetAllClasses(ns, dataAssembly);

            var res = new List <string>();

            foreach (var inst in classes.Select(namingClass => string.Format("{0}.{1}", ns, namingClass)).Select(toCreate => dataAssembly.GetType(toCreate)).Select(type => Activator.CreateInstance(type, approach)).Where(inst => ((SpecialNamingBase)inst).SpecialCode == namingCode))
            {
                return(inst as SpecialNamingBase);
            }

            throw new Exception(string.Format("No class found that is able to process {0} code", namingCode));
        }
Example #3
0
        protected override void Seed(InDocContext context)
        {
            var orderFormat = new NamingApproach()
            {
                Format   = "{intInc_G}/{intInc_D}/02/-{yy}",
                TypeName = "Orders"
            };

            var initParams = new List <KeyValuePair <int, string> >
            {
                new KeyValuePair <int, string>(0, "2296"), new KeyValuePair <int, string>(1, "1")
            };

            orderFormat.SaveCurrentParams(initParams);

            context.NamingApproaches.Add(orderFormat);

            base.Seed(context);
        }
        public void CreateGetParamBlocks()
        {
            const string format   = "{intInc_G}/{intInc_D}/02-{yy}";
            const string typeName = "Orders";

            var initParams = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(0, "2296"), new KeyValuePair <int, string>(1, "1")
            };

            var orderNamingApproach = new NamingApproach {
                Format = format, TypeName = typeName
            };

            orderNamingApproach.SaveCurrentParams(initParams);

            var breakdown = orderNamingApproach.ParamBlocks;

            Assert.AreEqual("1", breakdown[2]);
        }
        public void CreateSetParamsGetNameParams()
        {
            const string format   = "{intInc_G}/{intInc_D}/02-{yy}";
            const string typeName = "Orders";

            var initParams = new List <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(0, "2296"), new KeyValuePair <int, string>(1, "1")
            };

            var orderNamingApproach = new NamingApproach {
                Format = format, TypeName = typeName
            };

            orderNamingApproach.SaveCurrentParams(initParams);

            var newName = orderNamingApproach.GetNextName();

            Assert.AreEqual("2297/2/02-12", newName);
        }
        public void CreateSetParamsWriteOutParams()
        {
            const string format   = "{intInc_G}/{intInc_D}/02/-{yy}";
            const string typeName = "Orders";

            var initParams = new List <KeyValuePair <int, string> >
            {
                new KeyValuePair <int, string>(0, "2296"), new KeyValuePair <int, string>(1, "1")
            };

            var orderNamingApproach = new NamingApproach {
                Format = format, TypeName = typeName
            };

            orderNamingApproach.SaveCurrentParams(initParams);

            Console.WriteLine(orderNamingApproach.CurrentParamsCounters);

            Assert.IsNotEmpty(orderNamingApproach.CurrentParamsCounters);
        }
Example #7
0
 public YearNaming(ref NamingApproach approach)
     : base(ref approach){}
Example #8
0
 public GlobalIntIncNaming(ref NamingApproach approach) : base(ref approach)
 {
 }
Example #9
0
 public DailyIntIncNaming(ref NamingApproach approach) : base(ref approach)
 {}
Example #10
0
 protected SpecialNamingBase(ref NamingApproach approach)
 {
     Approach = approach;
 }
Example #11
0
 public GlobalIntIncNaming(ref NamingApproach approach) : base(ref approach)
 {}
Example #12
0
 protected SpecialNamingBase(ref NamingApproach approach)
 {
     Approach = approach;
 }
Example #13
0
 public DailyIntIncNaming(ref NamingApproach approach) : base(ref approach)
 {
 }
Example #14
0
 public YearNaming(ref NamingApproach approach)
     : base(ref approach)
 {
 }