public override IContext CreateContext(string contextName, ContextSchema schema) { if (string.IsNullOrEmpty(contextName)) { throw new ArgumentNullException("contextName"); } if (schema == null) { throw new ArgumentNullException("schema"); } IContext context; lock (padlock) { if (ContextsContains(contextName)) { throw new ContextAlreadyExistsException("A context with the name [" + contextName + "] already exists."); } using (var transaction = TransactionFactory.BeginTransaction(CurrentDB)) { CurrentDB.ExecuteNonQuery("dbo.USER_CreateContext", transaction, CurrentDB.CreateStringInputParameter("@chvContext", DbType.AnsiString, contextName)); foreach (var s in schema) { AddSchemaToContext(s, contextName, transaction); } context = new Context(contextName); transaction.Commit(); } contexts.Add(context); } return(context); }
public override ContextSchema GetDefaultContextSchema() { if (this.defaultContextSchema != null) { return(this.defaultContextSchema); } var pdt = new List <PropertyDefinition>(); DirectoryObject directoryObject = CurrentDS.CreateDirectoryObjectInstance(); foreach (Property property in directoryObject.Properties) { string propertyName = property.Name; Type propertyType = typeof(Property <string>); PropertyDefinition pd = new PropertyDefinition(propertyName, propertyType); pdt.Add(pd); } this.defaultContextSchema = new ContextSchema(pdt); return(this.defaultContextSchema); }
public PropertyCollection(IList<IProperty> innerList, ContextSchema schema) { this.innerList = innerList ?? new List<IProperty>(); this.schema = schema ?? new ContextSchema(new List<PropertyDefinition>()); }
public abstract IContext CreateContext(string contextName, ContextSchema schemaTable);
public override IContext CreateContext(string contextName, ContextSchema schemaTable) { return this.repository.CreateContext(contextName, schemaTable); }
public override IContext CreateContext(string contextName, ContextSchema schemaTable) { return(this.repository.CreateContext(contextName, schemaTable)); }
protected virtual ContextSchema GetContextSchema(string contextName, ITransaction transaction) { if (contextSchema.Keys.Contains(contextName)) { return(contextSchema[contextName]); } lock (padlock) { if (contextSchema.Keys.Contains(contextName)) { return(contextSchema[contextName]); } var pdt = new List <PropertyDefinition>(); IDataParameter[] prams = { CurrentDB.CreateStringInputParameter("@chvContext", DbType.AnsiString, contextName, true) }; DataSet dsUser; if (transaction == null) { dsUser = CurrentDB.ExecuteDataSet("dbo.USER_GetPropertySchema", prams); } else { dsUser = CurrentDB.ExecuteDataSet("dbo.USER_GetPropertySchema", transaction, prams); } // translate dataset if (dsUser.Tables.Count > 0) { foreach (DataRow row in dsUser.Tables[0].Rows) { var propertyName = (string)row["PropertyName"]; Type propertyType; if (!row.IsNull("AssemblyPath")) { var assembly = Assembly.LoadFrom((string)row["AssemblyPath"]); propertyType = assembly.GetType((string)row["DataType"]); } else if (!row.IsNull("AssemblyName")) { var assembly = Assembly.Load((string)row["AssemblyName"]); propertyType = assembly.GetType((string)row["DataType"]); } else { propertyType = Type.GetType((string)row["DataType"]); } if (propertyType == null) { throw new NotSupportedException(string.Format("The given property has a type {0} that can not be loaded.", row["DataType"])); } var pd = new PropertyDefinition(propertyName, propertyType); pdt.Add(pd); } } var schema = new ContextSchema(pdt); contextSchema.Add(contextName, schema); return(schema); } }
public override ContextSchema GetDefaultContextSchema() { if(this.defaultContextSchema != null) return this.defaultContextSchema; var pdt = new List<PropertyDefinition>(); DirectoryObject directoryObject = CurrentDS.CreateDirectoryObjectInstance(); foreach(Property property in directoryObject.Properties) { string propertyName = property.Name; Type propertyType = typeof(Property<string>); PropertyDefinition pd = new PropertyDefinition(propertyName, propertyType); pdt.Add(pd); } this.defaultContextSchema = new ContextSchema(pdt); return this.defaultContextSchema; }
public override IContext CreateContext(string contextName, ContextSchema schemaTable) { throw new NotImplementedException(); }
protected virtual ContextSchema GetContextSchema(string contextName, ITransaction transaction) { if(contextSchema.Keys.Contains(contextName)) { return contextSchema[contextName]; } lock(padlock) { if(contextSchema.Keys.Contains(contextName)) { return contextSchema[contextName]; } var pdt = new List<PropertyDefinition>(); IDataParameter[] prams = { CurrentDB.CreateStringInputParameter("@chvContext", DbType.AnsiString, contextName, true) }; DataSet dsUser; if(transaction == null) { dsUser = CurrentDB.ExecuteDataSet("dbo.USER_GetPropertySchema", prams); } else { dsUser = CurrentDB.ExecuteDataSet("dbo.USER_GetPropertySchema", transaction, prams); } // translate dataset if(dsUser.Tables.Count > 0) { foreach(DataRow row in dsUser.Tables[0].Rows) { var propertyName = (string)row["PropertyName"]; Type propertyType; if(!row.IsNull("AssemblyPath")) { var assembly = Assembly.LoadFrom((string)row["AssemblyPath"]); propertyType = assembly.GetType((string)row["DataType"]); } else if(!row.IsNull("AssemblyName")) { var assembly = Assembly.Load((string)row["AssemblyName"]); propertyType = assembly.GetType((string)row["DataType"]); } else { propertyType = Type.GetType((string)row["DataType"]); } if(propertyType == null) { throw new NotSupportedException(string.Format("The given property has a type {0} that can not be loaded.", row["DataType"])); } var pd = new PropertyDefinition(propertyName, propertyType); pdt.Add(pd); } } var schema = new ContextSchema(pdt); contextSchema.Add(contextName, schema); return schema; } }
public override IContext CreateContext(string contextName, ContextSchema schema) { if(string.IsNullOrEmpty(contextName)) { throw new ArgumentNullException("contextName"); } if(schema == null) { throw new ArgumentNullException("schema"); } IContext context; lock(padlock) { if(ContextsContains(contextName)) { throw new ContextAlreadyExistsException("A context with the name [" + contextName + "] already exists."); } using(var transaction = TransactionFactory.BeginTransaction(CurrentDB)) { CurrentDB.ExecuteNonQuery("dbo.USER_CreateContext", transaction, CurrentDB.CreateStringInputParameter("@chvContext", DbType.AnsiString, contextName)); foreach(var s in schema) { AddSchemaToContext(s, contextName, transaction); } context = new Context(contextName); transaction.Commit(); } contexts.Add(context); } return context; }