Ejemplo n.º 1
0
        public static IRuleDefinition RuleDefinitionMapper(ICategoryDefinition parentCategoryDefinition, Model.RuleDefinition ruleDefinition)
        {
            IRuleDefinition rule = null;

            try
            {
                rule = ConfigurationComponentFactory().ConfigurationFactory <IRuleDefinition>(typeof(IRuleDefinition));
            }
            catch (Exception e)
            {
                throw new DataAccessComponentException(null, -1, "Configuration proxy factory failure - unable to create an instance of " + typeof(IRuleDefinition) + "?", e);
            }


            try
            {
                rule.Id                           = ruleDefinition.Id;
                rule.Enabled                      = ruleDefinition.Enabled;
                rule.ParentDefinition             = parentCategoryDefinition;
                rule.RuleDeclarationReferenceId   = ruleDefinition.RuleDeclaration.Id;
                rule.RuleDeclarationReferenceName = ruleDefinition.RuleDeclaration.Name;
            }
            catch (Exception e)
            {
                throw new DataAccessComponentException(null, -1, "Mapping process failure?", e);
            }
            return(rule);
        }
Ejemplo n.º 2
0
        public static ICategoryDefinition CategoryDefinitionMapper(IProjectDefinition parentProjectDefinition, Model.CategoryDefinition categoryDefinition)
        {
            ICategoryDefinition category = null;

            try
            {
                category = ConfigurationComponentFactory().ConfigurationFactory <ICategoryDefinition>(typeof(ICategoryDefinition));
            }
            catch (Exception e)
            {
                throw new DataAccessComponentException(null, -1, "Configuration proxy factory failure - unable to create an instance of " + typeof(ICategoryDefinition) + "?", e);
            }


            try
            {
                category.Id               = categoryDefinition.Id;
                category.Enabled          = categoryDefinition.Enabled;
                category.ParentDefinition = parentProjectDefinition;
                category.CategoryDeclarationReferenceId   = categoryDefinition.CategoryDeclaration.Id;
                category.CategoryDeclarationReferenceName = categoryDefinition.CategoryDeclaration.Name;

                foreach (var ruleDef in categoryDefinition.RuleDefinitions)
                {
                    category.Rules.Add(ruleDef.Id, RuleDefinitionMapper(category, ruleDef));
                }
            }
            catch (Exception e)
            {
                throw new DataAccessComponentException(null, -1, "Mapping process failure?", e);
            }
            return(category);
        }
Ejemplo n.º 3
0
        public static XmlNode CreateCategoryDefinitionsXmlNode(XmlDocument doc, IProjectDefinition definition)
        {
            // <CategoryDefinitions>
            //   <CategoryDefinition />
            // </CategoryDefinitions>
            XmlNode categoryDefinitionsNode = doc.CreateNode(XmlNodeType.Element, "CategoryDefinitions", null);

            foreach (KeyValuePair <int, ICategoryDefinition> pair in definition.Categories)
            {
                ICategoryDefinition categoryDefinition = pair.Value;

                categoryDefinitionsNode.AppendChild(CreateCategoryDefinitionXmlNode(doc, categoryDefinition));
            }
            return(categoryDefinitionsNode);
        }
Ejemplo n.º 4
0
        public static XmlNode CreateCategoryDefinitionXmlNode(XmlDocument doc, ICategoryDefinition definition)
        {
            // <CategoryDefinition Enabled="true" Id="{GUID}" RefName="Try-Catches" RefId="{GUID}">
            //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="No explicit exception identifier" RefId="{GUID}"/>
            //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="Empty try-catch" RefId="{GUID}"/>
            //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="Try-catch vs. throw exception" RefId="{GUID}"/>
            // </CategoryDefinition>
            XmlNode      categoryDefinitionNode = doc.CreateNode(XmlNodeType.Element, "CategoryDefinition", null);
            XmlAttribute idAttrib      = doc.CreateAttribute("Id");
            XmlAttribute enabledAttrib = doc.CreateAttribute("Enabled");
            XmlAttribute refNameAttrib = doc.CreateAttribute("RefName");
            XmlAttribute refIdAttrib   = doc.CreateAttribute("RefId");

            idAttrib.Value      = definition.Id.ToString();
            enabledAttrib.Value = definition.Enabled.ToString();
            refNameAttrib.Value = definition.CategoryDeclarationReferenceName;
            refIdAttrib.Value   = definition.CategoryDeclarationReferenceId + "";

            categoryDefinitionNode.Attributes.Append(idAttrib);
            categoryDefinitionNode.Attributes.Append(enabledAttrib);
            categoryDefinitionNode.Attributes.Append(refNameAttrib);
            categoryDefinitionNode.Attributes.Append(refIdAttrib);

            foreach (KeyValuePair <int, IRuleDefinition> pair in definition.Rules)
            {
                IRuleDefinition ruleDef = pair.Value;

                XmlNode      ruleDefinitionNode = doc.CreateNode(XmlNodeType.Element, "RuleDefinition", null);
                XmlAttribute id      = doc.CreateAttribute("Id");
                XmlAttribute enabled = doc.CreateAttribute("Enabled");
                XmlAttribute refName = doc.CreateAttribute("RefName");
                XmlAttribute refId   = doc.CreateAttribute("RefId");

                id.Value      = ruleDef.Id.ToString();
                enabled.Value = ruleDef.Enabled.ToString();
                refName.Value = ruleDef.RuleDeclarationReferenceName;
                refId.Value   = ruleDef.RuleDeclarationReferenceId + "";

                ruleDefinitionNode.Attributes.Append(id);
                ruleDefinitionNode.Attributes.Append(enabled);
                ruleDefinitionNode.Attributes.Append(refName);
                ruleDefinitionNode.Attributes.Append(refId);

                categoryDefinitionNode.AppendChild(ruleDefinitionNode);
            }
            return(categoryDefinitionNode);
        }
Ejemplo n.º 5
0
        public static XmlNode CreateCategoryDefinitionXmlNode(XmlDocument doc, ICategoryDefinition definition)
        {
            // <CategoryDefinition Enabled="true" Id="{GUID}" RefName="Try-Catches" RefId="{GUID}">
              //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="No explicit exception identifier" RefId="{GUID}"/>
              //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="Empty try-catch" RefId="{GUID}"/>
              //   <RuleDefinition Enabled="true" Id="{GUID}" RefName="Try-catch vs. throw exception" RefId="{GUID}"/>
              // </CategoryDefinition>
              XmlNode categoryDefinitionNode = doc.CreateNode(XmlNodeType.Element, "CategoryDefinition", null);
              XmlAttribute     idAttrib      = doc.CreateAttribute("Id");
              XmlAttribute     enabledAttrib = doc.CreateAttribute("Enabled");
              XmlAttribute     refNameAttrib = doc.CreateAttribute("RefName");
              XmlAttribute     refIdAttrib   = doc.CreateAttribute("RefId");

              idAttrib.Value      = definition.Id.ToString();
              enabledAttrib.Value = definition.Enabled.ToString();
              refNameAttrib.Value = definition.CategoryDeclarationReferenceName;
              refIdAttrib.Value   = definition.CategoryDeclarationReferenceId + "";

              categoryDefinitionNode.Attributes.Append(idAttrib);
              categoryDefinitionNode.Attributes.Append(enabledAttrib);
              categoryDefinitionNode.Attributes.Append(refNameAttrib);
              categoryDefinitionNode.Attributes.Append(refIdAttrib);

              foreach (KeyValuePair<int, IRuleDefinition> pair in definition.Rules)
              {
            IRuleDefinition ruleDef = pair.Value;

            XmlNode ruleDefinitionNode = doc.CreateNode(XmlNodeType.Element, "RuleDefinition", null);
            XmlAttribute       id      = doc.CreateAttribute("Id");
            XmlAttribute       enabled = doc.CreateAttribute("Enabled");
            XmlAttribute       refName = doc.CreateAttribute("RefName");
            XmlAttribute       refId   = doc.CreateAttribute("RefId");

            id.Value      = ruleDef.Id.ToString();
            enabled.Value = ruleDef.Enabled.ToString();
            refName.Value = ruleDef.RuleDeclarationReferenceName;
            refId.Value   = ruleDef.RuleDeclarationReferenceId + "";

            ruleDefinitionNode.Attributes.Append(id);
            ruleDefinitionNode.Attributes.Append(enabled);
            ruleDefinitionNode.Attributes.Append(refName);
            ruleDefinitionNode.Attributes.Append(refId);

            categoryDefinitionNode.AppendChild(ruleDefinitionNode);
              }
              return categoryDefinitionNode;
        }
Ejemplo n.º 6
0
        private void CreateCategoryDefinitionsFile()
        {
            IConfigurationProxy proxy = ProxyHome.Instance.RetrieveConfigurationProxy(OutputKeyKeeper.Instance.AccessKey);

            XmlNode     node;
            XmlDocument doc = XmlFactory.CreateXmlFile(Ids.XSLT_DIR, Ids.ALL_CATEGORY_DEFINITIONS_XSLT_FILE, "CategoryDefinitions", out node);

            //<CategoryDefinitions>
            //  <CategoryDefinition />
            //</CategoryDefinitions>
            foreach (KeyValuePair <int, IProjectDefinition> projectDefinition in proxy.Projects())
            {
                foreach (KeyValuePair <int, ICategoryDefinition> pair in proxy.ProjectCategories(projectDefinition.Value.Id))
                {
                    ICategoryDefinition categoryDefinition = pair.Value;

                    node.AppendChild(XmlFactory.CreateCategoryDefinitionXmlNode(doc, categoryDefinition));
                    doc.AppendChild(node);
                }
            }

            XmlFactory.SaveXmlFile(Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.ALL_CATEGORY_DEFINITIONS_XML_FILE), doc);
        }
Ejemplo n.º 7
0
            public void ConfigurationFactory_AllSupportedTypes_ReturnsValidObject()
            {
                ConfigurationComponentFactory factory = ConfigurationComponentFactory.Instance;

                factory.InitializeComponentAccessPermissions(AppManager);

                Debug.Assert(factory != null, "proxy != null");
                ILanguageDeclaration languageDeclaration = factory.ConfigurationFactory <ILanguageDeclaration>(typeof(ILanguageDeclaration));
                IRuleDeclaration     ruleDeclaration     = factory.ConfigurationFactory <IRuleDeclaration>(typeof(IRuleDeclaration));
                IProjectDefinition   projectDefinition   = factory.ConfigurationFactory <IProjectDefinition>(typeof(IProjectDefinition));
                ICategoryDefinition  categoryDefinition  = factory.ConfigurationFactory <ICategoryDefinition>(typeof(ICategoryDefinition));
                IRuleDefinition      ruleDefinition      = factory.ConfigurationFactory <IRuleDefinition>(typeof(IRuleDefinition));
                IDirectoryDefinition directoryDefinition = factory.ConfigurationFactory <IDirectoryDefinition>(typeof(IDirectoryDefinition));
                IFileDefinition      fileDefinition      = factory.ConfigurationFactory <IFileDefinition>(typeof(IFileDefinition));

                Assert.IsNotNull(languageDeclaration);
                Assert.IsNotNull(ruleDeclaration);
                Assert.IsNotNull(projectDefinition);
                Assert.IsNotNull(categoryDefinition);
                Assert.IsNotNull(ruleDefinition);
                Assert.IsNotNull(directoryDefinition);
                Assert.IsNotNull(fileDefinition);
            }
Ejemplo n.º 8
0
 public static Model.CategoryDefinition CategoryDefinitionMapper(ICategoryDefinition categoryDefinition)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public static Model.CategoryDefinition CategoryDefinitionMapper(ICategoryDefinition categoryDefinition)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        public static IRuleDefinition RuleDefinitionMapper(ICategoryDefinition parentCategoryDefinition, Model.RuleDefinition ruleDefinition)
        {
            IRuleDefinition rule = null;
              try
              {
            rule = ConfigurationComponentFactory().ConfigurationFactory<IRuleDefinition>(typeof(IRuleDefinition));
              }
              catch (Exception e)
              {
            throw new DataAccessComponentException(null, -1, "Configuration proxy factory failure - unable to create an instance of " + typeof(IRuleDefinition) + "?", e);
              }

              try
              {
            rule.Id                           = ruleDefinition.Id;
            rule.Enabled                      = ruleDefinition.Enabled;
            rule.ParentDefinition             = parentCategoryDefinition;
            rule.RuleDeclarationReferenceId   = ruleDefinition.RuleDeclaration.Id;
            rule.RuleDeclarationReferenceName = ruleDefinition.RuleDeclaration.Name;
              }
              catch (Exception e)
              {
            throw new DataAccessComponentException(null, -1, "Mapping process failure?", e);
              }
              return rule;
        }