当前位置: 首页>>代码示例>>C#>>正文


C# IObjectSpace.GetObjectByKey方法代码示例

本文整理汇总了C#中IObjectSpace.GetObjectByKey方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectSpace.GetObjectByKey方法的具体用法?C# IObjectSpace.GetObjectByKey怎么用?C# IObjectSpace.GetObjectByKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObjectSpace的用法示例。


在下文中一共展示了IObjectSpace.GetObjectByKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:kevin3274,项目名称:eXpand,代码行数:17,代码来源:ViewShortCutProccesor.cs

示例2: AfterConstruction

        public static void AfterConstruction(ISerialDataObject serialDataObject, IObjectSpace os)
        {
            serialDataObject.ReplicationId = Guid.NewGuid();
            serialDataObject.ObjectCode = String.Empty;
            serialDataObject.RegCode = String.Empty;
            serialDataObject.Number = 0;

            var user = os.GetObjectByKey<SecuritySystemUser>(SecuritySystem.CurrentUserId);
            if (user != null)
            {
                var employee = user as Employee;
                if (employee != null)
                {
                    serialDataObject.User = employee;
                    serialDataObject.Department = employee.Department;
                }
            }
        }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:18,代码来源:ISerialDataObject.cs

示例3: GetUserOwner

 /// <summary>
 /// Возвращает собственника данных текущего пользователя для указанного пространства объектов
 /// </summary>
 /// <param name="objectSpace">Пространство объектов для сохранения и загрузки объектов</param>
 /// <returns>Собственник даных текущего пользователя</returns>
 public static Owner GetUserOwner(IObjectSpace objectSpace)
 {
     if (UserOwner == null) return null;
     return (Owner)objectSpace.GetObjectByKey(typeof(Owner), UserOwner.Id);
 }
开发者ID:LSTANCZYK,项目名称:devexpress_xaf_aurum,代码行数:10,代码来源:Owner.cs

示例4: CreateNewExamination

        /// <summary>
        /// Метод создает в БД новое обследование
        /// </summary>
        private IExamination CreateNewExamination(IObjectSpace os, IPatient patient, Guid id, ExaminationType type = null, bool allowEmptyFile = false)
        {
            IExamination examination = os.CreateObject<IExamination>();
            examination.ExaminationSoftType = os.FindObject<ExaminationSoftType>(CriteriaOperator.Parse("ExaminationSoftTypeId = ?", id));
            examination.Patient = os.GetObject<IPatient>(patient);

            examination.AllowEmptyOrNotExistsFile = allowEmptyFile;
            examination.TimeStart = DateTime.Now;
            // Создается новое обследование поэтому файла еще нет
            if (examination.ExaminationFile == null)
            {
                // заводим в базе файл
                //examination.ExaminationFile = os.CreateObject<FileSystemStoreObject>();
                examination.ExaminationFile = os.CreateObject<ExaminationFile>();
                examination.ExaminationFile.OwnerId = (examination as DevExpress.ExpressApp.DC.DCBaseObject).Oid;
                if (type != null)
                {
                    examination.ExaminationType = os.GetObjectByKey<ExaminationType>(type.Oid); //FindObject<ExaminationType>(CriteriaOperator.Parse("ExaminationTypeId = ?", type.));
                }

                // Применяем изменения
                os.CommitChanges();

                if (String.IsNullOrEmpty(examination.ObjectCode) == false)
                {
                    string fileName = examination.ObjectCode;
                    string fileExtension = examination.ExaminationSoftType.ExaminationFileExtension;

                    examination.ExaminationFile.FileName = Converters.GetFileNameWithoutInvalidChars(fileName, fileExtension);
                }
                else
                    throw new Exception("Examination invalid params");
            }

            os.CommitChanges(); // здесь создается пустой файл обследования

            while (os.IsCommitting) { Thread.Sleep(1000); } // ждем пока применятся изменения, не знаю зачем...

            //// Заполняем созданный файл заключения
            //// !!! ЗАПОЛНЯТЬ ЗАКЛЮЧЕНИЕ ПРИ СОЗДАНИИ НЕ НАДО !!!
            //ConclusionViewController conclusionController = Frame.GetController<ConclusionViewController>();
            //if (conclusionController != null)
            //{
            //    conclusionController.PopulateConclusionFile(examination);
            //}

            return examination;
        }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:51,代码来源:RunDynamicModuleController.cs

示例5: AfterConstruction

        public static void AfterConstruction(IExamination examination, IObjectSpace os)
        {
            examination.Examiner = os.GetObjectByKey<Employee>(SecuritySystem.CurrentUserId);

            examination.Anamnesis = String.Empty;
            examination.Description = String.Empty;
            examination.Drugs = String.Empty;

            examination.IsPopulatedConclusion = false;

            if (examination.ConclusionFile == null)
            {
                //examination.ConclusionFile = os.CreateObject<FileSystemStoreObject>();
                examination.ConclusionFile = os.CreateObject<ConclusionFile>();
                var conclusion = examination.ConclusionFile;
                conclusion.FileName = "Conclusion.rtf";
                conclusion.OwnerId = (examination as DevExpress.ExpressApp.DC.DCBaseObject).Oid;

                var organization = os.FindObject<IOrganization>(null);
                if (organization != null)
                {
                    var template = organization.ConclusionTemplate;
                    if (template != null)
                    {
                        CreateFromTemplate(template, conclusion);
                    }
                }

                examination.ExaminationNotes = os.CreateObject<IExaminationNotes>();
            }
        }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:31,代码来源:IExamination.cs

示例6: findApplicationObjectByKnownMaps

        /// <summary>
        /// Finds the application object by known maps.
        /// </summary>
        /// <param name="objectSpace">The object space.</param>
        /// <param name="reference">The reference.</param>
        /// <returns>Application object</returns>
        private static object findApplicationObjectByKnownMaps(IObjectSpace objectSpace, IObjectReference reference)
        {
            object result = null;
            // search using known mappings
            if (reference is IPackageObjectReference)
            {
                var objRef = (IPackageObjectReference) reference;
                if (!string.IsNullOrEmpty(objRef.KnownMapping))
                {
                    var typeInfo = objectSpace.TypesInfo.FindTypeInfo(objRef.ClassName);
                    if (typeInfo != null)
                    {
                        foreach (var mappingString in objRef.KnownMapping.Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries))
                        {
                            var mapValues = mappingString.Split('\a');
                            if (mapValues.Length < 2) continue;

                            var refNodeId = mapValues[0];

                            if (refNodeId == XafDeltaModule.Instance.CurrentNodeId)
                                // direct search by TargetId in current database
                                result = objectSpace.GetObjectByKey(typeInfo.Type,
                                    XPWeakReference.StringToKey(mapValues[1]));
                            else
                            {
                                // search similar mapping in existing OidMaps and return its target
                                var searchCriteria =
                                    CriteriaOperator.Parse("NodeId = ? And AssemblyName = ? And ClassName = ? And ObjectId = ?",
                                                           refNodeId, reference.AssemblyName, reference.ClassName, mapValues[1]);
                                var knownMap = objectSpace.FindObject<OidMap>(searchCriteria, true);
                                if (knownMap != null)
                                    result = knownMap.TargetObject;
                            }

                            if (result != null)
                                break;
                        }
                    }
                }
            }

            return result;
        }
开发者ID:xafdelta,项目名称:xafdelta,代码行数:49,代码来源:OidMap.cs

示例7: GetObject

 /// <summary>
 /// Возвращает объект по ссылке
 /// </summary>
 /// <param name="objectSpace">Пространство объектов</param>
 /// <param name="classType">Тип класса</param>
 /// <returns>Объект или null, если ссылка пустая</returns>
 public object GetObject(IObjectSpace objectSpace, Type classType)
 {
     object key = TargetKeyValue;
     return objectSpace.GetObjectByKey(classType, key);
 }
开发者ID:LSTANCZYK,项目名称:devexpress_xaf_aurum,代码行数:11,代码来源:Reference.cs


注:本文中的IObjectSpace.GetObjectByKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。