示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="product"></param>
 public ProductInfo(ProductElement product)
 {
     productId    = product.id;
     version      = product.version;
     product_name = product.name;
     productType  = (ProductType)Enum.Parse(typeof(ProductType), product.type);
 }
示例#2
0
 public void GetData()
 {
     foreach (XElement CategoryElement in xdoc.Element("Db").Elements("Category"))
     {
         XAttribute nameAttribute = CategoryElement.Attribute("name");
         Category   bufCategory   = new Category();
         bufCategory.Name = nameAttribute.Value;
         List <Product> bufProducts = new List <Product>();
         foreach (XElement ProductElement in CategoryElement.Elements("Product"))
         {
             Product  bufProduct      = new Product();
             XElement nameElement     = ProductElement.Element("Name");
             XElement GrammsElement   = ProductElement.Element("Gramms");
             XElement ProteinElement  = ProductElement.Element("Protein");
             XElement FatsElement     = ProductElement.Element("Fats");
             XElement CarbsElement    = ProductElement.Element("Carbs");
             XElement CaloriesElement = ProductElement.Element("Calories");
             bufProduct.Name     = nameElement.Value;
             bufProduct.Gramms   = int.Parse(GrammsElement.Value);
             bufProduct.Protein  = double.Parse(ProteinElement.Value);
             bufProduct.Fats     = double.Parse(FatsElement.Value);
             bufProduct.Carbs    = double.Parse(CarbsElement.Value);
             bufProduct.Calories = double.Parse(CaloriesElement.Value);
             bufProducts.Add(bufProduct);
         }
         bufCategory.products = bufProducts;
         resultCategories.Add(bufCategory);
     }
 }
示例#3
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Product>();
                    tx.Commit();
                }
            }
示例#4
0
        /*
         * author: Louise
         * date  : 16/11/2014
         * describe: 取得单条产生式
         */
        private List <ProductElement> getOneProduct()
        {
            List <ProductElement> product = new List <ProductElement>();

            while (true)
            {
                if (Cur >= buffer.Length)
                {
                    break;
                }
                if (buffer[Cur] == '\n' || buffer[Cur] == '\r')
                {
                    break;
                }
                if (buffer[Cur] == ' ')
                {
                    Cur++;
                    continue;
                }

                int            start   = Cur;
                ProductElement Element = new ProductElement();
                Element.IsTerminal = false;
                String data;

                while (buffer[Cur] != ' ' && buffer[Cur] != '\n' && buffer[Cur] != '\r' && Cur < buffer.Length)
                {
                    Cur++;
                    if (Cur >= buffer.Length)
                    {
                        break;
                    }
                }
                data = buffer.Substring(start, Cur - start);


                if (data.CompareTo("=") == 0)
                {
                    Cur++;
                    continue;
                }

                Element.NonTerminal = recoNonTerminal(data, Element);
                if (Element.IsTerminal == true)
                {
                    Element.Terminal = recoTerminal(data);
                }
                product.Add(Element);

                Cur++;
            }
            Cur++;

            return(product);
        }
            public void InitializeContext()
            {
                this.provider = new TestReferenceWithUriConverter();
                this.store    = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Element>();
                    tx.Commit();
                }
            }
示例#6
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                this.extension = new Mock <IAutomationExtension>();
                this.extension.As <IDisposable>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Product>();
                    tx.Commit();
                }

                this.element.AutomationExtensions.Add(this.extension.Object);
            }
        public void SaveProduct(string name, string company, string installPath, string virtualDirectoryRoot)
        {
            ProductSection productSection = config.GetSection("products") as ProductSection;

            ProductElement element = new ProductElement();

            element.Name                 = name;
            element.Company              = company;
            element.InstallPath          = installPath;
            element.VirtualDirectoryRoot = virtualDirectoryRoot;

            // Add the product
            productSection.Products.Add(element);

            config.Save();
        }
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = store.TransactionManager.BeginTransaction())
                {
                    this.property      = store.ElementFactory.CreateElement <Property>();
                    this.property.Info = Mocks.Of <IPropertyInfo>().First(i => i.Name == PropertyName && i.IsVisible == true && i.IsReadOnly == false);

                    this.element = store.ElementFactory.CreateElement <Element>();
                    this.element.Properties.Add(this.property);
                    tx.Commit();
                }

                this.descriptor = new ProductElementTypeDescriptor(
                    TypeDescriptor.GetProvider(this.element).GetTypeDescriptor(this.element), this.element);
            }
示例#9
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();
                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(SComponentModel)))
                .Returns(new Mock <IComponentModel>
                {
                    DefaultValue = DefaultValue.Mock
                }
                         .Object);
                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(IBindingCompositionService)))
                .Returns(new Mock <IBindingCompositionService>
                {
                    DefaultValue = DefaultValue.Mock
                }
                         .Object);

                this.automationExtension = new Mock <IAutomationExtension>();
                this.automationExtension.As <IDisposable>();
                this.automationExtension.As <ISupportInitialize>();
                this.extensionSettings = new Mock <IAutomationSettings>();
                this.extensionSettings
                .Setup(x => x.CreateAutomation(It.IsAny <IProductElement>()))
                .Returns(this.automationExtension.Object);

                var settingsContainer = new Mock <IPatternElementInfo>();
                var settingsInfo      = new Mock <IAutomationSettingsInfo>();

                settingsContainer
                .Setup(x => x.AutomationSettings)
                .Returns(new[] { settingsInfo.Object });

                settingsInfo
                .Setup(info => info.As <IAutomationSettings>())
                .Returns(this.extensionSettings.Object);

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element      = this.store.ElementFactory.CreateElement <Product>();
                    this.element.Info = settingsContainer.Object;
                    tx.Commit();
                }
            }
示例#10
0
            public void Initialize()
            {
                this.store = new DslTestStore <ProductStateStoreDomainModel>();

                using (var tx = this.store.TransactionManager.BeginTransaction())
                {
                    this.element = this.store.ElementFactory.CreateElement <Product>();
                    tx.Commit();
                }

                this.bindingContext = new Mock <IDynamicBindingContext> {
                    DefaultValue = DefaultValue.Mock
                };

                Mock.Get(this.store.ServiceProvider)
                .Setup(x => x.GetService(typeof(IBindingFactory)))
                .Returns(Mock.Of <IBindingFactory>(factory =>
                                                   factory.CreateContext() == this.bindingContext.Object));

                this.element.InstanceName = "Hello";
                this.element.Info         = Mock.Of <IElementInfo>(info =>
                                                                   info.Name == "My" &&
                                                                   info.ValidationSettings == new IBindingSettings[] { Mock.Of <IBindingSettings>() });
            }
示例#11
0
        /*
         *author: Louise
         *date  : 16/11/2014
         *describe: 取得单条产生式
         */
        private List<ProductElement> getOneProduct()
        {
            List<ProductElement> product = new List<ProductElement>();

            while (true)
            {
                if (Cur >= buffer.Length) break;
                if (buffer[Cur] == '\n' || buffer[Cur] == '\r') break;
                if (buffer[Cur] == ' ')
                {
                    Cur++;
                    continue;
                }

                int start = Cur;
                ProductElement Element = new ProductElement();
                Element.IsTerminal = false ;
                String data ;

                while (buffer[Cur] != ' ' && buffer[Cur] != '\n' && buffer[Cur] != '\r' && Cur < buffer.Length)
                {
                    Cur++;
                    if (Cur >= buffer.Length) break;
                }
                data = buffer.Substring(start, Cur - start);


                if (data.CompareTo( "=" ) == 0 )
                {
                     Cur++;
                     continue;
                }

                Element.NonTerminal = recoNonTerminal( data , Element ) ;
                if( Element.IsTerminal == true ) Element.Terminal = recoTerminal(data);
                product.Add(Element);

                Cur++;
            }
            Cur++;

            return product;
        }
示例#12
0
 /*
  *author: Louise
  *date  : 16/11/2014
  *describe: 辨认是哪个非终极符
  */
 private nonTerminals recoNonTerminal( String data , ProductElement Element )
 {
     switch (data)
     {
         case "Program":         return nonTerminals.Program;
         case "ProgramHead":     return nonTerminals.ProgramHead;
         case "ProgramName":     return nonTerminals.ProgramName;
         case "DeclarePart":     return nonTerminals.DeclarePart;
         case "TypeDecpart":     return nonTerminals.TypeDecpart;
         case "TypeDec":         return nonTerminals.TypeDec;
         case "TypeDecList":     return nonTerminals.TypeDecList;
         case "TypeDecMore":     return nonTerminals.TypeDecMore;
         case "TypeId":          return nonTerminals.TypeId;
         case "TypeDef":         return nonTerminals.TypeDef;
         case "BaseType":        return nonTerminals.BaseType;
         case "StructureType":   return nonTerminals.StructureType;
         case "ArrayType":       return nonTerminals.ArrayType;
         case "Low":             return nonTerminals.Low;
         case "Top":             return nonTerminals.Top;
         case "RecType":         return nonTerminals.RecType;
         case "FieldDecList":    return nonTerminals.FieldDecList;
         case "FieldDecMore":    return nonTerminals.FieldDecMore;
         case "IdList":          return nonTerminals.IdList;
         case "IdMore":          return nonTerminals.IdMore;
         case "VarDecpart":      return nonTerminals.VarDecpart;
         case "VarDec":          return nonTerminals.VarDec;
         case "VarDecList":      return nonTerminals.VarDecList;
         case "VarDecMore":      return nonTerminals.VarDecMore;
         case "VarIdList":       return nonTerminals.VarIdList;
         case "VarIdMore":       return nonTerminals.VarIdMore;
         case "ProcDecpart":     return nonTerminals.ProcDecpart;
         case "ProcDec":         return nonTerminals.ProcDec;
         case "ProcDecMore":     return nonTerminals.ProcDecMore;
         case "ProcName":        return nonTerminals.ProcName;
         case "ParamList":       return nonTerminals.ParamList;
         case "ProcDeclaration": return nonTerminals.ProcDeclaration;
         case "ParamDecList":    return nonTerminals.ParamDecList;
         case "ParamMore":       return nonTerminals.ParamMore;
         case "Param":           return nonTerminals.Param;
         case "FormList":        return nonTerminals.FormList;
         case "FidMore":         return nonTerminals.FidMore;
         case "ProcDecPart":     return nonTerminals.ProcDecPart;
         case "ProcBody":        return nonTerminals.ProcBody;
         case "ProgramBody":     return nonTerminals.ProgramBody;
         case "StmList":         return nonTerminals.StmList;
         case "StmMore":         return nonTerminals.StmMore;
         case "Stm":             return nonTerminals.Stm;
         case "AssCall":         return nonTerminals.AssCall;
         case "AssignmentRest":  return nonTerminals.AssignmentRest;
         case "ConditionalStm":  return nonTerminals.ConditionalStm;
         case "LoopStm":         return nonTerminals.LoopStm;
         case "InputStm":        return nonTerminals.InputStm;
         case "Invar":           return nonTerminals.Invar;
         case "OutputStm":       return nonTerminals.OutputStm;
         case "ReturnStm":       return nonTerminals.ReturnStm;
         case "CallStmRest":     return nonTerminals.CallStmRest;
         case "ActParamList":    return nonTerminals.ActParamList;
         case "ActParamMore":    return nonTerminals.ActParamMore;
         case "RelExp":          return nonTerminals.RelExp;
         case "OtherRelE":       return nonTerminals.OtherRelE;
         case "Exp":             return nonTerminals.Exp;
         case "OtherTerm":       return nonTerminals.OtherTerm;
         case "Term":            return nonTerminals.Term;
         case "OtherFactor":     return nonTerminals.OtherFactor;
         case "Factor":          return nonTerminals.Factor;
         case "Variable":        return nonTerminals.Variable;
         case "VariMore":        return nonTerminals.VariMore;
         case "FieldVar":        return nonTerminals.FieldVar;
         case "FieldVarMore":    return nonTerminals.FieldVarMore;
         case "CmpOp":           return nonTerminals.CmpOp;
         case "AddOp":           return nonTerminals.AddOp;
         case "MultOp":          return nonTerminals.MultOp;
     }
     Element.IsTerminal = true;
     return nonTerminals.Program;
 }
示例#13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="host_info"></param>
 /// <param name="product_info"></param>
 public ServerInfo(HostElement host_info, ProductElement product_info)
 {
     host    = new HostInfo(host_info);
     product = new ProductInfo(product_info);
 }
示例#14
0
        /*
         * author: Louise
         * date  : 16/11/2014
         * describe: 辨认是哪个非终极符
         */
        private nonTerminals recoNonTerminal(String data, ProductElement Element)
        {
            switch (data)
            {
            case "Program":         return(nonTerminals.Program);

            case "ProgramHead":     return(nonTerminals.ProgramHead);

            case "ProgramName":     return(nonTerminals.ProgramName);

            case "DeclarePart":     return(nonTerminals.DeclarePart);

            case "TypeDecpart":     return(nonTerminals.TypeDecpart);

            case "TypeDec":         return(nonTerminals.TypeDec);

            case "TypeDecList":     return(nonTerminals.TypeDecList);

            case "TypeDecMore":     return(nonTerminals.TypeDecMore);

            case "TypeId":          return(nonTerminals.TypeId);

            case "TypeDef":         return(nonTerminals.TypeDef);

            case "BaseType":        return(nonTerminals.BaseType);

            case "StructureType":   return(nonTerminals.StructureType);

            case "ArrayType":       return(nonTerminals.ArrayType);

            case "Low":             return(nonTerminals.Low);

            case "Top":             return(nonTerminals.Top);

            case "RecType":         return(nonTerminals.RecType);

            case "FieldDecList":    return(nonTerminals.FieldDecList);

            case "FieldDecMore":    return(nonTerminals.FieldDecMore);

            case "IdList":          return(nonTerminals.IdList);

            case "IdMore":          return(nonTerminals.IdMore);

            case "VarDecpart":      return(nonTerminals.VarDecpart);

            case "VarDec":          return(nonTerminals.VarDec);

            case "VarDecList":      return(nonTerminals.VarDecList);

            case "VarDecMore":      return(nonTerminals.VarDecMore);

            case "VarIdList":       return(nonTerminals.VarIdList);

            case "VarIdMore":       return(nonTerminals.VarIdMore);

            case "ProcDecpart":     return(nonTerminals.ProcDecpart);

            case "ProcDec":         return(nonTerminals.ProcDec);

            case "ProcDecMore":     return(nonTerminals.ProcDecMore);

            case "ProcName":        return(nonTerminals.ProcName);

            case "ParamList":       return(nonTerminals.ParamList);

            case "ProcDeclaration": return(nonTerminals.ProcDeclaration);

            case "ParamDecList":    return(nonTerminals.ParamDecList);

            case "ParamMore":       return(nonTerminals.ParamMore);

            case "Param":           return(nonTerminals.Param);

            case "FormList":        return(nonTerminals.FormList);

            case "FidMore":         return(nonTerminals.FidMore);

            case "ProcDecPart":     return(nonTerminals.ProcDecPart);

            case "ProcBody":        return(nonTerminals.ProcBody);

            case "ProgramBody":     return(nonTerminals.ProgramBody);

            case "StmList":         return(nonTerminals.StmList);

            case "StmMore":         return(nonTerminals.StmMore);

            case "Stm":             return(nonTerminals.Stm);

            case "AssCall":         return(nonTerminals.AssCall);

            case "AssignmentRest":  return(nonTerminals.AssignmentRest);

            case "ConditionalStm":  return(nonTerminals.ConditionalStm);

            case "LoopStm":         return(nonTerminals.LoopStm);

            case "InputStm":        return(nonTerminals.InputStm);

            case "Invar":           return(nonTerminals.Invar);

            case "OutputStm":       return(nonTerminals.OutputStm);

            case "ReturnStm":       return(nonTerminals.ReturnStm);

            case "CallStmRest":     return(nonTerminals.CallStmRest);

            case "ActParamList":    return(nonTerminals.ActParamList);

            case "ActParamMore":    return(nonTerminals.ActParamMore);

            case "RelExp":          return(nonTerminals.RelExp);

            case "OtherRelE":       return(nonTerminals.OtherRelE);

            case "Exp":             return(nonTerminals.Exp);

            case "OtherTerm":       return(nonTerminals.OtherTerm);

            case "Term":            return(nonTerminals.Term);

            case "OtherFactor":     return(nonTerminals.OtherFactor);

            case "Factor":          return(nonTerminals.Factor);

            case "Variable":        return(nonTerminals.Variable);

            case "VariMore":        return(nonTerminals.VariMore);

            case "FieldVar":        return(nonTerminals.FieldVar);

            case "FieldVarMore":    return(nonTerminals.FieldVarMore);

            case "CmpOp":           return(nonTerminals.CmpOp);

            case "AddOp":           return(nonTerminals.AddOp);

            case "MultOp":          return(nonTerminals.MultOp);
            }
            Element.IsTerminal = true;
            return(nonTerminals.Program);
        }