本文整理汇总了C#中Schema.AsActual方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.AsActual方法的具体用法?C# Schema.AsActual怎么用?C# Schema.AsActual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema.AsActual方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
public virtual TextContent Bind(Schema schema, TextContent textContent, System.Collections.Specialized.NameValueCollection values, bool update, bool thorwViolationException)
{
List<RuleViolation> violations = new List<RuleViolation>();
schema = schema.AsActual();
//do not to create a new content instance
//it will interrupt the object state for ravendb.
//textContent = new TextContent(textContent);
foreach (Column column in ((ISchema)(schema.AsActual())).Columns.Where(it => !string.IsNullOrEmpty(it.ControlType)))
{
var value = values[column.Name];
//IControl control = column.GetControlType();
////
//if (control != null)
//{
// value = control.GetValue(textContent[column.Name], value);
//}
// Update content will keep the old values;
if (value == null && update == true)
{
continue;
}
//postedData[column.Name] = value;
ParseColumnValue(textContent, ref violations, column, value);
ValidateColumn(schema, textContent, ref violations, column, update);
}
if (thorwViolationException && violations.Count > 0)
{
throw new RuleViolationException(textContent, violations);
}
return textContent;
}
示例2: OnExcluded
public void OnExcluded(ModuleContext moduleContext)
{
var repository = moduleContext.Site.AsActual().GetRepository();
if (repository != null)
{
TextFolder productFolder = new TextFolder(repository, "Product");
if (productFolder.AsActual() != null)
{
_textFolderManager.Remove(repository, productFolder);
}
Schema productSchema = new Schema(repository, "Product");
if (productSchema.AsActual() != null)
{
_schemaManager.Remove(repository, productSchema);
}
}
}
示例3: Default
public TextContent Default(Schema schema)
{
List<RuleViolation> violations = new List<RuleViolation>();
TextContent textContent = new TextContent();
foreach (Column column in ((ISchema)(schema.AsActual())).Columns)
{
if (!string.IsNullOrEmpty(column.DefaultValue))
{
ParseColumnValue(textContent, ref violations, column, column.DefaultValue);
}
else
{
textContent[column.Name] = DataTypeHelper.DefaultValue(column.DataType);
}
}
return textContent;
}
示例4: Add
public static void Add(Schema schema)
{
if (CheckTableExists(schema))
{
Delete(schema);
}
StringBuilder columns = new StringBuilder();
schema = schema.AsActual();
foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
{
columns.AppendFormat(",`{0}` {1}", column.Name, ColumnTypeDefinition(column));
}
string ddl = string.Format(createTable, schema.GetTableName(), columns.ToString(), MysqlSettings.Instance.DEFAULT_CHARSET);
ExecuteDDL(schema.Repository, ddl);
}
示例5: Copy
public virtual TextContent Copy(Schema schema, string uuid)
{
var repository = schema.Repository;
var content = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
if (content != null)
{
var textContent = new TextContent(content);
textContent.Id = "";
textContent.UUID = "";
textContent.UtcCreationDate = DateTime.Now;
textContent.UtcLastModificationDate = DateTime.Now;
textContent.Published = null;
textContent.Sequence = 0;
textContent.UserKey = null;
var titleField = schema.AsActual().GetSummarizeColumn();
if (titleField != null)
{
textContent[titleField.Name] = (content[titleField.Name] ?? "") + " - Copy".Localize();
}
EventBus.Content.ContentEvent.Fire(ContentAction.PreAdd, textContent);
TextContentProvider.Add(textContent);
var categories = this.QueryCategories(repository, content.FolderName, uuid);
this.AddCategories(repository, textContent, categories.SelectMany(it => it.Contents).ToArray());
EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent);
return textContent;
}
return null;
}
示例6: ConvertToColumnType
public object ConvertToColumnType(Schema schema, string field, string value)
{
schema = schema.AsActual();
var column = schema.AllColumns.Where(it => it.Name.EqualsOrNullEmpty(field, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (column == null)
{
return value;
}
return ConvertToColumnType(column, value);
}
示例7: OnIncluded
public void OnIncluded(ModuleContext moduleContext)
{
var repository = moduleContext.Site.AsActual().GetRepository();
if (repository != null)
{
//import the content types. the zip file contains "Category" content type.
//var contentTypePath = new ModulePathHelper(ModuleAreaRegistration.ModuleName).GetModuleInstallationFilePath("ContentType.zip");
//if (File.Exists(contentTypePath.PhysicalPath))
//{
// using (FileStream fs = new FileStream(contentTypePath.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
// {
// _schemaManager.Import(repository, fs, true);
// }
//}
Schema productSchema = new Schema(repository, "Product");
productSchema.AddColumn("ProductName", "TextBox", DataType.String, "", true, true);
productSchema.AddColumn("ProductDetail", "Tinymce", DataType.String, "", false, true);
if (productSchema.AsActual() == null)
{
_schemaManager.Add(repository, productSchema);
}
TextFolder productFolder = new TextFolder(repository, "Product")
{
SchemaName = "Product"
};
if (productFolder.AsActual() == null)
{
_textFolderManager.Add(repository, productFolder);
}
}
}
示例8: GetIndexColumn
private string GetIndexColumn(Schema schema)
{
StringBuilder sb = new StringBuilder(@"UUID = doc[""UUID""],FolderName=doc[""FolderName""],UserKey=doc[""UserKey""],UtcCreationDate=doc[""UtcCreationDate""],UtcLastModificationDate=doc[""UtcLastModificationDate""],Published=doc[""Published""],SchemaName=doc[""SchemaName""],ParentUUID=doc[""ParentUUID""],OriginalUUID=doc[""OriginalUUID""],UserId=doc[""UserId""]");
schema = schema.AsActual();
foreach (var item in schema.Columns)
{
if (item.Indexable)
{
sb.AppendFormat(@",{0}=doc[""{0}""]", item.Name);
}
}
return sb.ToString();
}