示例#1
0
        public virtual System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ConnectionProfile> ParseEnabled(Net.Vpc.Upa.Impl.DefaultProperties p2, Net.Vpc.Upa.Persistence.ConnectionConfig[] connectionConfigsArr, string prefix0)
        {
            System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ConnectionProfile> found = new System.Collections.Generic.List <Net.Vpc.Upa.Persistence.ConnectionProfile>();
            for (int i = 0; i < connectionConfigsArr.Length; i++)
            {
                Net.Vpc.Upa.Persistence.ConnectionConfig connectionConfig = connectionConfigsArr[i];
                string prefix = prefix0 + "[" + i + "]";
                p2.SetString(prefix, connectionConfig.GetConnectionString());
                p2.SetString(prefix + ".password", connectionConfig.GetPassword());
                p2.SetString(prefix + ".userName", connectionConfig.GetUserName());
                p2.SetString(prefix + ".enabled", connectionConfig.IsEnabled() == null ? "true" : System.Convert.ToString(connectionConfig.IsEnabled()));
                p2.SetString(prefix + ".structure", connectionConfig.GetStructureStrategy() == default(Net.Vpc.Upa.Persistence.StructureStrategy) ? null : connectionConfig.GetStructureStrategy().ToString());
                foreach (System.Collections.Generic.KeyValuePair <string, string> entry in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, string> >(connectionConfig.GetProperties()))
                {
                    p2.SetString(prefix + "." + (entry).Key, (entry).Value);
                }
            }
            int i2 = 0;

            while (true)
            {
                string prefix = prefix0 + "[" + i2 + "]";
                if (p2.IsSet(prefix))
                {
                    if (System.Convert.ToBoolean(p2.GetString(prefix + ".enabled", "true")))
                    {
                        Net.Vpc.Upa.Persistence.ConnectionProfile a = Parse(p2, prefix);
                        //if (isValidConnectionProfile(a)) {
                        found.Add(a);
                    }
                    //}
                    i2++;
                }
                else
                {
                    break;
                }
            }
            if (p2.IsSet(prefix0))
            {
                if (System.Convert.ToBoolean(p2.GetString(prefix0 + ".enabled", "true")))
                {
                    Net.Vpc.Upa.Persistence.ConnectionProfile a = Parse(p2, prefix0);
                    //if (isValidConnectionProfile(a)) {
                    found.Add(a);
                }
            }
            //}
            return(found);
        }
示例#2
0
 public virtual Net.Vpc.Upa.Persistence.UPAContextConfig ParseContextConfig(Net.Vpc.Upa.Impl.Config.ContextElement contextElement)
 {
     Net.Vpc.Upa.Persistence.UPAContextConfig c = new Net.Vpc.Upa.Persistence.UPAContextConfig();
     System.Collections.Generic.HashSet <Net.Vpc.Upa.Config.ScanFilter> filters = new System.Collections.Generic.HashSet <Net.Vpc.Upa.Config.ScanFilter>();
     foreach (Net.Vpc.Upa.Impl.Config.ScanElement scanElement in contextElement.GetScanElements())
     {
         filters.Add(new Net.Vpc.Upa.Config.ScanFilter(scanElement.libs, scanElement.types, scanElement.propagate, Net.Vpc.Upa.Persistence.UPAContextConfig.XML_ORDER));
     }
     if ((filters.Count == 0) && contextElement.autoScan)
     {
         filters.Add(new Net.Vpc.Upa.Config.ScanFilter(null, null, true, Net.Vpc.Upa.Persistence.UPAContextConfig.XML_ORDER));
     }
     c.SetAutoScan(contextElement.autoScan);
     c.SetFilters(new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(filters));
     c.SetPersistenceGroups(new System.Collections.Generic.List <Net.Vpc.Upa.Persistence.PersistenceGroupConfig>());
     foreach (Net.Vpc.Upa.Impl.Config.PersistenceGroupElement e in contextElement.GetPersistenceGroupElements())
     {
         Net.Vpc.Upa.Persistence.PersistenceGroupConfig gc = new Net.Vpc.Upa.Persistence.PersistenceGroupConfig(Net.Vpc.Upa.Persistence.UPAContextConfig.XML_ORDER);
         gc.SetName(e.name);
         gc.SetAutoScan(e.autoScan);
         filters = new System.Collections.Generic.HashSet <Net.Vpc.Upa.Config.ScanFilter>();
         foreach (Net.Vpc.Upa.Impl.Config.ScanElement scanElement in e.GetScanElements())
         {
             filters.Add(new Net.Vpc.Upa.Config.ScanFilter(scanElement.libs, scanElement.types, scanElement.propagate, Net.Vpc.Upa.Persistence.UPAContextConfig.XML_ORDER));
         }
         gc.SetContextAnnotationStrategyFilters(new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(filters));
         System.Collections.Generic.IDictionary <string, object> parameters = gc.GetProperties();
         if (parameters == null)
         {
             parameters = new System.Collections.Generic.Dictionary <string, object>();
         }
         foreach (Net.Vpc.Upa.Property property in e.properties)
         {
             parameters[property.GetName()] = Net.Vpc.Upa.Impl.Util.UPAUtils.CreateValue(property);
         }
         c.GetPersistenceGroups().Add(gc);
         foreach (Net.Vpc.Upa.Impl.Config.PersistenceUnitElement pue in e.GetPersistenceUnitElements())
         {
             Net.Vpc.Upa.Persistence.PersistenceUnitConfig pu = new Net.Vpc.Upa.Persistence.PersistenceUnitConfig();
             pu.SetName(pue.name);
             pu.SetAutoStart(pue.start);
             pu.SetAutoScan(pue.autoScan);
             filters = new System.Collections.Generic.HashSet <Net.Vpc.Upa.Config.ScanFilter>();
             foreach (Net.Vpc.Upa.Impl.Config.ScanElement scanElement in pue.GetScanElements())
             {
                 filters.Add(new Net.Vpc.Upa.Config.ScanFilter(scanElement.libs, scanElement.types, scanElement.propagate, Net.Vpc.Upa.Persistence.UPAContextConfig.XML_ORDER));
             }
             pu.SetContextAnnotationStrategyFilters(new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(filters));
             //pu.setModel(null);
             parameters = pu.GetProperties();
             if (parameters == null)
             {
                 parameters = new System.Collections.Generic.Dictionary <string, object>();
             }
             foreach (Net.Vpc.Upa.Property property in pue.properties)
             {
                 parameters[property.GetName()] = Net.Vpc.Upa.Impl.Util.UPAUtils.CreateValue(property);
             }
             pu.SetPersistenceGroup(e.name);
             pu.SetProperties(parameters);
             foreach (Net.Vpc.Upa.Impl.Config.ConnectionElement ce in pue.connectionElements)
             {
                 Net.Vpc.Upa.Persistence.ConnectionConfig cc = new Net.Vpc.Upa.Persistence.ConnectionConfig();
                 cc.SetConnectionString(ce.connectionString);
                 cc.SetUserName(ce.userName);
                 cc.SetPassword(ce.password);
                 cc.SetStructureStrategy(Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(ce.structure) ? ((Net.Vpc.Upa.Persistence.StructureStrategy)(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.Persistence.StructureStrategy>(typeof(Net.Vpc.Upa.Persistence.StructureStrategy)))) : (Net.Vpc.Upa.Persistence.StructureStrategy)(System.Enum.Parse(typeof(Net.Vpc.Upa.Persistence.StructureStrategy), ce.structure.ToUpper())));
                 cc.SetProperties(new System.Collections.Generic.Dictionary <string, string>());
                 foreach (System.Collections.Generic.KeyValuePair <string, string> x in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, string> >(ce.properties))
                 {
                     cc.GetProperties()[(x).Key] = (x).Value;
                 }
                 pu.GetConnections().Add(cc);
             }
             foreach (Net.Vpc.Upa.Impl.Config.ConnectionElement ce in pue.rootConnectionElements)
             {
                 Net.Vpc.Upa.Persistence.ConnectionConfig cc = new Net.Vpc.Upa.Persistence.ConnectionConfig();
                 cc.SetConnectionString(ce.connectionString);
                 cc.SetUserName(ce.userName);
                 cc.SetPassword(ce.password);
                 cc.SetStructureStrategy(Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(ce.structure) ? ((Net.Vpc.Upa.Persistence.StructureStrategy)(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.Persistence.StructureStrategy>(typeof(Net.Vpc.Upa.Persistence.StructureStrategy)))) : (Net.Vpc.Upa.Persistence.StructureStrategy)(System.Enum.Parse(typeof(Net.Vpc.Upa.Persistence.StructureStrategy), ce.structure.ToUpper())));
                 cc.SetProperties(new System.Collections.Generic.Dictionary <string, string>());
                 foreach (System.Collections.Generic.KeyValuePair <string, string> x in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, string> >(ce.properties))
                 {
                     cc.GetProperties()[(x).Key] = (x).Value;
                 }
                 pu.GetRootConnections().Add(cc);
             }
             gc.GetPersistenceUnits().Add(pu);
         }
     }
     return(c);
 }