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


C# IDataObject.SetProperty方法代码示例

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


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

示例1: MergeDynamicProperties

        /// <summary>
        /// Merges dynamic properties of DataObject.
        /// </summary>
        /// <param name="baseObject">Base DataObject to be merged.</param>
        /// <param name="mergingObject">Merging DataObject to be merged into base DataObject.</param>
        /// <param name="checkPaths">Consider paths in the merging.</param>
        private void MergeDynamicProperties(IDataObject baseObject, IDataObject mergingObject, Boolean checkPaths)
        {
            baseObject.DynamicType = mergingObject.DynamicType;

            DataCache dynamicCache = (DataCache)typeof(DataObject).GetTypeInfo().GetDeclaredField("dynamicCache").GetValue(mergingObject);

            foreach (KeyValuePair<String, Object> propertyValue in dynamicCache.GetObjectsInRegion("Properties"))
            {
                Boolean includePath = true;

                if (this.Paths != null)
                {
                    includePath = !checkPaths;

                    foreach (String path in this.Paths)
                    {
                        if (propertyValue.Key == path)
                        {
                            includePath = true;
                        }
                    }
                }

                if ((!mergingObject.GetProxyState(propertyValue.Key)) && (includePath))
                {
                    if (propertyValue.Value != null)
                    {
                        Type propertyType = propertyValue.Value.GetType();

                        if (IsDataList(propertyType))
                        {
                            IDataList mergingList = ((IDataList)propertyValue.Value);
                            IDataList dataList = (IDataList)LightHouse.Elite.Core.Builder.Get(propertyValue.Value.GetType());

                            for (int i = 0; i < mergingList.Count; i++)
                            {
                                IDataObject cloningObject = (IDataObject)mergingList[i];

                                if (IsReferenceObject(cloningObject))
                                {
                                    //Proxy on new generated object should be set to false, otherwise will bet unproxied on storing

                                    if (String.IsNullOrEmpty(cloningObject.ID))
                                    {
                                        IDataObject referencedObject = GetProxyObject(cloningObject);
                                        dataList.Add(referencedObject);
                                    }
                                    else
                                    {

                                        dataList.Add(GetReferencedObject(cloningObject));
                                    }
                                }
                                else
                                {
                                    IDataObject referencedObject = GetProxyObject(cloningObject);
                                    dataList.Add(referencedObject);
                                }
                            }

                            baseObject.SetProperty(propertyValue.Key, dataList);
                        }
                        else if (IsDataObject(propertyType))
                        {
                            DataObject cloningObject = ((DataObject)propertyValue.Value);

                            if (IsReferenceObject(cloningObject))
                            {
                                // If the Object hasn't been saved, it is persisted as such to the database
                                if (String.IsNullOrEmpty(cloningObject.ID))
                                {
                                    IDataObject referencedObject = GetProxyObject(cloningObject);
                                    baseObject.SetProperty(propertyValue.Key, referencedObject);
                                }
                                else
                                {
                                    baseObject.SetProperty(propertyValue.Key, GetReferencedObject(cloningObject));
                                }
                            }
                            else
                            {
                                IDataObject referencedObject = GetProxyObject(cloningObject);
                                baseObject.SetProperty(propertyValue.Key, referencedObject);
                            }
                        }
                        else
                        {
                            baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
                        }
                    }
                    else
                    {
                        baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
                    }
//.........这里部分代码省略.........
开发者ID:PongpetTurneo,项目名称:LightHouse,代码行数:101,代码来源:MergeExecutor.cs


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