Example #1
0
        /// <summary>
        /// Configures the entities.
        /// </summary>
        /// <param name="rootNode">The root node.</param>
        /// <param name="metatables">The metatables.</param>
        protected void ConfigureEntities(XmlNode rootNode, Dictionary <string, MetaPersistentType> metatables)
        {
            NodeAttributes rootAtributes = new NodeAttributes(rootNode);
            bool           autoscan      = rootAtributes.AsBool("autoscan", true);
            string         entityPreffix = rootAtributes.AsString("entityPreffix");

            if (autoscan)
            {
                this.Scanner = new SecurityScanner(this);
                this.Scanner.EntityPreffix = rootAtributes.AsString("entityPreffix");
                this.Scanner.EntitySuffix  = rootAtributes.AsString("entitySuffix");
                this.Scanner.DtoPreffix    = rootAtributes.AsString("dtoPreffix");
                this.Scanner.DtoSuffix     = rootAtributes.AsString("dtoSuffix", "Dto");
                this.Scanner.FilterPreffix = rootAtributes.AsString("filterPreffix");
                this.Scanner.FilterSuffix  = rootAtributes.AsString("filterSuffix", "Filter");
                this.Scanner.BOPreffix     = rootAtributes.AsString("boPreffix");
                this.Scanner.BOSuffix      = rootAtributes.AsString("boSuffix", "BO");
                this.Scanner.Metatables    = metatables;
                this.Scanner.ScanNamespace(rootAtributes.AsString("namespaces"));
            }
        }
Example #2
0
        /// <summary>
        /// Configures the Security Manager from a file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public virtual void Configure(string fileName)
        {
            MetadataContainer metadata = this.GetOpenAccessMetadata();
            Dictionary <string, MetaPersistentType> metatables = this.GetMetaTables(metadata);
            XmlDocument document = null;

            if (!string.IsNullOrEmpty(fileName))
            {
                document = XmlResources.GetFromResource(fileName);
                if (document == null)
                {
                    document = XmlResources.GetFromEmbeddedResource(fileName);
                }
            }
            if (document != null)
            {
                ObjectProxyFactory.ConfigureMappers(document);
                XmlNode rootNode = document.SelectSingleNode("configuration/entities");
                if (rootNode != null)
                {
                    this.ConfigureEntities(rootNode, metatables);
                }
            }
            else
            {
                this.Scanner = new SecurityScanner(this);
                this.Scanner.EntityPreffix = string.Empty;
                this.Scanner.EntitySuffix  = string.Empty;
                this.Scanner.DtoPreffix    = string.Empty;
                this.Scanner.DtoSuffix     = "Dto";
                this.Scanner.FilterPreffix = string.Empty;
                this.Scanner.FilterSuffix  = "Filter";
                this.Scanner.BOPreffix     = string.Empty;
                this.Scanner.BOSuffix      = "BO";
                this.Scanner.Metatables    = metatables;
                this.Scanner.ScanNamespace(string.Empty);
            }
        }