本文整理汇总了C#中IObjectSpace.CreateObject方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectSpace.CreateObject方法的具体用法?C# IObjectSpace.CreateObject怎么用?C# IObjectSpace.CreateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectSpace
的用法示例。
在下文中一共展示了IObjectSpace.CreateObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDefaultSolution
public static void InitializeDefaultSolution(IObjectSpace os)
{
var enumerable = ReflectionHelper.FindTypeDescendants(ReflectionHelper.FindTypeInfoByName(typeof(I单据编号).FullName));
var dictionary = os.GetObjects<单据编号方案>(null, true).ToDictionary(p => p.应用单据);
foreach (ITypeInfo info2 in enumerable)
{
if (!info2.IsAbstract && info2.IsPersistent)
{
var key = info2.Type;
单据编号方案 i单据编号方案 = null;
if (dictionary.ContainsKey(key))
{
i单据编号方案 = dictionary[key];
}
else
{
i单据编号方案 = os.CreateObject<单据编号方案>();
i单据编号方案.名称 = key.FullName;
i单据编号方案.应用单据 = info2.Type;
var item = os.CreateObject<单据编号自动编号规则>();
item.格式化字符串 = "00000";
i单据编号方案.编号规则.Add(item);
dictionary.Add(key, i单据编号方案);
}
}
}
os.CommitChanges();
}
示例2: CreateRegistrationEmailTemplates
private void CreateRegistrationEmailTemplates(IObjectSpace objectSpace) {
if (!objectSpace.Contains<EmailTemplate>()) {
var emailTemplate = objectSpace.CreateObject<EmailTemplate>();
emailTemplate.Configure(EmailTemplateConfig.UserActivation, "http://localhost:50822/");
emailTemplate = objectSpace.CreateObject<EmailTemplate>();
emailTemplate.Configure(EmailTemplateConfig.PassForgotten);
}
}
示例3: ClassGeneratorHelper
public ClassGeneratorHelper(IObjectSpace XPObjectSpace) {
_persistentAssemblyInfo = XPObjectSpace.CreateObject<PersistentAssemblyInfo>();
_persistentAssemblyInfo.Name = "PersistentAssemblyInfo";
_persistentClassInfo = XPObjectSpace.CreateObject<PersistentClassInfo>();
_persistentClassInfo.Name = "MainTable";
_persistentAssemblyInfo.PersistentClassInfos.Add(_persistentClassInfo);
_persistentClassInfo.SetDefaultTemplate(TemplateType.Class);
_classGeneratorInfos = new Dictionary<string, ClassGeneratorInfo>();
var classGeneratorInfo = new ClassGeneratorInfo(PersistentClassInfo, DbTable);
_classGeneratorInfos.Add(PersistentClassInfo.Name, classGeneratorInfo);
}
示例4: Authenticate
public override object Authenticate(IObjectSpace objectSpace)
{
string systemUserName = WindowsIdentity.GetCurrent().Name;
string enteredUserName = ((AuthenticationStandardLogonParameters)LogonParameters).UserName;
if (string.IsNullOrEmpty(enteredUserName))
{
throw new ArgumentException(SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.UserNameIsEmpty));
}
if (!String.Equals(systemUserName, enteredUserName))
{
throw new AuthenticationException(enteredUserName, "Invalid user name");
}
object user = objectSpace.FindObject(UserType, new BinaryOperator("UserName", systemUserName));
if (user == null)
{
user = objectSpace.CreateObject(UserType);
((IAuthenticationActiveDirectoryUser)user).UserName = systemUserName;
bool strictSecurityStrategyBehavior = SecurityModule.StrictSecurityStrategyBehavior;
SecurityModule.StrictSecurityStrategyBehavior = false;
objectSpace.CommitChanges();
SecurityModule.StrictSecurityStrategyBehavior = strictSecurityStrategyBehavior;
}
if (!((IAuthenticationStandardUser)user).ComparePassword(((AuthenticationStandardLogonParameters)LogonParameters).Password))
{
throw new AuthenticationException(systemUserName, SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation));
}
return user;
}
示例5: CreateOutputPackage
/// <summary>
/// Creates the output package.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <param name="recipient">The recipient.</param>
/// <param name="packageType">Type of the package.</param>
/// <returns>Output package</returns>
public Package CreateOutputPackage(IObjectSpace objectSpace, ReplicationNode recipient, PackageType packageType)
{
var result = objectSpace.CreateObject<Package>();
result.ApplicationName = XafDeltaModule.XafApp.ApplicationName;
result.SenderNodeId = Owner.CurrentNodeId;
result.RecipientNodeId = recipient.NodeId;
result.PackageType = packageType;
// for broadcast package recipient node Id is "AllNodes"
if (result.SenderNodeId == result.RecipientNodeId)
result.RecipientNodeId = ReplicationNode.AllNodes;
// assign package id
if (packageType == PackageType.Snapshot)
{
recipient.SnapshotDateTime = DateTime.UtcNow;
recipient.LastSavedSnapshotNumber++;
result.PackageId = recipient.LastSavedSnapshotNumber;
}
else
{
recipient.LastSavedPackageNumber++;
result.PackageId = recipient.LastSavedPackageNumber;
}
return result;
}
示例6: AuthenticateActiveDirectory
private object AuthenticateActiveDirectory(IObjectSpace objectSpace) {
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null) {
string userName = windowsIdentity.Name;
var user = (IAuthenticationActiveDirectoryUser)objectSpace.FindObject(UserType, new BinaryOperator("UserName", userName));
if (user == null) {
if (_createUserAutomatically) {
var args = new CustomCreateUserEventArgs(objectSpace, userName);
if (!args.Handled) {
user = (IAuthenticationActiveDirectoryUser)objectSpace.CreateObject(UserType);
user.UserName = userName;
if (Security != null) {
//Security.InitializeNewUser(objectSpace, user);
Security.CallMethod("InitializeNewUser", new object[]{objectSpace, user});
}
}
objectSpace.CommitChanges();
}
}
if (user == null) {
throw new AuthenticationException(userName);
}
return user;
}
return null;
}
示例7: CreateArtifact
private static ModuleArtifact CreateArtifact(ModuleChild moduleChild, ModuleArtifactType moduleArtifactType,IObjectSpace objectSpace, Type type){
var moduleArtifact = objectSpace.CreateObject<ModuleArtifact>();
moduleArtifact.Name = type.Name;
moduleArtifact.Type = moduleArtifactType;
moduleArtifact.ModuleChilds.Add(moduleChild);
return moduleArtifact;
}
示例8: CreateForPackageSession
/// <summary>
/// Creates for package session.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <param name="packageSession">The package session.</param>
/// <returns>New external protocol session</returns>
public static ExternalProtocolSession CreateForPackageSession(IObjectSpace objectSpace, PackageSession packageSession)
{
var result = objectSpace.CreateObject<ExternalProtocolSession>();
result.SessionId = packageSession.SessionId;
result.Route = packageSession.Route;
result.StartedOn = packageSession.StartedOn;
return result;
}
示例9: Generate
void Generate(IObjectSpace objectSpace, Type typeToSerialize) {
if (!SerializationConfigurationQuery.ConfigurationExists(((XPObjectSpace)objectSpace).Session, typeToSerialize, _serializationConfigurationGroup)) {
var serializationConfiguration =
(ISerializationConfiguration)
objectSpace.CreateObject(TypesInfo.Instance.SerializationConfigurationType);
serializationConfiguration.SerializationConfigurationGroup = _serializationConfigurationGroup;
serializationConfiguration.TypeToSerialize = typeToSerialize;
Generate(serializationConfiguration);
}
}
示例10: GetInstance
public static IFirstLaunchParameters GetInstance(IObjectSpace objectSpace)
{
var parameters = objectSpace.FindObject<IFirstLaunchParameters>(null);
if (parameters == null)
{
parameters = objectSpace.CreateObject<IFirstLaunchParameters>();
parameters.DummyObjectsCreated = false;
}
return parameters;
}
示例11: CreateModelNodeAttributes
private static IEnumerable<ModelNodeAttribute> CreateModelNodeAttributes(IObjectSpace objectSpace,Type interfaceExtender) {
foreach (var propertyInfo in interfaceExtender.Properties()) {
var modelNodeAttribute = objectSpace.CreateObject<ModelNodeAttribute>();
modelNodeAttribute.Name = propertyInfo.Name;
var descriptionAttribute = propertyInfo.GetCustomAttributes(true).OfType<DescriptionAttribute>().FirstOrDefault();
if (descriptionAttribute != null)
modelNodeAttribute.Text = descriptionAttribute.Description;
yield return modelNodeAttribute;
}
}
示例12: CreateForArgs
/// <summary>
/// Creates for argumets.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <param name="args">The arguments.</param>
/// <returns></returns>
public static MethodCallParams CreateForArgs(IObjectSpace objectSpace, object[] args)
{
var i = 0;
var result = objectSpace.CreateObject<MethodCallParams>();
foreach (var arg in args)
{
var paramValue = MethodParamValue.CreateForArg(objectSpace, arg);
paramValue.OrdNo = i++;
paramValue.MethodCallParams = result;
}
return result;
}
示例13: CompoundPKMemberGeneratorHelper
public CompoundPKMemberGeneratorHelper(IObjectSpace XPObjectSpace)
: base(XPObjectSpace) {
_dbColumn1 = new DBColumn { Name = "DBColumn1", ColumnType = DBColumnType.Int32 };
_dbColumn2 = new DBColumn { Name = "DBColumn2", ColumnType = DBColumnType.Int32 };
var dbColumns = new[] { _dbColumn1, _dbColumn2 };
DbTable.Columns.AddRange(dbColumns);
DbTable.PrimaryKey = new DBPrimaryKey(dbColumns);
_structPersistentClassInfo = XPObjectSpace.CreateObject<PersistentClassInfo>();
_structPersistentClassInfo.Name = "MainTable" + TableMapper.KeyStruct;
_structPersistentClassInfo.PersistentAssemblyInfo = (PersistentAssemblyInfo)PersistentAssemblyInfo;
_structPersistentClassInfo.SetDefaultTemplate(TemplateType.Struct);
ClassGeneratorInfos.Add(_structPersistentClassInfo.Name, new ClassGeneratorInfo(StructPersistentClassInfo, DbTable));
}
示例14: GetObjectCore
protected virtual object GetObjectCore(IModelDetailView modelView, object objectKey, IObjectSpace objectSpace) {
Type type = modelView.ModelClass.TypeInfo.Type;
object obj;
if (XafTypesInfo.CastTypeToTypeInfo(type).IsPersistent) {
if (objectKey != null && !(objectKey is CriteriaOperator))
obj = objectSpace.GetObjectByKey(type, objectKey);
else {
obj = objectSpace.FindObject(type, (CriteriaOperator)objectKey) ?? objectSpace.CreateObject(type);
if (!(objectSpace.IsNewObject(obj)))
((IXafApplication)_application).AfterViewShown += OnAfterViewShown;
}
} else {
obj = (type.GetConstructor(new[] { typeof(Session) }) != null) ? objectSpace.CreateObject(type) : Activator.CreateInstance(type);
}
return obj;
}
示例15: GetSession
/// <summary>
/// Gets the session.
/// </summary>
/// <param name="objectSpace">The object space.</param>
/// <param name="packageSession">The package session.</param>
/// <returns>New external protocol session</returns>
public static ExternalProtocolSession GetSession(IObjectSpace objectSpace, PackageSession packageSession)
{
var result =
objectSpace.FindObject<ExternalProtocolSession>(
CriteriaOperator.Parse("SessionId = ?", packageSession.SessionId), true);
if(result == null)
{
result = objectSpace.CreateObject<ExternalProtocolSession>();
result.SessionId = packageSession.SessionId;
result.Route = packageSession.Route;
result.StartedOn = packageSession.StartedOn;
result.CommitedOn = packageSession.CommitedOn;
if (packageSession.Parent != null)
result.Parent = GetSession(objectSpace, packageSession.Parent);
}
return result;
}